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
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.
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'
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'
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.
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'