Sound timing question

If this template helps then use it. If not then just delete and start from scratch.

OS (e.g. Win10): OS X 10.14.6
PsychoPy version (e.g. 1.84.x): 3.1.5

My question is about how to best time sounds in Builder. Having read the documentation, I thought I would use the PTB sound device, but I can see that this is not listed in the preferences.
So I added it there, and that throws an error

ValueError: audioLib pref should be one of [‘sounddevice’, ‘pyo’, ‘pysoundcard’, ‘pygame’], not ‘PTB’

I also tried to set this in a custom code component at the start of the experiment:
prefs.hardware[‘audioLib’] = [‘PTB’]
from psychopy import sound

That does NOT throw an error, but when I then use the code adapted from the documentation

sound_2.play(when = now+interval)

I get the following error:

TypeError: play() got an unexpected keyword argument ‘when’

Some more research revealed that this is probably because sound device is
<class ‘psychopy.sound.backend_sounddevice.SoundDeviceSound’>

Any tips on how to ensure decent sound timing, esp. when loading sound from files & using builder?
THanks
Marc

What specifically went wrong when you tried that?:
Include pasted full error message if possible. “That didn’t work” is not enough information.

Hi @Marc_Buehner, yes to get the best accuracy and precision, use the PTB library. In case you have not seen it yet, we have a preprint available to demonstrate what you can achieve with PsychoPys new PTB audio engine [see The timing mega-study (2020)].

However, to use PTB you need to have a 64bit Python 3 - see docs.