Page 1 of 1

Waiting while sound is playing

Posted: Tue Mar 08, 2011 5:01 pm
by gjn1w07
Hi there,

I'm writing a program that plays an audioclip, then waits for 2 seconds, then plays another audioclip, waits another 2 seconds, then plays a final audioclip. The audioclips themselves vary from 1.5 to around 3ish seconds. However, at the moment the code looks something like this:

play audioclip clip1.wav
wait 2 seconds
play audioclip clip2.wav
wait 2 seconds
play audioclip clip3.wav

The problem is that the wait functions execute from the beginning of the audioclip, rather than waiting till the audioclip is finished. So at best the audioclips play end to end, and sometimes a clip is stopped so a new one can start. How can I do what I actually want to do? I have a feeling the playstopped message comes into it somewhere but my understanding of the code isn't good enough yet to figure out how!

Any help would be greatly appreciated.

Re: Waiting while sound is playing

Posted: Tue Mar 08, 2011 5:07 pm
by Klaus
Hi gjn1w07,

the magic word is "sound" and "done", OK the magic wordS ARE "sound" and "done" :D

...
## ac = abbreviation for audioclip
play ac "clip1.wav"
wait until the sound is "done"
play ac "clip2.wav"
wait until the sound is "done"
play ac "clip3.wav"
...

Hint: Get used to put QUOTES around names! Remember Murphys law 8)


Best from germany

Klaus

Re: Waiting while sound is playing

Posted: Tue Mar 08, 2011 5:42 pm
by gjn1w07
Awesome - that's exactly what I needed. Thank you so much. I was starting to get into overly complicated ways to do it, like having a player object to put the sounds into and then put in a wait command based on the duration of the player.

Greg