sound.Sound cannot play notes (specified by string), PsychoPy 2024v2.2 & 2024v2.1,Win 10)

Hi! I really appreciate the work that you’ve put into PsychoPy!

I recently tried creating a new sound object from a string:

a = sound.Sound(value="A")

and was met with the following error trace:
“Traceback (most recent call last):
File “”, line 1, in
File “C:\Users\mdm124\AppData\Local\Programs\PsychoPy\lib\site-packages\psychopy\sound\backend_ptb.py”, line 334, in init
self.setSound(value, secs=self.secs, octave=self.octave,
File “C:\Users\mdm124\AppData\Local\Programs\PsychoPy\lib\site-packages\psychopy\sound\backend_ptb.py”, line 423, in setSound
_SoundBase.setSound(self, value, secs, octave, hamming, log)
File “C:\Users\mdm124\AppData\Local\Programs\PsychoPy\lib\site-packages\psychopy\sound_base.py”, line 192, in setSound
self._setSndFromNote(value.capitalize(), secs, octave,
File “C:\Users\mdm124\AppData\Local\Programs\PsychoPy\lib\site-packages\psychopy\sound_base.py”, line 248, in _setSndFromNote
self._setSndFromFreq(thisFreq, secs, hamming=hamming)
File “C:\Users\mdm124\AppData\Local\Programs\PsychoPy\lib\site-packages\psychopy\sound_base.py”, line 264, in _setSndFromFreq
self._setSndFromArray(outArr)
File “C:\Users\mdm124\AppData\Local\Programs\PsychoPy\lib\site-packages\psychopy\sound\backend_ptb.py”, line 497, in _setSndFromArray
self.track = audio.Slave(self.stream.handle, data=self.sndArr,
File “C:\Users\mdm124\AppData\Local\Programs\PsychoPy\lib\site-packages\psychopy\sound\backend_ptb.py”, line 609, in stream
label, s = streams.getStream(sampleRate=self.sampleRate,
TypeError: cannot unpack non-iterable NoneType object”

This seems to only be an issue with creating sounds from notes (.wav files work fine and sound great), and is not an issue on 2024v1.3 on Mac (need to check which OS).

Thanks,
Miles

Python 3.9.17 (main, Jun  8 2023, 14:52:17) 
[GCC 13.1.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import psychopy
>>> from psychopy import sound
>>> a = sound.Sound(value="A")
>>> a.play()

works, so you will need to tell us what:

python version
what you have imported
any audioprefs you set and soundclasses
have you tried setting all the parameters in sound.sound?
e.g., a=sound.Sound( value = ‘A’, octave=4, secs = 0.5, volume=.6, hamming=True,stereo=0, sampleRate=48000 )

see: https://psychopy.org/api/sound/playback.html

see, also [Bug]: API example not working - calling psychopy.sound.Sound('A') · Issue #6765 · psychopy/psychopy · GitHub

Hi Ben,

Thanks for your response! And in particular, for pointing me towards the issue on GitHub. The issue was the stereo argument, this works:

Python 3.10.11 (tags/v3.10.11:7d4cc5a, Apr  5 2023, 00:38:17) [MSC v.1929 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from psychopy import sound
>>> a = sound.Sound(value='A',stereo=True)
>>> a.play()