Variance in delay with auditory stimuli

Hi everyone,

We created a auditory oddball task using psychopy script (originally generated from PsychoPy Builder and then modified) with LSL event triggers that are then captured via Neuroelectrics NIC software at the same time as EEG data (applies synchronization of clocks). To test the delay in sound presentation, we used the black box toolkit (BBTK) to send a TTL pulse in response to detected sound. To quantify the delay, we measured the difference between the LSL event and actual sound produced by headphones.

We used the PTB audio library and set the latency mode to 4:
from psychopy import prefs
prefs.hardware[‘audioLib’] = ‘ptb’
prefs.hardware[‘audioLatencyMode’] = ‘4’

The original implementation in the Builder App waits to present stimuli (sound/image) based on the window flip.
nextFlip = win.getFutureFlipTime(clock=‘ptb’)
mySound.play(when=nextFlip) # sync with screen refresh

However, using this implementation it was noted that there was a large discrepancy in when a visual stimuli showed compared to auditory stimuli, with the sound being displayed on average 74.66 ms after the visual stimuli. Of note, the sound was initialized at the beginning of the task and a nonslip timer was utilized for each trial.

It was also noted, that presenting an auditory stimuli based on window flip has a large amount of variance/jitter present that seems have oscillatory increases/decreases at random intervals (2nd half shown below).

Interestingly the jitter in the delay can be improved by presenting sound at a predetermined time.
sound_trial.setSound(soundFrequency, secs=thisTrialSoundDuration, hamming=True)
now = ptb.GetSecs()
sound_trial.play(when=now+0.1) # play in EXACTLY 0.1s

While the jitter can be improved we still have two outstanding questions/concerns:

  1. The overall delay is still ~100ms, which seems extremely long. We are currently utilizing a fairly basic 8GB RAM laptop with a 60Hz refresh rate to run this script. We also tried running the task on a 16GB gaming computer, which tremendously improved the overall delay. Does anyone know which hardware parameters will have the greatest impact on overall delay?

  2. Even with the change in presenting auditory stimuli based on predefined time, we still occasionally see a deterioration in the delay variance/jitter that seems to have a oscillatory nature to it (shown below). My initial thought is there could be some degradation in system performance related to a background task, low battery, antivirus, etc. Has anyone else experienced a similar issue or have some idea on what could be causing this issue?