Noise during sound presentation with sample
If you fill out the information below, we will be able to help you better. 😎 You can also consider asking SigmundAI.eu, our AI assistant with expert knowledge of OpenSesame.
OpenSesame version: 4.0
Operating system: Windows 10
Backend: PsychoPy
Expected behavior
I am running an experiment with two tasks, one is a memory task and one a sound localisation task. During the memory task I present auditory stimuli using inline code. In the sound localization task I use a sampler to present the same sounds. The sounds should be played one at a time and without noise - just what is in the file. Both tasks are shown alternately several times.
Actual behavior (what goes wrong)
All worked perfectly for the first 6 sessions and since than I have not changed anything in the experiment. However, in todays session there was an issue with the sound presentation from the sampler. There was from time to time (sadly quite frequently) some noise in the sound... like a buzz. It almost sounded like the sound was presented twice and overlayed a little. Based on the audiorecording in the MEG data it also looked like the sound was displayed longer than it should have been (the length is identical to the length of the sound file).
Error messages (if any): NA
What did you try already?
Together with the MEG lab manager we tried out different sound systems to see if it was a hardware issue. The noise remained independet of the used hardware. Next we tried to play around with the volume, but that did not work either. Since the issue only arose in the sound localization task and both tasks use the same audiofile it cannot be due to a faulty audiofile, right? Also the very first sounds in the experiment are presented to adjust the volume to the participants liking and they are also presented with the sampler and they are never noisy. So it cannot also not be due to the interaction of the sound files and the sampler, right?
The only thing that worked was rebooting the PC. However, this only worked for the first time running the experiment. The second time the noise was back there. Is there a chance that opensesame fills some buffers that effect the sampler and which are not emptied once opensesame is closed again?
Experiment file (optional)
Consider attaching attaching your .osexp file. If you do not want to share your experiment file, you can also attach a minimal version of the experiment that illustrates the issue.
Comments
Hi @Maroes
Thank you for the detailed report. However, I'm not sure what's causing this without looking at your experiment file directly; I'll ask SigmundAI, our Opensesame AI expert and copy paste its answer below so that you can try its suggestions.
Let us know how it goes,
Claire
-----
Sigmund: You've done some excellent troubleshooting already! The issue you’re describing—where audio plays with extra noise or sounds "doubled", and the noise persists across hardware but is resolved after a system reboot (but only for one run)—almost always points to audio driver, buffer, or backend issues rather than a problem with your sound files or script logic.
Here’s a targeted checklist and advice for OpenSesame & PsychoPy backend:
1. Buffer/Caching Issues
sampler
and Python-based audio code may use different libraries (e.g.,sounddevice
,pygame
, or even system devices directly).2. Mixing Different Audio Engines
sounddevice
orpygame
) and sampler for localization task. Combining multiple libraries (even if all via PsychoPy) can cause conflicts, especially if the underlying hardware is locked by one method and not properly released before use in another.3. “First run after reboot” works, then fails
4. Other considerations
Recommendations
A. Single Backend Consistency
sd.stop()
or.close()
after each sound.sounddevice
orpygame
, avoid mixing with Sampler within a single session.B. Tidy Up Between Tasks
clock.sleep(100)
ms) before and after blocks that use different sound methods. This sometimes resets audio interfaces.C. Update and Test Backends
sounddevice
topyo
, or vice versa).D. Audio File Check
E. System and Driver Notes
Further Steps
If this checklist doesn't resolve the issue, a minimal example experiment (upload a .osexp to OSF or similar) and system info (OpenSesame/PsychoPy/sound device versions, audio backend used) will help the developers replicate and fix the bug.
Summary Table
| Problem | Solution | |--------------------------|---------------------------------------------------------| | Stale Audio Buffers | Stick to one backend, explicitly stop/release audio | | Mixed Sound Engines | Use only Sampler or only inline sound per session | | Sample Rate Mismatches | Convert all files to same sample rate/format | | Unstable Drivers | Test driver rollbacks, use official/updated drivers | | Software Bug | Update OS/psychopy/os, report w/ minimal example |
Let me know if you want step-by-step instructions for any of the above, or have a small .osexp for review!
Check out SigmundAI.eu for our OpenSesame AI assistant! 🤖