Changing audioLib with prefs does not work

Hello everyone,

I’m using Standalone Psychopy 3.0 on Win10.

With the last beta releases of Psychopy3, I was able to play the same sound object several times with the code below. Now that I’ve downloaded the official release of Psychopy 3.0, setting audioLib preferences to pyo does not work. The audioLib stays sounddevice and sounddevice does not allow playing the same sound object more than once.

Thank you for your help!

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

from psychopy import sound, core

mysound = sound.Sound()
mysound.play()
core.wait(2)
mysound.play() # no sound is played

The output:

>>> sounddevice

I would say that you are not successfully changing to “pyo” and you are still using the sounddevice audiolib. With this library you are encoutering the same problem as I do, reported here -> Sounddevice and sound presentation

My solution to change the preferences is the following:

Restart python kernel.

import psychopy
psychopy.prefs.general[‘audioLib’] = [‘pygame’] # or any other Audiolib. (I dont have pyo) installed in my system)
from psychopy import sound
standard = sound.Sound(630, sampleRate=44100, secs=0.5, stereo=True )
standard # you can verify that the audiolib has changed

standard.play() # play the tone as many times as need it (at least this works in pygame, I havent tested this in pyo and it does not work with the sounddevice)

Hope this helped.

alex

Thank you for your answer, but I cannot change the prefs to pygame either. If I run your code, the audioLib remains sounddevice. (Plus, I don’t want to use pygame instead of pyo because latencies are important in my experiment.)

Pyo is definately installed, because if I can import pyo:

import pyo
>>> pyo version 0.9.0 (uses single precision)

Have you restarted the python kernel before applying the preference changes?

good luck

I’m using the stanalone version of Psychopy. How do I restart the kernel there?
If it is simply done by closing and reopening Psychopy, then yes, I did. :grin:

I found the solution to my problem: