psychopy.org | Reference | Downloads | Github

Adding music to run throughout an experiment

Hello there, I am a 3rd Year Psychology student and I am currently planning my final research project.

I am going to be using Pavlovia to run a Stroop task (with additional rules) to measure error rates and error detection. I want to see if music has an effect on error awareness and I am therefore using 3 different conditions, silence, rock and classical.

I want the music to play continuously throughout a certain number of trials (not start and then stop on each trial) but I am unsure how to achieve this in PsychoPy.
If anybody could give any help that would be hugely appreciated!

Because of how Routines work, everything in them has to be contained and so cannot span multiple Routines. However, you can create the illusion of continuous playback by starting each Sound component where the previous one left off. If we call your Sound component mySound, you could create a Code component to manage this.

It would need to have this in Begin Experiment:

seekStore = 0

this in End Routine:

seekStore += t

and this in Begin Routine:

mySound.seek(seekStore)

So, in English: Start out with seekStore set to 0, each Routine start the audio at the point specified by seekStore, at the end of the Routine, add the time elapsed to seekStore.