This article applies to:
E-Prime 3.0
Detail
This experiment illustrates how to loop a sound based on whether a SlideButton is clicked.
Abstract
In the experiment, the Init InLine loads the sound buffer before Stimulus starts playing the sound buffer. It also runs the InitLoopTaskEvent subroutine. This creates a dummy Task Event to execute the LoopSoundOut1 subroutine after 5000ms when called (i.e. when PlaySoundLoopEvent is fired, LoopSoundOut1 will run after 5000ms).
On the Stimulus Slide, a SlideButton is presented. When the SlideButton is clicked, the PlaySoundOut1 Task Event is fired. This Task Event either starts or stops playback. If a playback is started by pressing the SlideButton, the PlaySoundLoopEvent is fired, thus firing LoopSoundOut1 5000ms later (the sound file is 5000ms long so this is why the number is chosen). LoopSoundOut1 plays the sound again after 5000ms and repeats the process by firing PlaySoundLoopEvent until the user stops playback by pressing the SlideButton again.
NOTE: The audio file in the .zip folder needs to be at the same level as the .es3.
Comments
1 comment
Hi there,
I am trying to figure out how to create a background noise for my experiment, which would need to play during the completion of a respiratory task. I stumbled upon the article above and was wondering whether you can create two slide objects. The first would, after button press, initiate the looped sound. Then after completion of the task, I would insert a second slide object, which enables me to stop the sound?
Would that be possible?
Best, Nina
Please sign in to leave a comment.