psychopy.org | Reference | Downloads | Github

Problems with audio libraries pyo and pygame (and bluetooth speakers)

Hi,

this is my first post here but the problem is bit complex but I try to be as short as possible:

Short story: My experiment includes audio and visual stimuli. Each trial an audio warning is given and a visual stimulus is displayed. Additionally I play a sound every 3.33 secs which is independant from the trials and realized with a python code component. Everything went well until we tried to play the sound via bluetooth speakers, at least on the pc in the lab. On my working-pc everything still works perfectly.

Problem description:
On the lab-pc, as soon the first sound file should be played during the experiment, the sound of the whole computer brakes down and no sound can be heard anymore. More precisely: If I open a browser and play a music video on youtube and then start my psypy experiment, the moment the first sound in the experiment should be played, all sound from the computer shuts off and nothing can be heard anymore. In the windows sound control panel you can see that sound is played from youtube but you can’t hear it anymore. But the thing to notice is that all this is only happening when I use bluetooth speakers. This problem does not occur when using USB-speakers or normal 3,5mm klinke speakers. But to make it even more confusing: This only happens on the lab-pc. The same all works fine on my working-pc.

Both computers, my working-pc and the lab-pc, have similar OS and PsychoPy version:
OS: Windows 10
PsychoPy version : v1.83.04
They differ in CPU, Mainboard, GPU etc.

The bluetooth speakers work fine. They work perfectly on the lab-pc with everything other than Psychopy. On my working pc they even work with Psychopy. So I don’t think the source of the problem is bluetooth or the bluetooth speakers.

What I tried to fix it:
I changed the audio library in the PsychoPy preferences: When I use only ‘pygame’ as audio library the sound works with the bluetooth speakers, even on the lab-pc, BUT now my experiment doesn’t work properly anymore! Some of the stimuli are not appearing anymore - it seems the trial loop is broken. This is the same on both computers.
If I use only ‘pyo’ as audio library, I get the sound issues on the lab-pc (it’s fine on the working-pc) but the experiment flow works fine.

I suppose the lab-pc has a problem with ‘pyo’ but why is it only occurring with the bluetooth speakers. And why does my other pc not have this problem? I am clueless here.

I hope the problems are understandable and someone has an idea how to fix it?
Thanks!

My best guess here is that you will need to specify for pyo is playing the sound to a differnet device than the bluetooth speakers.

Could you go to the shell panel in psychopy coder and do:

import pyo
print pyo.pa_get_output_devices()
print pyo.pa_get_default_output()

and paste the output from each command (you can select and right-click to copy)

Thanks for your answer,

on the lab-pc I get the following:

print pyo.pa_get_output_devices()
(['Microsoft Soundmapper - Output', 'Kopfhörer (Creative MUVO 2 Ster', 'Kopfhörer (Creative MUVO 2 Hand', 'Primärer Soundtreiber', 'Kopfhörer (Creative MUVO 2 Stereo)', 'Kopfhörer (Creative MUVO 2 Hands-Free)'], [2, 3, 4, 7, 8, 9])
print pyo.pa_get_default_output()
3

=> This does not work (no sound).

What I noticed is, that the output of these prints does not change if I change the speaker setup in windows. I think it does not update. I stays the same values as when PsychoPy was started.

If I disconnect the bluetooth speakers and instead connect some USB-Speakers, the output is the following (after restarting Psychopy):

print pyo.pa_get_output_devices()
(['Microsoft Soundmapper - Output', 'Lautsprecher (2- USB  AUDIO  )', 'Primärer Soundtreiber', 'Lautsprecher (2- USB  AUDIO  )'], [0, 1, 2, 3])
print pyo.pa_get_default_output()
1

=> This works fine (I have sound)

On my working-pc I connected the same bluetooth speakers and I get the following:

print pyo.pa_get_output_devices()
(['Microsoft Soundmapper - Output', 'Kopfhörer (Creative MUVO 2 Ster', 'Kopfhörer (Creative MUVO 2 Hand', 'Lautsprecher (Realtek High Defi', 'Primärer Soundtreiber', 'Kopfhörer (Creative MUVO 2 Stereo)', 'Kopfhörer (Creative MUVO 2 Hands-Free)', 'Lautsprecher (Realtek High Definition Audio)'], [3, 4, 5, 6, 10, 11, 12, 13])
print pyo.pa_get_default_output()
4

=> this also works fine and I have sound

The “Creative MUVO 2” is the Bluetooth Speaker btw. and it connects with two deviced, one is named “stereo” and the other “hands free” in windows.

I hope you can see a fault here because I don’t :slight_smile:

Cheers