Sound component with empty duration won't play after first iteration of loop—changed behavior in 2023.2.0

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.

My best guess as to the reason for the change in 2023.1.3 is that it has to do with the addition of a parameter to control sounds ending when the routine ends.

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: Code component to trial_beep._isFinished = False and then enable it.

Thanks!

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>
    run(
  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: Code component.

Many thanks, @TParsons!

I think my problem might be related (but I’m not totally sure, and I haven’t been able to fix the problem).

My sound files won’t play after the first iteration of the loop, but that’s only a problem when run on Pavlovia. When run locally through PsychoPy, no problem.

I’ve created a very simple experiment to demonstrate this - basically just a loop with a sound file.

I would really truly appreciate any help.

Two_AudioFile_Experiment.psyexp (11.2 KB)
SimpleAudioExperiment.xlsx (8.7 KB)

Hi @yonder-psychling24:

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.

1 Like

That worked! Thanks so much. Made my day.

1 Like

I’ve just checked and this is still true in 2023.2.2 available from Releases · psychopy/psychopy · GitHub. You can test with different start times here:

https://run.pavlovia.org/test-suite/bleep-test/