PTB Latency Modes not reacting as expected under PsychoPy + MS Windows

Hi all,

I’m seeing some odd behavior when presenting sound stimuli and using PTB latency modes. I’m synchronizing the sound presentation with a trigger output for an EEG experiment and when using Latency mode 3 I was getting a lag of about 100ms with respect to the trigger being sent. I verified this using an oscilloscope. Troubleshooting the code I changed the latency mode to 0 to see what the worst performance looked like and to my surprise this had sub millisecond accuracy. In summary, Latency mode 0 gives me better timing accuracy than latency mode 3, and I can’t get my head around it.

Has anyone experienced this before?

I am using Win 10 64-bit Education edition 22H2, and the python implementation on python 3.8.18 via Psychopy.

mode 0 on Windows would by default choose the ancient Windows MME backend, which usually has high (> 100 msecs) latency and not much timing precision at all, neither in the sound onset timing, nor in the corresponding timestamps. Our driver even requests a 100 msecs minimum latency by default, as lower values were known to cause instability and audio artifacts with MME. mode 3 will get exclusive hardware access to the soundcard and optimized sample formats, for typically below 20 msecs latency on Windows 10 via the modern WASAPI backend.

So this result seems unlikely, and user error or a misunderstanding on how to coordinate triggers with sound seems more likely. Or bugs in the PsychoPy code wrapping around the PsychPortAudio sound driver. Sub-millisecond latency is essentially impossible, only sub-millisecond accurate sound onset scheduling under the right conditions. This even more suggests some flaws in your testing approach.

You don’t describe your exact test setup, code etc., so more information would be needed to see what’s going on. And at least 30 minutes of my paid work time, possibly more, so please post a paid support authentication token, as generated by the PsychPaidSupportAndServices Psychtoolbox function to pay for up to 30 minutes of my paid support. See also License Key | Psychtoolbox.

-mario

Thanks Mario,

Good to hear a bit more what the defaults of the modes are. As this is a psychopy environment issue (which I realized after posting this here initially). I’ll wait to see if there is another set of eyes in that forum.

Kind regards
Alejandro

@ALopez that wasn’t my experience when testing the PTB audio. We found the expected results of long and variable lags (but wide compatibility) when using mode 0. We found high precision and accuracy when using exclusive aggressive mode, but note that for this you do need to preschedule the audio to occur at a particular point in the future (you may need as much as 20ms in advance of the desired start time). In our tests, when you schedule the audio to start in sync with a visual stimulus you can get very high precision (and accuracy). If you simply request the sound to start “as soon as possible” in mode 3 then you will get a rather variable lag before the sound starts