RAPID SEQUENCE of audioclips using the PREPARE command

J. Scott Saults SaultsJ at missouri.edu
Sat Jan 19 14:59:01 EST 2002


In use-revolution digest, Vol 1 #112, Kevin Miller <kevin at runrev.com> wrote:
>Have you tried using the "prepare" command on all the audioClips before you
>attempt to run the script that Scott Rossi supplied?
>
>Kind regards,
>
>Kevin


I made a couple of attempts to incorporate the 'prepare' command into 
the scripts Scott Rossi  (Thank you, Scott) supplied to play a 
sequence of audioclips.

First, I tried to 'prepare' the next audioClip right after playing 
one audioClip:

on runAudio
   if the sound is "done" then
     if the uCurrClip of me > the number of items of fld cliplist then
       set the uCurrClip of me to empty
       exit runAudio
     end if
     play audioClip (item (the uCurrClip of me) of fld cliplist)
     set the uCurrClip of me to the uCurrClip of me + 1
     prepare audioClip (item (the uCurrClip of me) of fld cliplist)
   end if
   send "runAudio" to me in 5 milliseconds
end runAudio

The 'play' commands begins playing its audioClip, which is quickly 
interrupted by the 'prepare' command playing the same sound. (Putting 
a 'wait until done' after the prepare command simply results in the 
complete sound being played twice and taking twice as long.)

Next, I tried to 'prepare' the complete set of audioClips in the 
initial mouseUp handler:

on mouseUp
   if the sound is not "done" then
     play stop
     set the uCurrClip of me to empty
     exit mouseUp
   end if
   repeat with i = 1 to the number of items of field "clipList"
     prepare audioclip (item 2 of field "clipList")
      wait until the sound is "done"
   end repeat
   set the uCurrClip of me to 1
   runAudio
end mouseUp

The successive 'prepare' commands plays each of the 10 sounds 
(presumably loading them into memory, as well) Then  'runAudio' plays 
the sounds at a rate of a little more than 500 ms per audioClip, when 
the audioClips are each 250 ms long. That rate (2/second), pretty 
erratic and about half what it should be (4/sec), is not 
significantly different from what I get without using the 'prepare' 
command.

In summary, using Scott Rossi's scripts, Revolution could only play 
the 250 ms audioclips at a rate of about 2/second, and the prepare 
command did make it any faster. (I was running on a Mac PowerPC G3 
220 MHz cpu under OS 9.0.4. Naturally, it's faster on a faster 
Pentium 4.)

In fact, I can't tell if the 'prepare' command works any differently 
than the 'play' command!

Keven suggested "you should try the "prepare" command, it will buffer 
audioClips
before playback.  Let me know if that works for you?"

Well, it does not seem to work.  Is this a bug? How is 'prepare' 
supposed to work?

I'm still open to suggestions, but it looks like I'll have to work on 
extracting and combining the audio file data, as suggested by Geoff 
Canyon and Sjoerd Op 't Land (Both have supplied useful information 
that I still need to digest and apply.)

Thanks and best regards,
Scott Saults



J. Scott Saults, Ph.D.
Research Associate
	email: SaultsJ at missouri.edu
Department of Psychology
	210 McAlester Hall



More information about the use-livecode mailing list