Views: 2639

Written by:

Dealing with Latency: The Audio Buffer

Uncategorized

This post is going to focus on the subject of latency in the digital medium, mainly adjusting the audio buffer to achieve the results needed.

One thing that people who are new to the realm of recording on a computer will notice is that there is a lag between what goes into the computer and what comes out. This is due to the nature of how computers work. Computers are number crunchers. When audio goes into the computer it turns the audio into a string of digital information, ones and zeros. In order to play back the audio recorded, it has to convert those ones and zeros back into audio information and then present that information to you via the sound card. All of this takes time. That time is called latency.


There are many solutions in the modern studio that are designed to improve latency in the professional audio environment. The most important of these solutions is the creation of drivers for audio applications and hardware that are specifically designed to process audio quickly. Apple has Core Audio, Linux has Alsa / Pulse Audio, and Windows has ASIO and WDM. Both Core Audio and Alsa are included in their modern operating system releases, so the age of poor audio driver performance is thankfully coming to an end. Despite the advancements that have been made in the realm of audio driver performance, latency still exists as long as audio is being processed by the computer.

There are important things to know about working with audio latency. The most important is how to properly handle the audio buffer.

The Audio Buffer

Audio buffers exist in order to compensate for moments when the computer’s CPU is too distracted by other things going on to keep up with the task of processing audio. Think of the audio buffer as a bucket of water that fills up from a stream. There’s a hole in the bottom of the bucket out of which you get your water. In a situation where the stream is diverted and the water stops flowing into the bucket, it will be a while before the water in the bucket has collected is used up. If the stream can be redirected back into the bucket in time, you will experience an uninterrupted flow of water. If the bucket didn’t exist and the stream were diverted, the water would stop immediately. This is the purpose of the audio buffer… it’s the bucket and the audio stream is the water.

The larger the bucket you have, the longer it will take for the water to be depleted if the stream were to stop flowing. This means that the stream can be diverted for longer before you notice it has stopped flowing. This is what’s called a large buffer size.

If the bucket is small, it will take less time for the water to stop flowing if the stream is diverted, but you’ll get the water faster.

Consider if someone were to pour food coloring into the stream of water. With a larger bucket, you won’t be aware of the change for some time until the colored water makes its way to the hole in the bottom. With a smaller bucket, you’ll become aware of the change faster. This is what it’s like for audio that flows in and out of your audio buffer.

Your computer will respond faster to changes you make to your music if you have a small buffer size and slower if you have a large buffer size.

Applications for Small Buffer Sizes

Buffer sizes usually come in a few flavors, depending on the capabilities of your audio hardware: 32, 64, 128, 256, 512, 768, 1024, 2048, 4096, etc. It’s smart to choose small buffer sizes when doing things that need to be heard quickly, like playing a virtual instrument. If you were to have a large buffer size, there will be a longer delay between pressing the note on your midi keyboard and hearing the computer produce the intended sound. The smaller the buffer size the faster you will hear the sound and the more ‘live’ it will feel to play the instrument.

The downside of a small buffer size is that it’s less “safe” than a large buffer size. If your computer suddenly gets distracted and cannot attend to your audio quickly enough, you’ll experience a ‘dropout’ – a moment where the sound simply doesn’t happen. This can be disorienting at best. At worst it can freak the DAW out enough to stop recording altogether… meaning you may lose your take.

As a result, it’s important to use the smallest buffer size that meets your needs for ‘liveness’ while also having enough of a buffer to prevent things from going wrong. The more things you have going on in your DAW, like effects, tracks, or even other applications like internet browsers, the more likely it is for your computer to be too distracted. For me, I shut off all non-essential effects and kill any non-audio applications when I am performing. If I do this, I can often get away with buffer sizes as low as 64 on my Macbook’s stock hardware and Cubase, which produces a very satisfying response time.

Applications for Larger Buffer Sizes

Larger buffer sizes are useful either when a) you need to use your CPU heavily or b) it’s important to have what you’re doing be really “safe”.

If you’re mixing your material ‘in the box’ using you computer’s processing power, it makes sense to turn up the buffer size. This will free up more of your computer’s attention to deal with the extra burden of effects, automation, and whatnot. It’s not super important that the changes you make be heard right away (with the possible exception of automation movements). You’ll find you’ll be able to to fit substantially more effects in your mix without hitting your CPU’s 100% point.

If you’re recording something that absolutely must not be interrupted – like a live performance where you can’t get another take, it’s really important to choose a high audio buffer setting. The most important thing in these situations is making sure that the flow of audio to your computer does not ever get interrupted. Losing a portion of a live performance is a capital crime in production. Be smart!

Live Monitoring

Some devices offer a feature called ‘live monitoring’. Essentially these interfaces offer little montoring mixers that can bypass your computer. This means that you can hear the audio that’s going in at the same time as it goes in – you don’t have to wait for it to be processed and come back out. While this isn’t useful in situations where your computer is creating the sound, like a virtual instrument, or when you need to hear an plugin effect on the output, it is useful to hear the unadulterated signal without having to wait at all. Some examples of interfaces with this sort of feature are the RME Fireface 400 and 800, the Lynx Studio LynxTwo. I use the FF400 for my portable set up and love the Lynx series for mastering. Incidentally, independent from their live monitoring, both the Lynx and RME product lines have some of the best audio buffer performance on the market. I could get my LynxTwo down to 3ms!

As you can see, there is no “correct” buffer setting for all situations. This is something that you will probably have to change from content to context. Using appropriate buffer settings will save you many headaches and will make the music-making experience better for everyone. Take some time to experiment with what works for your equipment and needs so that you are aware of the choices you will have to make when working on the clock.

One Response to :
Dealing with Latency: The Audio Buffer

  1. Great! This “water bucket” exapmple was very helpful to me. Thank you guys!

Comments are closed.