| Reference | Downloads | Github

Building an audio based mri block design

hello :slight_smile:
i need to build a pretty simple block-design mri experiment, and im trying to do it PsychoPy, but for some reason the api doesnt include a lot of info on the sound modules…

what im trying to build is a program that runs 4 or 5 audio stimuli for 20 sec each for about 4 runs, with interchanging order between the stimuli.
what is the best way to time duration of the stimuli? and why do i have a lag when i use play()?

(btw, this is my first time using psychopy, and im pretty new to python as a whole…)


a more specific problem that arose, is a threading error…
probably because my code is the wrong way of preforming this task

any ideas on the crowd?

The error is likely occurring because you are trying to start playing the sound thousands (or more) times. Only issue once. It will automatically stop playing once the sound file has ended. i.e. sound stimuli aren’t like visual stimuli: you don’t to keep actively ‘drawing’ them. Once started, they take care of themselves and your code can continue doing other things.

If you need to terminate it early, at some specified time, then do something like this:

while timer.getTime > 0
    time.sleep(0.001) # don't let loops run too fast, they hog the CPU
    fur_elis.stop() # end the sound prematurely

ok, but now stop() doesn’t really stop the file from running… it make the audio be like a reprtetive loop on the last bit (like when you record player is stuck)
i think its some kind of bug in the stop() module…