Audio library not appearing in Preferences (Mac)

Hello! My experiment is not running because I need to change what I have set up in my audio library in the Psychopy hardware. However, that topic is not even showing up in my preferences.


All I have showing up is audio driver, audio device, parallel ports, and Qmix configuration. Does anyone know how to obtain audio library?

For reference, my Mac is macOS Monterey version 12.6.5, and my Psychopy is v2023.1.2.

I am a beginner at Psychopy, so any help would be greatly appreciated! Thanks!

Hello, could you possibly share the error message you get? (it will be in the “runner” view)

Thanks,
Becca

I’m actually having the same problem with 2023.1.2, but on a windows PC (Windows 10). I don’t have the audio library showing up in my preferences (but it does in the .cfg file). Error message is below.

##### Running: C:\Users\SPPLab\Desktop\Shiloh_Sleep\Sleep_Test_lastrun.py ######
1792.3294     INFO     Loaded monitor calibration from ['2019_07_26 14:43']
2.6098     ERROR     Support for the `sounddevice` audio backend is not available this session. Please install `psychopy-sounddevice` and restart the session to enable support.
Traceback (most recent call last):
  File "C:\Users\SPPLab\Desktop\Shiloh_Sleep\Sleep_Test_lastrun.py", line 21, in <module>
    from psychopy import sound, gui, visual, core, data, event, logging, clock, colors, layout
  File "C:\Users\SPPLab\AppData\Local\Programs\PsychoPy\lib\site-packages\psychopy\sound\__init__.py", line 135, in <module>
    raise DependencyError(
psychopy.exceptions.DependencyError: No sound libs could be loaded. Tried: ['sounddevice']
Check whether the necessary sound libs are installed
################# Experiment ended with exit code 1 [pid:8292] #################

Sounddevice was removed in the 2023 version. You might want to re-install 2022.2.5, use the settings window there to change the audio lib to PTB or something else that works, then reinstall 2023. That will at least resolve the immediate error. Or you could just go back to 2022.2.5 and keep using sounddevice.

Thanks! Any idea why the audio library preferences aren’t showing up in the GUI, even though they’re in the .cfg file?

Can’t help you there. Sounds like a bug. @jon might know more

There are two issues at play here.

  1. our recommendation is that you use PTB as the sound backend unless you have a specific reason that it doesn’t work in your case (let us know if you have a bug with that). PTB has considerably superior timing performance compared to all the other options

  2. In v2023.1 we added a plugin architecture so that we could more easily phase out parts of the lib that aren’t (or should be) widely used and b) so that we can add new functionality/hardware that only some people need without overloading the options for everyone. Sounddevice as a sound backend is now available as a plugin from the >Tools>Plugins menu item. But honestly, use PTB instead, which is now the only sound engine that we provide prepackaged

Great, thank you!

I can start a separate thread about this but I’ve been hearing from a lot of people on Windows running into issues with PTB when loading movie files with audio. In particular, the ManyBabies4 PyHab experiment, several (but strangely not all) Windows users get errors where it fails while trying to play the movie for the first time. I think there are still some issues with the PTB backend that I don’t fully grasp but I’d encourage leaving some alternatives in the base version just in case.

Installing the plugins is really very easy. I don’t think we’ll revert to adding sounddevice back in to the core. If there are issues with PTB then we really want to know about those so they can be fixed.

Using psychopy standalone v2023.2.0 on a windows 10

  • when trying to install the plugin for the sounddevice it is collecting incompatible version of numpy (1.24.4) with what this version of psychopy needs (<1.24.0)

    • Also after unsuccessful install the software thinks it is installed since if I try to install the plugin again it says it is installed and no option for uninstall.
  • when trying the PTB backend I get the following error for following minimal script:

Script

import psychtoolbox as ptb
from psychopy import sound

mySound = sound.Sound('assets/audio/sound.wav')
now = ptb.GetSecs()
mySound.play(when=now+0.5)  # play in EXACTLY 0.5s

Error

########### Running: C:\Users\shafieim\codes\seal\npad\task\test.py ############
PTB-ERROR: Desired audio parameters for device -1 unsupported by audio device: Invalid sample rate 
Traceback (most recent call last):
PTB-ERROR: Seems the requested audio sample rate 22050.000000 Hz is not supported by this combo of hardware and sound driver.
Error in function Open:     Usage error
Failed to open PortAudio audio device due to unsupported combination of audio parameters.
PsychPortAudio:Open: Usage:

pahandle = PsychPortAudio('Open' [, deviceid][, mode][, reqlatencyclass][, freq][, channels][, buffersize][, suggestedLatency][, selectchannels][, specialFlags=0]);
PTB-ERROR: Desired audio parameters for device -1 unsupported by audio device: Invalid sample rate 
PTB-ERROR: Seems the requested audio sample rate 22050.000000 Hz is not supported by this combo of hardware and sound driver.
Error in function Open:     Usage error
Failed to open PortAudio audio device due to unsupported combination of audio parameters.
PsychPortAudio:Open: Usage:

pahandle = PsychPortAudio('Open' [, deviceid][, mode][, reqlatencyclass][, freq][, channels][, buffersize][, suggestedLatency][, selectchannels][, specialFlags=0]);
0.9626     ERROR     Support for the `sounddevice` audio backend is not available this session. Please install `psychopy-sounddevice` and restart the session to enable support.
  File "C:\Program Files\PsychoPy\lib\site-packages\psychopy\sound\backend_ptb.py", line 227, in __init__
    audio.Stream.__init__(self, device_id=deviceID, mode=mode+8,
  File "C:\Program Files\PsychoPy\lib\site-packages\psychtoolbox\audio.py", line 97, in __init__
    self.handle = PsychPortAudio('Open', device_id, mode,
Exception: Failed to open PortAudio audio device due to unsupported combination of audio parameters.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\[...]\task\test.py", line 4, in <module>
    mySound = sound.Sound('assets/audio/sound.wav')
  File "C:\Program Files\PsychoPy\lib\site-packages\psychopy\sound\backend_ptb.py", line 332, in __init__
    self.setSound(value, secs=self.secs, octave=self.octave,
  File "C:\Program Files\PsychoPy\lib\site-packages\psychopy\sound\backend_ptb.py", line 440, in setSound
    _SoundBase.setSound(self, value, secs, octave, hamming, log)
  File "C:\Program Files\PsychoPy\lib\site-packages\psychopy\sound\_base.py", line 185, in setSound
    self._setSndFromFile(p)
  File "C:\Program Files\PsychoPy\lib\site-packages\psychopy\sound\backend_ptb.py", line 476, in _setSndFromFile
    self._setSndFromArray(sndArr)
  File "C:\Program Files\PsychoPy\lib\site-packages\psychopy\sound\backend_ptb.py", line 515, in _setSndFromArray
    self.track = audio.Slave(self.stream.handle, data=self.sndArr,
  File "C:\Program Files\PsychoPy\lib\site-packages\psychopy\sound\backend_ptb.py", line 621, in stream
    label, s = streams.getStream(sampleRate=self.sampleRate,
  File "C:\Program Files\PsychoPy\lib\site-packages\psychopy\sound\backend_ptb.py", line 140, in getStream
    return self._getStream(sampleRate,
  File "C:\Program Files\PsychoPy\lib\site-packages\psychopy\sound\backend_ptb.py", line 187, in _getStream
    self[label] = _MasterStream(sampleRate, channels, blockSize,
  File "C:\Program Files\PsychoPy\lib\site-packages\psychopy\sound\backend_ptb.py", line 248, in __init__
    audio.Stream.__init__(self, mode=mode+8,
  File "C:\Program Files\PsychoPy\lib\site-packages\psychtoolbox\audio.py", line 97, in __init__
    self.handle = PsychPortAudio('Open', device_id, mode,
Exception: Failed to open PortAudio audio device due to unsupported combination of audio parameters.
Exception ignored in: <function Stream.__del__ at 0x0000022DD3A1EEE0>
Traceback (most recent call last):
  File "C:\Program Files\PsychoPy\lib\site-packages\psychtoolbox\audio.py", line 236, in __del__
    self.close()
  File "C:\Program Files\PsychoPy\lib\site-packages\psychtoolbox\audio.py", line 146, in close
    raise err
  File "C:\Program Files\PsychoPy\lib\site-packages\psychtoolbox\audio.py", line 139, in close
    PsychPortAudio('Close', self.handle)
AttributeError: '_MasterStream' object has no attribute 'handle'

Any tips?
Thanks

I also tried following script and I get following error:

Script

from psychopy import sound

print('Using %s (with %s) for sounds' % (sound.audioLib, sound.audioDriver))
mySound = sound.Sound('A')
mySound.play() 

Error

########### Running: C:\Users\[....]\task\test.py ############
Using ptb (with ['Primary Sound', 'ASIO', 'Audigy']) for sounds
0.9306     ERROR     Support for the `sounddevice` audio backend is not available this session. Please install `psychopy-sounddevice` and restart the session to enable support.
################# Experiment ended with exit code 0 [pid:1624] #################

Regarding the original post query, the audiolib setting is still available but it’s now in the Experiment Settings rather than the overall PsychoPy Preferences because when people do need to change it they want to change it per-experiment. That also means that when they take their study to a new machine the preferences of that machine don’t alter the performance of the study (e.g. if it was created using low-latency PTB and then taken to a machine that has been configured to use sounddevice)

My above response about installing plugins also stands - you need the appropriate plugin for some of the sound drivers - but I had forgotten the more basic issue that the preference had necessarily moved location