I’m having trouble getting started with auditory stimuli in psychopy. I have so far managed to play pre-recorded wav files from a conditions file in excel, but I would like to also be able to play them using code. (I found some tutorials on this for the previous version of psychopy but it looks like lots has changed in the meantime.)
Let’s assume I want to play two sounds repeatedly with a fixed ISI between them, say sound1 onset, 500ms ISI, sound2 onset, 500ms ISI, sound1 onset, 500ms, etc. What would a code component that does this look like?
In coder? A rough and ready approach would be to use core.wait(0.5) a more accurate approach would be to fetch the frameRate and wait nFrames - there is some info on presenting stimuli using frames here(but that is easier to make mistakes with - which is why I use builder for things now!)
If you are using a code component in builder you could use something like this:
#Begin Routine tab
waiting = False
#Each frame tab
if not waiting and t >= toneOnsetTime:#where tineOnsetTime is a time you want to play the tone
startTime = t
firstTone.play()
waiting = True
if waiting and t >= startTime + 0.5: #where 0.5 if your deisred pause
waiting = False
nextTone.play()