From: Leon Brocard Date: Fri, 9 Oct 2009 15:11:20 +0000 (+0100) Subject: Add an example that plays a .WAV sound sample X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=71dfa2cb2dfa261a15c575a98e3545e536bb56c1;p=sdlgit%2FSDL_perl.git Add an example that plays a .WAV sound sample --- diff --git a/MANIFEST b/MANIFEST index e6a600a..9fab935 100644 --- a/MANIFEST +++ b/MANIFEST @@ -135,5 +135,6 @@ test/testjoystick.pl test/testmenu.pl test/testsprite.pl test/testtimer.pl +test/wave.pl TODO typemap diff --git a/test/wave.pl b/test/wave.pl new file mode 100644 index 0000000..fcb8cbb --- /dev/null +++ b/test/wave.pl @@ -0,0 +1,29 @@ +#!/usr/bin/env perl +# +# This example plays a .WAV sound sample +# +use strict; +use warnings; +use SDL; +use SDL::Mixer; +use SDL::Sound; + +SDL::Init(SDL_INIT_AUDIO); + +my $filename = shift || 'data/sample.wav'; + +my $mixer = SDL::Mixer->new( + -frequency => 44100, +); +print "Using audio driver: ", SDL::AudioDriverName(), "\n"; + +my $wave = SDL::Sound->new($filename); + +# we don't care what channel, and we only want to play it once +my $channel = $mixer->play_channel( -1, $wave, 0 ); + +# wait until it has finished playing +while ( $mixer->playing($channel) ) { + SDL::Delay(10); +} +