OS (e.g. Win10): Windows 11
PsychoPy version (e.g. 1.84.x): 2023.2.3
Standard Standalone? (y/n) If not then what?: Installed via terminal
What are you trying to achieve?:
I’m trying to connect external speakers to play the sounds and videos that are in the Psychopy Experiment with an aggressive latency priority.
The Problem:
Whenever I connect headphones or a speaker through the audiojack (I tried different audiojacks too) of the desktop computer (1) the sounds (made in the Builder; a simple “A” tone) get distorted and (2) the video playback is sped up like crazy with no sound.
My Hypothesis:
The issue has something to do with the sample rate. When psychopy uses the external audio device it tries to force a sample rate that doesn’t match the stimuli and so it causes a distortion on the audio and forces a sped up playback on the video.
What Doesn’t Work:
My attempts at fixing are all over the place.
- Tried to set a fixed sample rate but that didn’t work
- Tried to install asio4all, but windows won’t recognize it, so that’s useless
- Tried different audio libraries, pyo, etc, but that didn’t work
- Tried changing the sampling rate on the windows sound properties (I tried a bunch)
- Tried changing the latency priority mode, none of them work, except one of them (see “What Works” section)
- Tried different audio devices (headphones, an external speaker, etc).
- Tried using different audiojack inputs on the desktop
- Tried using different audio cables
What Works:
Switching the latency priority to mode 1: “Share low-latency driver” is the only thing that worked. However, I want to ensure there is no latency and the recommended mode is mode 3. I want to avoid latency because I’m running an EEG experiment.
What Confuses Me:
What drives me crazy is that if I use bluetooth headphones (that can also be manually connected with a cable to an audiojack) or the screen monitor for as the ‘sound device’ there’s no issue! I can’t use the bluetooth headphones for the experiment since I’m using EEG (and there’s a small lag anyways, but no distortion).
The fact that this works… confuses me because if it is a sampling rate problem, then why does the bluetooth work? If Psychopy is making the “A” tone at 44.1khz and the audio in my videos is 48khz, why does that work in bluetooth / screen monitor speakers, but not when the bluetooth headphone is connected via cable or when an external audio speaker is connected?
NEW INFO:
If I disable the sound component on all my sound stimuli the video playback is fine and has audio.
If I write code to force the sounds to play at 48khz, the sound is distorted and the videoplayback gets sped up again.
Example code that I used to force a specific sample rate (to match that of the video’s audio sample rate).
from psychopy import sound
beep = sound.Sound(440, secs=0.25, sampleRate=48000)
beep.play()
Why does adding a sound cause such an issue?
Anyways, thanks for the help!