RAPID SEQUENCE of audioclips on a Mac
Scott Rossi
scott at tactilemedia.com
Mon Jan 7 19:45:00 EST 2002
Recently, J. Scott Saults wrote:
> For more than 12 years I've used HyperCard and SuperCard to present
> sequences of sounds, usually recorded speech but occasionally tones,
> to be used as stimuli in STM memory research. Arbitrary sequences of
> up to 20 sound resources can be played by simply issuing a series of
> 'play' commands. While the first sound begins playing, the remaining
> sounds are quickly loaded and cued to play in order, one immediately
> after the other. This provides a reasonably clean, reliable and
> precise sequence of sounds in which the onset-to-onset times,
> determined by the duration of the digitized samples, can be
> controlled within a few milliseconds. I can accomplish the same basic
> task in Revolution on the PC only by using the external commands of
> the MCPsych. DLLs, as far as I know. How can I do this in Revolution
> on a Mac, with or (preferably) without external commands?
As a developer, I would also like this ability in MC/REV, and have argued
over the years that having the MetaCard folks maintain control over sound
within MC would be much better than handing off audio support to QuickTime.
QT does have some advantages for playback, but seamless playback of multiple
clips is not one of them.
One thing to confirm first is that your sounds can be present as imported
audio clips, not as external files. I'm not sure about Hypercard but I know
that SuperCard can only play multiple clips seamlessly when the clips are
stored as internal sound resources.
If your stack allows you to rely on imported sounds, the following script
may work for you. I've done a couple of tests that seem to play imported
multiple clips back-to-back seamlessly, something which I don't believe is
doable with player objects due to inherent delay that results from loading
an unloading file references.
First, create a field named "cliplist" and enter all the names of your
imported clips that you want to play, delimited with commas
(myclip1,myclip2,myclip3,etc). Then create a playback button with this
script:
on mouseUp
if the sound is not "done" then
play stop
set the uCurrClip of me to empty
exit mouseUp
end if
set the uCurrClip of me to 1
runAudio
end mouseUp
Next, place this handler in your stack:
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
end if
send "runAudio" to me in 5 milliseconds
end runAudio
When clicking the playback button, the result should be that the clips in
your cliplist are played seamlessly, back-to-back, with playback ceasing as
the end of the cliplist is reached. The principle here is to establish a
timer which constantly checks the state of sound playback in your stack;
when any playing sound has finished, the next clip in your list is played.
Hope this helps.
Regards,
Scott
_____________________________________________________________________
Scott Rossi Tactile Media - Multimedia & Design
Creative Director Email: scott at tactilemedia.com
Web: http://www.tactilemedia.com
More information about the use-livecode
mailing list