Repeated sound plays inconsistently after a few minutes

URL of experiment: audiotest [PsychoPy]

Description of the problem:
In my experiment I have 120 trials, each trial consists of sequences of 5 to 12 rectangles and beeps (generated using builder’s polygon and sound components). The trials advance by the participant indicating whether or not the beep sequence matches the rectangle sequence by pressing Y or N. What I have noticed is that for approximately the first 60-70 trials everything works just fine, however, after that Pavlovia starts skipping beeps and playing them inconsistently. The problem doesn’t happen in PsychoPy. To make sure this is not due to a bug in my code, I created a simplified audio test using PsychoPy by putting two sound components (440 Hz and 550 Hz) in a virtually infinite loop and ran it in Pavlovia (link attached above). This is what my audio test experiment looks like in PsychoPy:

A similar problem occured. Pavlovia played the beeps just fine for the first 3-4 minutes, and then suddenly started skipping beeps. Again, this problem does not happen locally on PsychoPy and is unique to Pavlovia – no matter which browser I use and whether or not I use headphones. I even tried playing the sounds using audio files with different formats (mp3, wav, etc.) instead of using PsychoPy generated sounds, but that also didn’t work as Pavlovia failed to start and stop the sounds in a timely manner and all the sounds started mixing together after a few trials.

I found someone else reporting a similar problem on GitHub with no existing solution: repeated playing of sound eventually causes crash · Issue #436 · psychopy/psychojs · GitHub

I would really appreciate any suggestions on how to tackle this issue.

Hi @pavlov,

I tried out your URL and I experience the sound issue as described.

Is it important that sound_1 is set every repeat? I recreated your minimal example in PsychoPy 2022.2.1, but if I set both sound_1 and sound_2 to constant then I no longer experience the sound issue.

If you don’t need to change the sound every trial, maybe see if setting the sounds to constant solves the problem.

Also, what version of PsychoPy are you using?


Hi @shabkr,

Thank you so much for your response. You are absolutely right, the problem only occurs when the sound and volume are set to “set every repeat”. Unfortunately, my actual experiment relies on the sound and volume being reset on every trial, so I cannot work around that.

Since I posted here, I have updated my PsychoPy to the latest version (2022.2.3), and created an even simpler audio test consisting of only one audio stimulus (set to every repeat) in a virtually infinite loop. Here’s the Pavlovia link.
The audio completely goes out without an error after about a minute. I have tried different start times and sound durations, but the problem persists in all variations. It looks like the problem only comes down to “set to every repeat”, which my experiment absolutely relies on.

Any suggestions will be extremely appreciated!
Thank you so much for your time.

Hi @pavlov, have you tried this on different machines? Running your latest example, I noticed some inconsistencies and glitches after a while, but the sound definitely did not turn off after a minute. Also when I checked my mail while the example ran in the background it started to glitch a lot more. Maybe that means that it is some kind of performance issue?

Hi @ajus,

Can I ask which browser you used? The program runs differently on different machines and browsers. Although some are better than others, in my experience they have all been faulty. In my case, Safari has been the best browser. While the beeps completely stop playing on Chrome after around 380 trials, they only start glitching on Safari around the 900th trial (similar to what you mentioned). In my actual experiment, due to the added complexity, the sound starts glitching (and eventually stopping) even sooner.

However, since Safari is limited to macOS and is unaccessible by some participants, unfortunately its advantages over Chrome aren’t really useful to me. I will need to resolve the issue on Chrome.

Thank you so much for your response.

I used Firefox.

Hi @pavlov,

I tested a few different sound settings and didn’t see any improvement, however when I used pre-generated sounds I didn’t experience any stuttering or glitching when set to repeat. If you use pre-generated sounds, do you still run into the same issue? There are a variety of websites and programs that will let you generate single pure tones that you are using.