Lokasenna Human being with feelings



Join Date: Sep 2008 Location: Calgary, AB, Canada Posts: 6,551

How to deal with interface latency (delay/lag)



What is latency? In the realm of digital recording, latency is the time it takes for a signal to open the door, come in, take of its jacket and boots, and sit down in Reaper's living room for a chat. Most equipment in your recording chain, especially analog (non-digital) stuff, won't add a noticeable amount of delay. However, digital things often will, and your computer's audio interface will typically add a fair bit.



Depending on how powerful your PC is, "a fair bit" can mean anything from 5ms (well below what most people can distinguish, but still enough to drive hardcore studio nerds insane) to 500ms ("Jesus, this drummer is horrible"). You may have noticed this if you've ever used guitar software like Amplitube, Guitar Rig, Revalver, or any of the sexy free plugins floating around the internet. That weird half-second between hitting a chord and hearing it through the speakers? That's latency, and that's what we're about to fix.



Well, sort of.



The first thing you want to do is mess with your interface's settings, particularly the buffer size, in order to minimize the latency you have to deal with. Buffer size refers to the size of each bundle of information that gets sent to Reaper. A smaller buffer means Reaper will receive incoming audio faster, but it will also put more of a strain on your computer. Conversely, a larger buffer is easier on the PC, but will make Reaper wait around longer until each bundle is full.



The rule of thumb here is that you want the buffer size as low as possible without causing any hiccups, glitches, or stutters in the audio signal. Trust me, if it's too low, you'll hear it.



We should now have a reasonably quick signal path going into Reaper. If you plug in a guitar, whatever you play should be coming right back out of the speakers with a minimum of fuss. (If your system simply can't handle a low latency, your best bet is to monitor through a real guitar amp while recording a direct signal into the computer, and then put it through Guitar Rig afterward).



Go ahead and record something simple, a basic rock beat, the riff to "Smoke On The Water", whatever - something easy. Record it to a click, as tight as you can. Now have a look at what you've recorded. Chances are it's not as tight as you thought it was. In fact, if you haven't already spent some time dealing with latency, I'd bet good money that the signal is significantly off from the click.



I think it's time for an illustration:



https://stash.reaper.fm/oldsb/745259/...sation%201.png



Edit: Big image, so I've changed it to a link.



I can hear people asking "What the hell am I looking at?" Simply put, this is how you deal with interface latency.



When doing performing the tests described below, set the track's Record Monitoring to OFF, or you could quite easily mess up your speakers with feedback. I take no responsibility for any inadvertent damage.



The first track, labelled "Source", is a simple click (In Reaper, Insert | Click Source). This is the most accurate signal to use for examining your latency, since it's all tidy and perfect.



Track two, "Interface", demonstrates the latency my interface is adding. To measure this, I simply ran a patch cable from the interface's output to the input, played back the click source, and recorded it coming back in. As you can see, the signal is significantly late. Exactly how much is a question we'll get to in a moment, but I'm not quite done here.



Just for fun, I wanted to see if there was a notable delay being added by the speakers and/or the two feet of space between my ear and the speaker. "Speaker" was recorded with a microphone against one of my monitors, and as you can see it did add a tiny amount of latency. However, the difference is so small that it might as well not exist. "Chair", recorded through a microphone placed beside my head, shows a bit more added time - but anyone with some basic physics already knew that.



The speed of sound, in air, is 1100ft/s. As my head is in the ballpark of two feet from the speaker, the signal should take an extra 1.8ms to get to me. Guess what? It does. Now, in the grand scheme of things 1.8ms doesn't make a bit of difference. Nobody, anywhere, ever, is capable of noticing 1.8ms of delay. At least, not by itself. But, as a guitarist, 1.8ms is enough to annoy me. Why? Simple: Doubling.



Pretty much anyone playing hard rock or metal these days will double (or quadruple) their guitar tracks. That's just how you get that big huge guitar sound we hear everywhere. In most cases, guitarists want their doubled tracks to be as tight (played in sync) as possible. The farther apart the two tracks are, the sloppier the sound. A little sloppiness might be fine for AC/DC and the Stones, but with today's ultra-perfect, ridiculously fast technical metal, the bottom line is all about inhuman precision. Given how simple it is to fix, I'd just as soon not have an extra 1.8ms lurking in the shadows of my mixes, tempting me to poke around and clean it up.



That's all just my opinion, however, and in most cases fixing the interface latency alone will be enough to keep you happy.



So, having discovered this evil delay in our signal, how do we fix it? Thankfully, the companies who manufacture interfaces are one step ahead of us. Most interfaces can make an educated guess as to how much latency they're adding and pass it along for Reaper to work with.



Here's where you want to look:







Checking off "Use audio driver reported latency" will have Reaper move all of your recordings back by whatever amount the interface says. But does it work? Have a look at the fifth track, "Interface, Reported Latency". In this case the interface is clearly trying to do the right thing, but is nowhere near the right number.



Every interface is different. Some might be spot-on with their guess, others might be worse than mine. If this option works for you, that's awesome.



It looks like we'll have to solve this problem ourselves. In order to get a measurement of our latency, as accurate as possible, here's what we'll do:



1. On Reaper's toolbar, turn off Snap To Grid (the magnet icon).

2. Right-click the Transport bar and tell Reaper to give use Samples as a time base. (A sample is one digital "tick" of audio information, and is the most precise unit of measurement you can use)

3. Zoom in nice and close, so the original and delayed clicks cover most of the screen.

4. Very carefully, drag a time selection from the start of the original to the start of the delayed signal.



Your screen should resemble this:







On the Transport bar, the third Selection box tells us how long our selection is. In my case, with "Chair" as our target, the delay is 2160 samples.



Back in the Preferences menu, next to the option to use our reported latency, are a few boxes that let us do the same thing manually. Unchecking "Use reported latency" and entering your own measurement under Input | Samples will tell Reaper to ignore the interface, and just move everything back by whatever you tell it to.



Looking back at our first image, the final two tracks show the same tests as above, but now compensated for their respective delays. Manual compensation has clearly done the trick, which means any further timing issues are now entirely my own fault as a musician.



I think it's time for a drink. I just did a bit of experimenting to get my system set up, all nice and perfect, and I figured the information might benefit someone else.In the realm of digital recording, latency is the time it takes for a signal to open the door, come in, take of its jacket and boots, and sit down in Reaper's living room for a chat. Most equipment in your recording chain, especially analog (non-digital) stuff, won't add a noticeable amount of delay. However, digital things often will, and your computer's audio interface will typically add a fair bit.Depending on how powerful your PC is, "a fair bit" can mean anything from 5ms (well below what most people can distinguish, but still enough to drive hardcore studio nerds insane) to 500ms ("Jesus, this drummer is horrible"). You may have noticed this if you've ever used guitar software like Amplitube, Guitar Rig, Revalver, or any of the sexy free plugins floating around the internet. That weird half-second between hitting a chord and hearing it through the speakers? That's latency, and that's what we're about to fix.Well, sort of.The first thing you want to do is mess with your interface's settings, particularly the buffer size, in order to minimize the latency you have to deal with. Buffer size refers to the size of each bundle of information that gets sent to Reaper. A smaller buffer means Reaper will receive incoming audio faster, but it will also put more of a strain on your computer. Conversely, a larger buffer is easier on the PC, but will make Reaper wait around longer until each bundle is full.The rule of thumb here is that you want the buffer size as low as possible without causing any hiccups, glitches, or stutters in the audio signal. Trust me, if it's too low, you'll hear it.We should now have a reasonably quick signal path going into Reaper. If you plug in a guitar, whatever you play should be coming right back out of the speakers with a minimum of fuss. (If your system simply can't handle a low latency, your best bet is to monitor through a real guitar amp while recording a direct signal into the computer, and then put it through Guitar Rig afterward).Go ahead and record something simple, a basic rock beat, the riff to "Smoke On The Water", whatever - something easy. Record it to a click, as tight as you can. Now have a look at what you've recorded. Chances are it's not as tight as you thought it was. In fact, if you haven't already spent some time dealing with latency, I'd bet good money that the signal is significantly off from the click.I think it's time for an illustration:I can hear people asking "What the hell am I looking at?" Simply put, this is how you deal with interface latency.The first track, labelled "Source", is a simple click (In Reaper, Insert | Click Source). This is the most accurate signal to use for examining your latency, since it's all tidy and perfect.Track two, "Interface", demonstrates the latency my interface is adding. To measure this, I simply ran a patch cable from the interface's output to the input, played back the click source, and recorded it coming back in. As you can see, the signal is significantly late. Exactly how much is a question we'll get to in a moment, but I'm not quite done here.Just for fun, I wanted to see if there was a notable delay being added by the speakers and/or the two feet of space between my ear and the speaker. "Speaker" was recorded with a microphone against one of my monitors, and as you can see it did add a tiny amount of latency. However, the difference is so small that it might as well not exist. "Chair", recorded through a microphone placed beside my head, shows a bit more added time - but anyone with some basic physics already knew that.The speed of sound, in air, is 1100ft/s. As my head is in the ballpark of two feet from the speaker, the signal should take an extra 1.8ms to get to me. Guess what? It does. Now, in the grand scheme of things 1.8ms doesn't make a bit of difference. Nobody, anywhere, ever, is capable of noticing 1.8ms of delay. At least, not by itself. But, as a guitarist, 1.8ms is enough to annoy me. Why? Simple: Doubling.Pretty much anyone playing hard rock or metal these days will double (or quadruple) their guitar tracks. That's just how you get that big huge guitar sound we hear everywhere. In most cases, guitarists want their doubled tracks to be as tight (played in sync) as possible. The farther apart the two tracks are, the sloppier the sound. A little sloppiness might be fine for AC/DC and the Stones, but with today's ultra-perfect, ridiculously fast technical metal, the bottom line is all about inhuman precision. Given how simple it is to fix, I'd just as soon not have an extra 1.8ms lurking in the shadows of my mixes, tempting me to poke around and clean it up.That's all just my opinion, however, and in most cases fixing the interface latency alone will be enough to keep you happy.So, having discovered this evil delay in our signal, how do we fix it? Thankfully, the companies who manufacture interfaces are one step ahead of us. Most interfaces can make an educated guess as to how much latency they're adding and pass it along for Reaper to work with.Here's where you want to look:Checking off "Use audio driver reported latency" will have Reaper move all of your recordings back by whatever amount the interface says. But does it work? Have a look at the fifth track, "Interface, Reported Latency". In this case the interface is clearly trying to do the right thing, but is nowhere near the right number.It looks like we'll have to solve this problem ourselves. In order to get a measurement of our latency, as accurate as possible, here's what we'll do:1. On Reaper's toolbar, turn off Snap To Grid (the magnet icon).2. Right-click the Transport bar and tell Reaper to give use Samples as a time base. (A sample is one digital "tick" of audio information, and is the most precise unit of measurement you can use)3. Zoom in nice and close, so the original and delayed clicks cover most of the screen.4. Very carefully, drag a time selection from the start of the original to the start of the delayed signal.Your screen should resemble this:On the Transport bar, the third Selection box tells us how long our selection is. In my case, with "Chair" as our target, the delay is 2160 samples.Back in the Preferences menu, next to the option to use our reported latency, are a few boxes that let us do the same thing manually. Unchecking "Use reported latency" and entering your own measurement under Input | Samples will tell Reaper to ignore the interface, and just move everything back by whatever you tell it to.Looking back at our first image, the final two tracks show the same tests as above, but now compensated for their respective delays. Manual compensation has clearly done the trick, which means any further timing issues are now entirely my own fault as a musician.I think it's time for a drink.

I'm no longer using Reaper or working on scripts for it. Sorry. :(

Default 5.0 Nitpicky Edition / GUI library for Lua scripts / Theory Helper / Radial Menu / Donate __________________I'm no longer using Reaper or working on scripts for it. Sorry. :( Last edited by Lokasenna; 12-29-2009 at 12:17 PM .