PageRenderTime 27ms CodeModel.GetById 20ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

/t_backcompat/wave.pl

http://github.com/PerlGameDev/SDL
Perl | 26 lines | 13 code | 6 blank | 7 comment | 2 complexity | 82bb2a7d46df2553fe9a7a2e496d7703 MD5 | raw file
 1#!/usr/bin/env perl
 2#
 3# This example plays a .WAV sound sample
 4#
 5use strict;
 6use warnings;
 7use SDL;
 8use SDL::Mixer;
 9use SDL::Sound;
10
11my $filename = shift || 'data/sample.wav';
12
13# we want a frequency that is higher than the default
14my $mixer = SDL::Mixer->new( -frequency => 44100, );
15print "Using audio driver: ", SDL::AudioDriverName(), "\n";
16
17my $wave = SDL::Sound->new($filename);
18
19# we don't care what channel, and we only want to play it once
20my $channel = $mixer->play_channel( -1, $wave, 0 );
21
22# wait until it has finished playing
23while ( $mixer->playing($channel) ) {
24	SDL::Delay(10);
25}
26