I need to carefully control the latency and timing of auditory stimulation in an upcoming experiment. Some of this depends on software, but my question is specifically relating to hardware, drivers and OS kernel. In other words, I'm not looking for advice on programming languages; I have that part covered.

Driver & OS

I'm somewhat familiar with the ASIO4ALL driver suite in Windows, but I was weighing this against the option of using a Linux distribution (e.g. Ubuntu) with a real-time kernel installed. My concern is that sound is notoriously problematic in Linux. I seem to recall real-time audio being all but impossible if you're working with ALSA. Is the same true of Pulseaudio? Has anybody successfully set up low-latency audio output in Linux?


What sound cards are commonly used? Can anybody suggest some specialized hardware? Ideally, I'd like to stick with a PCI card of some sort and not have to resort to bulky external sound cards, but I could be swayed if these cards offer significant advantages.


  • $\begingroup$ Have you read the specific instructions and benchmarks for the specific experimental software you're gonna use? $\endgroup$
    – jona
    Jul 10 '14 at 13:40
  • $\begingroup$ @jona, Sure, but there's no mention of recommended hardware, nor is there any information about real-time Linux kernels. Is there some spec whose relevance I'm overlooking? $\endgroup$ Jul 10 '14 at 15:10
  • $\begingroup$ What software are you going to use? All the experimental software I know comes with extensive discussions of this topic. $\endgroup$
    – jona
    Jul 10 '14 at 16:07
  • $\begingroup$ @jona, This PC will mainly be running psychopy (and other python-driven scripts). Psychtoolbox is also likely to be installed. $\endgroup$ Jul 10 '14 at 16:54

It generally helps to provide some sort of specification as to how well you want to control the timing. There are 4 orders of magnitude difference between the 100 ms timing accuracy required for auditory and visual stimuli to be judged simultaneous (Zampini et al. 2005) and the 0.1 ms timing accuracy required for binaural stimuli to be judged simultaneous (Hershkowitz and Durlach 1969). There are two types of latency when it comes to audio stimulation, what I will refer to as the ongoing and onset latencies.

Ongoing Latency

Imagine a study on virtual reality where the subjects head orientation is being tracked in real time presented sound depends on the orientation. In this type of study it is not possible to load the sound in advance onto the sound device. If the audio device requires 1000 ms of sound in advance so as to not drop samples, there will be a noticeable lag between moving the head and the sound position updating. Scarpaci et al. (2005) found that an for these types of studies an overall latency of under 32 ms is desirable. This overall latency needs to include the time required to read the current position as well as generate the sound and then buffer the sound. Depending on the speed of other devices and the amount of required processing time, this may only leave 5-10 ms for sound buffering. Head movements are relatively slow and our sensitivity to the location of a sound is relatively poor, and other experiments may require much lower latencies.

A perfect sound device would have an ongoing latency less than a sample. With a sample rate of 10 kHz, the sound hardware has 0.1 ms per sample, but at 100 kHz it only has 0.01 ms per sample so when choosing a sound device it is important to consider the sample rate. Off the shelf systems with PortAudio can provide ongoing latencies on the order of 10 ms. The PsychToolbox patches PortAudio and can achieve lower ongoing latencies. Scarpaci et al. (2005) achieved subsample ongoing latency with a 44.1 kHz sample rate by using a real time Linux kernel and a dedicated DA board. Custom systems by TDT can provide subsample ongoing latency with a 200 kHz sample rate.

Onset Latency

Imagine an EEG study in which one wants to start recording from the EEG electrodes at the same time as the sound starts playing. Unlike ongoing latency, it is possible to load the stimulus onto the sound device in advance. The goal is then to have the sound device start as quickly as possible. In my opinion, it is more important to minimize the variability in this latency rather than minimize the latency itself. If it takes between 99 and 101 ms (high latency, low variability) to start the sound, then if the EEG recordings are delayed by 100 ms, the onset of the sound and recordings will be within +/-1 ms. If however, it takes between 0 and 20 ms (low latency, high variability) and the EEG recordings are delayed by 10 ms, then the onset asynchrony can be as large as 10 ms. The case where the onset latency really matters is when the start of the sound is externally triggered. For example if a subject presses a button to start the sound, having a "long" delay would be problematic.

Similar to ongoing latencies off the shelf systems can provide onset latencies on the order of 10 ms and PsychToolbox can get down to about 5 ms (maybe less). Scarpaci et al. (2005) did not measure onset latency and performance is likely poor since the system was not optimized for that aspect of sound delivery. The TDT systems provide an external trigger and can provide onset latencies down to levels that make it difficult to measure (sub microsecond). CRS provides custom hardware that can be externally triggered so should provide extremely low onset latencies, but the system requires the stimulus to be loaded in advanced so it essentially has an infinite ongoing latency.

  • $\begingroup$ I concur with StrongBad: I have experience with both TDT and the PsychoPhysics Toolbox (PTB-3) in Matlab. The TDT system is hardware that is specifically designed for audio-related tasks and brings latencies down to sub-microseconds. If you do not wish to spend hundreds to tens of thousands of dollars on a TDT modular system, then PTB-3 offers a free software environment add-on to Matlab and it offers EXCELLENT help files and instructions how to bring down latencies in the millisecond order on a pc/mac/Linux machine. Hope this helps. $\endgroup$
    – AliceD
    Oct 31 '14 at 3:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.