| Reference | Downloads | Github

Sounds problems

Hey everyone, finally updated to the latest PsychoPy library. Excited about the new low latency sound. After upgrading sounds only play once. This is true for PTB, pyo, sounddevice… What’s happening? :open_mouth:

Minimal example:

import psychtoolbox as ptb
from psychopy import prefs
prefs.general['audioLib'] = 'PTB'
from psychopy import sound, visual, event

mySound = sound.Sound('A', secs=0.1)

win = visual.Window([300,200],color="black", units='pix')

while True:
	if event.getKeys(keyList=['t']):
		print('playing sound')

What happens if you shift the win.flip() to inside the while loop (but outside the if block)?

Did some more digging around. Turns out that the command for setting audioLib that used to work, e.g.,

prefs.general['audioLib'] = ['pyo']

now does not… it needs to be

prefs.hardware['audioLib'] = ['PTB']

So in my example above, the sound was being played via the default sounddevice. When I switch it to PTB, the problem goes away. The problem with the sound only being played once persists, but is limited to sounddevice

Thanks. Doesn’t help though. Seems like a sounddevice issue (see above)