Setting prefs.general['audioLib'] to pyo doesn't work

Hello everyone,

I’m using stanalone Psychopy v3.0.1. With the last beta releases of Psychopy3, I could change audioLib, but now, changing prefs.general[‘audioLib’] has no impact. I cannot use sounddevice, because timing is important in my experiment. Is this a bug in psychopy.prefs or a mistake in my code?

from psychopy import prefs
prefs.general['audioLib']=['pyo']
from psychopy import sound
sound.audioLib

Output

'sounddevice'

I posted this before, but I didn’t isolate the problem from the rest of my code, so I didn’t get an answer. I apologise if anyone is reading this a second time.

I think I found the solution, although I can’t explain the change from version to version:
The following change to prefs.hardware[‘audioLib’] instead of prefs[‘audioLib’] solves the problem.

from psychopy import prefs
prefs.hardware['audioLib']=['pyo']
from sound import sound
from psychopy import sound
sound.audioLib

Output

'pyo'

Hi LukasPsy,

Thanks for sharing your solution. I am using Psychopy 3.0.7 in Anaconda 2/windows10, and your solution still work… when I execute exactly the same script from command prompt. If I run from ipython, it the audioLib is not changed by these codes.

Erik

i am having the same problem on a windows machine (and only on this machine) with psychopy 1.84 standalone.

did anyone find a solution for psychopy2?
unfortunately in this version prefs has no attribute hardware.

Did you try both the old version and the new version?

  1. Old version
from psychopy import prefs
prefs.general['audioLib']=['pyo']
from psychopy import sound
sound.audioLib
  1. New version
from psychopy import prefs
prefs.hardware['audioLib']=['pyo']
from psychopy import sound
sound.audioLib

Second, are you aware that changing prefs has no effect once you imported audiolib?
And third, are you sure that pyo is installed? What do you get, when you try to import pyo?

import pyo

It should print something like this to your console: “pyo version 0.9.0 (uses single precision)”

thanks for the quick reply @LukasPsy, and sorry for my belated answer!

yes, I did try both old and new version. but I found the cause, a rather simple/stupid one:

for various reasons, I wanted to use pygame not pyo and apparently this is simply not included in the standalone version we have installed on our lab-machines (see Standalone Win32 for v1.84.0 doesn't include pygame)

psychopy’s behavior to default to pyo looked to me as if the pref.general['audioLib'] functionality would not work

1 Like