Audio Synchronization

Typically, playing audio files is typically not particularly reliable with respect to timing. Latencies of 100 +/- 50 ms are common. However, for simple experiments, it is straightforward to measure when an audio output occurred. Generate wave files for which the left channel is the waveform that you want the subject to hear. Plug this into your speakers. The right channel should be a square pulse at the beginning and end of the file. Connect this to the biosemi analog input box (or equivalent). This way, there is a synchronized voltage level in the EEG data when any sound is played. An LSL event at about the same time can be used to indicate which sound was played.

If the experiment is more complicated (or requires more precise timing of output in addition to measurement) it is possible to get improved reliability on Windows by using Audio Stream Input/Output (ASIO) drivers and devices. A free ASIO driver is available at ASIO4ALL. Most conventional devices support ASIO to some degree. Software support is less common, but still available. A low level SDK is available from the developer of ASIO, if desired (free account required).

However, even with ASIO latency is generally not well-reported or guaranteed and has to be tested with any desired device and software. The following tests were done with the default sound device on a Dell Precision 390 (an older computer). Two USB devices (the M-Audio M-Track and the Creative Sound Blaster X-Fi) did not perform as well, so in this case the cheaper solution is better.

Sounds were generated using Psychophysics toolbox (which supports ASIO), with this code and analyzed with this code and this code. LSL's LabRecorder was used to record data. A Logitech USB microphone and the AudioCaptureWin LSL application were used to record sounds. In addition, a homemade analog microphone was used to convert the sound into a voltage that could be acquired by the biosemi analog input box and the BioSemi LSL application.

Below is an example of the raw data. The vertical red trace is the LSL event. The horizontal red lines are the triggering threshold. The black trace is the audio data from the logitech microphone. The blue trace is the audio data from the analog microphone. It is referred to as EEG because it is input into the biosemi analog input box and therefore accurately represents the latency between the LSL event and the EEG signals. A known constant latency of 7.72 ms was subtracted from the EEG signal. A known constant latency of 10.47 ms was subtracted from the audio signal. A known constant lead of 49.02 ms was added to the event time. These offsets are included in all the figures on this page.

Below is the audio latency, over time, and binned. This shows is a stable latency of -0.44 to 0.48 ms, with occasional (about 0.3 %) outliers of as much as 5 ms.

Next we show the EEG latency, with a range from -0.45 to 0.48 ms latency, with the same outliers.

Plots comparing EEG vs audio latency are next. The correlation between the two is very high (less than 200 microsecond variation), which is expected for a robust recording system. That is, the variation comes from how the sounds are played, not how they are recorded.

 

The data for this report was taken on 2013/11/21.