I recently installed the standalone package of 2023.2.0 (on a Mac), and have an issue that wasn’t present in 2023.1.3.
The experiment loops over a single trial routine. In that routine is a sound component trial_beep that has a specified time (s) Start time, and an empty Stop time. (There’s also a text component and a keyboard component)
In 2023.2.0, the sound trial_beep plays on the first iteration of the loop, but no sound plays on any subsequent iterations of the loop. Sounds play correctly if a Stop time is provided that is the exact duration of the sound file. (This is fine in some cases, but if you’re looping over sound files of different duration, this is a problem).
In 2023.1.3, the sound plays (as intended) on every iteration of the loop, even with an empty Stop time.
I’ve tried using trial_beep.stop() in a code component in End Routine, hoping that would kill the audio and let it restart on the next trial, but no luck.
Any suggestions on how to get back to the 2023.1.3 behavior would be appreciated.
I’ve created a minimal working example here: broken_sound_test.psyexp (14.4 KB) sound.wav stimlist.csv (285 Bytes)
NB: the code component PTB_fix must be disabled when running in 2023.2.0 and enabled when running in 2023.1.3, due to this issue and its resolution in 2023.2.0.
I think I see the problem - it’s that calling sound.seek(0) (as the stop function does) doesn’t change the value of sound.isFinished; so once it’s run through once, even though the timestamp has been set back to 0 at Routine end, it still thinks it’s finished so refuses to play. Will get a fix in for this ASAP!
Quick fix in the meantime is to change trial_beep.isFinished = False in your Code component to trial_beep._isFinished = False and then enable it.
I made the suggested quick fix, but that has caused a new error:
File "/Users/abraver/Library/CloudStorage/Dropbox/PsychoPy stuff/broken_sound_test/broken_sound_test_lastrun.py", line 584, in <module>
File "/Users/abraver/Library/CloudStorage/Dropbox/PsychoPy stuff/broken_sound_test/broken_sound_test_lastrun.py", line 454, in run
if thisExp.status == FINISHED or endExpNow:
NameError: name 'endExpNow' is not defined
If I define endExpNow = False in the Begin Routine section of the code component, the experiment will run and the sounds play as intended (yay!). (So at the very least, I have a fix that works for the time being.)
Perhaps _isFinished needs endExpNow to be defined in a way that .isFinished does not require?
I spotted this too when I opened your experiment - it’s a different, unrelated bug. I’ve just done a fix for it (it’s a simple error so has a simple solution) - essentially it’s that endExpNow isn’t defined initially unless “end experiment with escape” is ticked in Experiment Settings. To fix it either enable the escape button in your Experiment Settings or add endExpNow = False to the Begin Experiment tab of a Code component.
I think your issue is unrelated, but is one I’ve come across before. Try setting the start time of the audio to something like 0.25 sec instead of 0. That seems to resolve the issue whenever it crops up for me.