Problem presentings sounds with sounddevice

Dear community,

I am using the last stanalone Psychopy version (3.1.0) in a Macbook pro (Mojave 10.14.4).

I am trying to reproduce sounds with sounddevice using the next piece of code:

from psychopy.sound import Sound
low = Sound(600, sampleRate=44100, secs=0.3, stereo=True ,loops=200, hamming=True) 

low.play()

low.play()

I find two problems:

  • The first one and more important, my code only reproduces the sound the first time that I call low.play(). If I want to reproduce the sound two times in a row I need to create again the sound variable (low = Sound(600, sampleRate=44100, secs=0.3, stereo=True ,loops=200, preBuffer=1,hamming=True).

Following previous posts I have tried to fix it by removing “sounds” from self.sounds.remove(thisSound) -> self.remove(thisSound) but it does not make a difference.

I would appreciate very much if someone could help me to solve this because I am bit stucked.

  • My second question relates to the arguments. Although I am expressing that I would like to loop the sound 200 times (just for fun), it is only reproduced once. Thus, I have the impression that the hamming and loop arguments are not being taken into account. Am I doing something wrong?

Thank you very much

You can repeat a sound if you switch from sounddevice to pyo. You can do this via preferences.

prefs.hardware['audioLib']=['pyo']
from psychopy.sound import Sound
# insert your code

Thanks LukasPsy,

then I imagine that the “problem” that I am encountering using sounddevice audiolib is normal in OSX and it is still better to continue working with pyo.

Best

Hi @alepebel and others,

I am wondering if you are able to use:
prefs.hardware[‘audioLib’] = [‘PTB’]
When I use this instead of ‘pyo’ I don’t hear any sound. Further, there is no error also. Can someone give any pointers to debug this. Below is the code segment.

from psychopy import prefs
prefs.hardware[‘audioLib’] = [‘PTB’]
from psychopy.sound import Sound
import psychtoolbox as ptb

low = Sound(600, sampleRate=44100, secs=0.3, stereo=True ,loops=50, hamming=True)
low.play()