I’m currently building a gambling experiment. At each round, participants bet money using a keypad which I ask them to click with the mouse.
What I would like is for a click sound to play when they press a button. However, I currently have this error.
File "C:\Program Files\PsychoPy3\lib\site-packages\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'
In practice, clicking makes the sound play once but the code inside that statement fails to run (doesn’t update their current bet), I can click to run the sound again, but on the third time the sound will run continuously then crash.
What i’ve tried
- I’ve tried changing the hardware preferences as in this post: Sounds stop playing after 2/3 stimuli when running the experiment several times .
- And i’ve tried editing the code suggested here (Sounddevice backend issue?) but I couldn’t find the line they were suggesting.
- I set the volume where I define the sound clip: click = sound.Sound(“click.wav”, volume=1.0)
I have other audio files in a separate routine which work fine. This is either a winSound or lossSound depending if they won/lost the bet. I wondered maybe my error is due to the code being in each frame, which may example the # Set the volume block by block error?
Doesn’t work in each frame (1st routine)
if ((onePad.contains(PadMouse) and PadMouse.getPressed() == 1)) or (betInput.keys == '1'): click.play() if int(len(currentBet)) <= 1: currentBet = (currentBet + "1"); betInput.keys = core.wait(0.3)
Does work in begin routine (2nd routine)
if correct == 1: winSound.play() else: lossSound.play()
Any advice would be appreciated