I’m trying to get a 25 second piece of sound to just play for the first 10 seconds through code, and then stop once my trials stop after 10 seconds.
My trials stop after 10 seconds which is perfect and what I need, however the sound doesn’t play after one second, it players at the end of the trials so after the 10 seconds., does anyone know this may occur?
Both of these are within each frame
if trial_timer.getTime() > 1:
sound1.play()
if trial_timer.getTime() > 10:
continueRoutine = False
Recall_Practice.finished = True
I suspect that your code gives the command to play the sound many times a second and maybe that leads to the problem. Does it help if you use the following?
if sound1.status == NOT_STARTED and trial_timer.getTime() > 1:
I tried it, didn’t work, no sound is now playing. I do think your suggestion maybe correct though, in that it’s trying to play the sound lots due to checking per frame.
I did wonder if it was to do with the clock, but the trial length works perfectly.
I searched the forums, and I can get the sound to work off trials e.g.
if trial.n == 0:
sound1.play()
if trial n ==20
sound1.stop()
My problem is I need blocks of trials based off lengths of times, rather than trial number.