| Reference | Downloads | Github

Lag between picture and sound component

As a minimal working example, I have a picture component (a speaker icon) and a sound component (WAV with no padding at the beginning) defined at the top of my Trial routine, both set to start at 0.

I’d expect these to start at exactly the same time, however there is always a lag of 1-second or so between when the picture appears and when the sound then starts playing. I don’t understand why this is happening.

I switched the order and moved the picture component at the top, with the sound component second, but things don’t change.

How can I remove this delay between the onset of the two components?

OS (e.g. Win10): Win10
PsychoPy version (e.g. 1.84.x): 3.1.0

It takes a finite amount of time to load a file (images or sound) from disk and then process it in order to be able to work with it. So if you need a sound file to start playing immediately at a specific time, particularly if it is a large file, you should pre-load it in advance of the required time.

This can be done by inserting a “static period” component that occurs at some point when nothing is really changing during your procedure (e.g. when a fixation point is being shown. Then, in a later sound component, you specify that the sound file is set during that specific named static period, rather than the usual “every routine” setting.

You might also be able to improve performance by ensuring that the sound file is no longer than it needs to be.

Thank you Michael. I was just surprised that the lag is so great (order of seconds, perhaps 1-2s) for a sound file that is only 10s in length and therefore should load quickly. Anyway, I’ll try the preloading solution.

That does seem unusual.