If I have a list of stimulus names for tones, either written in code or pulled up from an excel file using xlrd, how do I play them using code in psychopy?
# For example, if my tones are
lo = sound.backend_sounddevice.SoundDeviceSound(value='A',
secs=0.05, octave=4, stereo=-1, volume=1.0,
loops=0, sampleRate=44100, blockSize=128,
preBuffer=- 1, hamming=True, startTime=0,
stopTime=- 1, name='', autoLog=True)
hi = sound.backend_sounddevice.SoundDeviceSound(value='B',
secs=0.05, octave=4, stereo=-1, volume=1.0,
loops=0, sampleRate=44100, blockSize=128,
preBuffer=- 1, hamming=True, startTime=0,
stopTime=- 1, name='', autoLog=True)
# and the stimulus list is
tone_stimuli = ['hi', 'hi', 'lo', 'hi', 'lo']
# and I want to play them in order with a command like
hi.play()
What is the code I need in order for this to play the high tone, high tone, low tone, high tone, low tone, in sequence, as in the tone_stimuli list?
I tried this but it didn’t work:
current_tone = str(tone_stimuli[0])
current_tone.play()
(At the end of the day I need to make an audio-visual experiment where tones play in the background of the visual task, and independently of the visual trials. To do so, the tones need to be played using code, and need to pre-exist in a list for timing perfection, so workarounds where the tones are called in Builder unfortunately won’t work in this case.)