Fingers crossed I think I’ve worked out how to present sound files selected in code.
I created a sound component (sound_1) in a routine prior to the one where I wanted the sound to be played. I called the sound $thisSound with “set every repeat” and (critically) set the start time to after I want the routine to end (e.g. 2 for a 1 second routine).
I therefore had to end the routine in code
if t > 1: continueRoutine=False
- I start the sound file playing in End Routine
if thisSoundCondition != "Silence": sound_1.setVolume(1) sound_1.play()
setVolume probably isn’t needed – it’s still there from earlier attempts.
I then stop the sound in Begin Routine of the routine after where I want it played.
if thisSoundCondition != "Silence": sound_1.stop()
I don’t yet know how to stop PsychoPy having to download all 36 wav files (of which I need 13 – or possibly only 10) but when the experiment fails due to a memory issue at the start it usually works if I try again.