psychopy.org | Reference | Downloads | Github

Sounds stop playing after 2/3 stimuli when running the experiment several times

OS (e.g. Win10): Windows 10
PsychoPy version (e.g. 1.84.x): 1.90.2
Standard Standalone? (y/n) If not then what?: Yes

What are you trying to achieve?:
I am trying to run a loop that plays sound stimuli for a perception task.

What did you try to make it work?:
Tried restarting PC and it often works for the first or second run. But, the problem comes back in the next runs.

What specifically went wrong when you tried that?:
The program works fine the first time I run it. But, when I run it a second or third time, the sounds stop playing after 2/3 stimuli. The loop still works fine (keeps displaying the accompanying texts for the number of repetitions in the loop); just the sounds don’t play.

HERE’S THE ERROR MESSAGE:

From cffi callback <function callback_ptr at 0x1E913370>:
Traceback (most recent call last):
File “C:\Program Files (x86)\PsychoPy2\lib\site-packages\sounddevice.py”, line 1008, in callback_ptr
return _wrap_callback(callback, data, frames, time, status)
File “C:\Program Files (x86)\PsychoPy2\lib\site-packages\sounddevice.py”, line 2773, in _wrap_callback
callback(*args)
File “C:\Program Files (x86)\PsychoPy2\lib\site-packages\psychopy\sound\backend_sounddevice.py”, line 199, in callback
self.sounds.remove(thisSound)
ValueError: list.remove(x): x not in list

Just to let you know that I am encountering exactly the same issue…

Having the exact same issue. Using version 1.90.2 Windows 10. Any fix suggestions greatly appreciated.

Found the solution in an older thread on this site.
Go to
C:\Program Files (x86)\PsychoPy2\lib\site-packages\psychopy\sound\backend_sounddevice.py
then go to line 199
change text from
self.sounds.remove(thisSound)
to
self.remove(thisSound)
Fixed my problem.
Here is the link to the original thread.

It solved my problem too! Tons of thanks! :slightly_smiling_face:

Same deal (stops plague), but my version already has “self.remove(thisSound)”, albeit on line 207. I’m using Psychopy versions 3.04.

If I generate a tone, it plays only once and refuses to play again (no error messages).

ballSound = Sound(value='A', secs=0.1136, octave=4, stereo=-1, volume=1.0, loops=0, sampleRate=44100, blockSize=128, preBuffer=-1, hamming=True, startTime=0, stopTime=-1, name='', autoLog=True)

If I use a .wav, I can get the sound to work up to 8-9 times before it refuses to play again. I do get error messages with .wav files

code:

ballSound = Sound("eeg_knock1.wav")

error message:

From cffi callback <function _StreamBase.__init__.<locals>.callback_ptr at 0x132b525510>:
Traceback (most recent call last):
  File "/anaconda3/lib/python3.7/site-packages/sounddevice.py", line 741, in callback_ptr
    return _wrap_callback(callback, data, frames, time, status)
  File "/anaconda3/lib/python3.7/site-packages/sounddevice.py", line 2517, in _wrap_callback
    callback(*args)
  File "/anaconda3/lib/python3.7/site-packages/psychopy/sound/backend_sounddevice.py", line 195, in callback
    dat *= thisSound.volume  # Set the volume block by block
TypeError: unsupported operand type(s) for *=: 'NoneType' and 'float'

​Hi Matt,

Try to uninstall and reinstall your Psychopy version.

Then make sure to select the correct version to run your experiment.

Best

What is the correct version?

BTW: I’m teaching a class at the moment, using Mac and PC, and they all are having problems:

3.0.2, 3.0.4, 3.0.5 OSX
3.0.6 PY3_PY2, 3.0.6py3, 3.0.5 Windows

This is my traceback error using 3.0.6 PY3

Traceback (most recent call last):
  File "C:\Program Files (x86)\PsychoPy3\lib\site-packages\sounddevice.py", line 740, in callback_ptr
    return _wrap_callback(callback, data, frames, time, status)
  File "C:\Program Files (x86)\PsychoPy3\lib\site-packages\sounddevice.py", line 2516, in _wrap_callback
    callback(*args)
  File "C:\Program Files (x86)\PsychoPy3\lib\site-packages\psychopy\sound\backend_sounddevice.py", line 194, in callback
    dat *= thisSound.volume  # Set the volume block by block
TypeError: unsupported operand type(s) for *=: 'NoneType' and 'float'

​The 3.04 is stable.

You must read the file names.

The beta files of any version are not stable.

Those are the test versions.

You must read and take your time and download the same stable version of the files on each of your machines.

Best wishes.

I was seeing similar errors on OSX and Windows. It is as if the sound object is deleted after some variable number of plays, which is why you get the ‘NoneType’ error.

As you can see, several of the students, on OSX and Windows, are using PsychoPy visions >= 3.04, yet have problems with sounds disappearing.

Go to preference -> hardware. Change the order as [“pyo”,“pygame”,“soundlib”,]
Does it work?

1 Like

I’m running into this problem, too. I’m using a Macbook Pro from 2018 running 10.13.6, running standalone PsychoPy 3.1.5 using the sounddevice library in coder view. I get the same behavior (program continues, but sound suddenly stops) and error

From cffi callback <function _StreamBase.__init__.<locals>.callback_ptr at 0x135c64048>:
Traceback (most recent call last):
  File "sounddevice.pyc", line 733, in callback_ptr
  File "sounddevice.pyc", line 2508, in _wrap_callback
  File "/Applications/PsychoPy3.app/Contents/Resources/lib/python3.6/psychopy/sound/backend_sounddevice.py", line 201, in callback
    dat *= thisSound.volume  # Set the volume block by block
TypeError: unsupported operand type(s) for *=: 'NoneType' and 'float'

I have the same behavior when using pyo as the audioLib.