# Changing audioLib with prefs does not work

**URL:** <https://discourse.psychopy.org/t/changing-audiolib-with-prefs-does-not-work/6220>\
**Category:** Coding\
**Tags:** sound\
**Created:** [January 8, 2019, 9:44am UTC](https://discourse.psychopy.org/t/changing-audiolib-with-prefs-does-not-work/6220 "2019-01-08T09:44:40Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![LukasPsy](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/lukaspsy/32/4582_2.png) [@LukasPsy](https://discourse.psychopy.org/u/LukasPsy)\
**Post date:** [January 8, 2019, 9:44am UTC](https://discourse.psychopy.org/t/changing-audiolib-with-prefs-does-not-work/6220/1 "2019-01-08T09:44:40Z")

</div>

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!

```auto
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:

```auto
>>> sounddevice

```

---

<div class="post-metadata">

**Author:** ![alepebel](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/alepebel/32/33931_2.png) [@alepebel](https://discourse.psychopy.org/u/alepebel)\
**Post date:** [January 9, 2019, 10:57am UTC](https://discourse.psychopy.org/t/changing-audiolib-with-prefs-does-not-work/6220/2 "2019-01-09T10:57:27Z")

</div>

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](https://discourse.psychopy.org/t/sounddevice-and-sound-presentation/6181)

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

---

<div class="post-metadata">

**Author:** ![LukasPsy](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/lukaspsy/32/4582_2.png) [@LukasPsy](https://discourse.psychopy.org/u/LukasPsy)\
**Post date:** [January 9, 2019, 11:12am UTC](https://discourse.psychopy.org/t/changing-audiolib-with-prefs-does-not-work/6220/3 "2019-01-09T11:12:24Z")

</div>

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:

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

```

---

<div class="post-metadata">

**Author:** ![alepebel](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/alepebel/32/33931_2.png) [@alepebel](https://discourse.psychopy.org/u/alepebel)\
**Post date:** [January 9, 2019, 11:29am UTC](https://discourse.psychopy.org/t/changing-audiolib-with-prefs-does-not-work/6220/4 "2019-01-09T11:29:59Z")

</div>

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

good luck

---

<div class="post-metadata">

**Author:** ![LukasPsy](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/lukaspsy/32/4582_2.png) [@LukasPsy](https://discourse.psychopy.org/u/LukasPsy)\
**Post date:** [January 9, 2019, 11:53am UTC](https://discourse.psychopy.org/t/changing-audiolib-with-prefs-does-not-work/6220/5 "2019-01-09T11:53:32Z")

</div>

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. 😁

---

<div class="post-metadata">

**Author:** ![LukasPsy](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/lukaspsy/32/4582_2.png) [@LukasPsy](https://discourse.psychopy.org/u/LukasPsy)\
**Post date:** [January 13, 2019, 2:44pm UTC](https://discourse.psychopy.org/t/changing-audiolib-with-prefs-does-not-work/6220/6 "2019-01-13T14:44:30Z")

</div>

I found the solution to my problem:

> [@Setting prefs.general\['audioLib'\] to pyo doesn't work](https://discourse.psychopy.org/t/setting-prefs-general-audiolib-to-pyo-doesnt-work/6288):
>
> 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…
