OS (e.g. Win10): Win10
PsychoPy version (e.g. 1.84.x): 2023.1.3
Standard Standalone? (y/n): y
What are you trying to achieve?: I have an experiment (well, many experiments!) that involve(s) a loop where different sound files play. The sound files are selected at random from a stimulus list on each loop. The experiments have all worked well in previous versions of PsychoPy. Initially after upgrading, no sound files worked; however, after installing the fix described here, the experiment does not immediately break.
What did I try and what specifically went wrong when you tried that?:
On loops that involve Sound components, the sound that’s in the component plays exactly once and never plays again. Note that there is never an error message associated with this bug. The experiment seems to think that it’s being run just fine and the other components in the Routine (and other Routines) work without a hitch. I just hear exactly one sound (not even every sound that’s listed in the loop) and no others.
I’ve tried a few things:
-
Inspecting the data: when I look through the data files that are generated, there is only one “sound_1.started” (or whatever the name of the Routine is) generated in the first row. After that, “sound_1.started” is blank. So the sound itself is only started once; after that, no start is listed. (Investigating the log also shows “Sound sound_1 reached end of file”.)
-
Running a different experiment with a similar design: This error only seems to haunt one of my experiments. Other experiments (which use the same looping architecture) seem to work just fine.
-
Creating a simplified version of the study where I can replicate the issue (a version completely from scratch): I get the same bug as the original; the sound plays exactly once and does not repeat.
-
Switching the sound file from “set every repeat” to “constant”: this does not improve the issue. The sounds play once and then do not play again.
One of the few differences I observe between the studies that do work and the studies that don’t is how the audio libraries are encoded in the experiment.
In an experiment that does work, the “Audio library” and “Audio latency priority” settings in the experiment prefs are both “use prefs”. In an experiment that does not work (including the simplified version above and the original study that is now defective), the local experiment prefs for audio library are listed as “ptb” with audio latency priority “3: Aggressive low-latency”. My global prefs are currently set up with the following list: “PTB, pyo, sounddevice, pygame”. Changing the experiment’s audio library to pyo, sounddevice, or pygame breaks the experiment (pyo and sounddevice are not available, pygame is missing an “isFinished” component). Changing the experiment’s audio latency to 2 or 4 doesn’t change the error, while 0 and 1 also bring up an error.
tl;dr: The Sound component doesn’t work more than once per participant because it doesn’t seem to start the sound after the first time the component is encountered in the loop. I can replicate the bug when I program a new experiment from scratch but not when I open other experiments that had been previously programmed.