Page 1 of 4
A more accessible way to set up latency correction
Posted: Tue Nov 19, 2013 6:57 pm
by steve
As illustrated in this topic
http://forum.audacityteam.org/viewtopic ... 46&t=75803 setting up latency correction is quite problematic for VI users.
David's JAWs guide offers helpful advice)
http://vip.chowo.co.uk/wp-content/uploa ... correction
but the step "
Find the position of a click in the recorded track" is still quite awkward.
A relatively simple improvement could be to provide a plug-in that measures the time difference between clicks in two selected tracks.
This could be developed as a Nyquist plug-in, and this Feature Request is in part a place-holder / reminder for me to look into that.
A more complete solution would be for a built-in tool that can adjust the latency correction setting according to clicks being recorded from a track that is playing.
This would be a lot harder, but I don't think impossible.
Re: A more accessible way to set up latency correction
Posted: Tue Nov 19, 2013 10:00 pm
by steve
Zero latency is impossible, not only for Audacity but for any program.
There are several different "latencies" but they all refer to the same principle, which is that things cannot be done "instantly".
When you record the first track, the sound enters the computer (perhaps via a microphone), passes through the sound card, is written to the hard drive and drawn as an audio track in the Audacity project window. In order for the data to all be transferred successfully the data is buffered at various stages in this process. It does not really matter if this takes a couple of milliseconds or several hundred milliseconds, the audio can still be drawn on the track starting at time = 0.
When you record a second track the situation is less simple.
The data for any existing audio tracks is read from the hard drive and if necessary converted to a format supported by the sound card, then passed to the sound card, which in turn converts the data back into sound which plays through your headphones. This takes time. It cannot happen instantly.
You can then sing, talk or play an instrument in time with the tracks that are already playing.
The new sounds pass through the sound card and are written to the hard drive in much the same way as for the first track, but now the time take is important.
To make the arithmetic easy, lets sat that it takes 1 second for the audio data on the hard drive to be read, pass through the sound card and play through your headphones and that it takes 1 second for sound to pass from the microphone, through the sound card and be written to disk. The new audio track is now 2 seconds late compared with the first track. This is sometimes called "round trip latency". In order to get the second track correctly aligned with the first track, the second track must be shifted so that it has an earlier start time, in this example it would need to be shifted 2 seconds earlier.
If sounds could pass from the microphone, through the sound card and be written to the hard drive instantly (in zero time) and data could be read, passed through the sound card and played through the headphones instantly (in zero time), then there would be no latency and no need for latency correction, but unfortunately that is impossible.
The next best thing would be if Audacity automatically knew how much round trip latency there would be, then Audacity could automatically adjust for it. Unfortunately this is not simple because there are so many dependent factors involved. The actual amount of latency depends on many things including the sound card hardware, the sound card drivers, the operating systems sound system, the CPU, the hard drive, the sample rate, the sample format and other things. Audacity guesses that the round trip latency will be around 130 milliseconds, and often this is close enough, but sometimes not. If that is not close enough then the second and subsequent tracks will be out of time with the first track, so it is then necessary to manually adjust the latency correction.
Re: A more accessible way to set up latency correction
Posted: Tue Nov 19, 2013 10:01 pm
by Robert J. H.
I'm just writing a latency plug-in, so no need for you Steve to look into this.
On Windows, it even reads out the current latency setting (Audacity.cfg) and proposes the new value to be entered. However, it would be nice if you (Steve) could supply a function that returns the Audacity.cfg location on Linux (or even Mac?).
Re: A more accessible way to set up latency correction
Posted: Tue Nov 19, 2013 10:08 pm
by steve
Robert J. H. wrote: it would be nice if you (Steve) could supply a function that returns the Audacity.cfg location on Linux (or even Mac?).
On Linux the default location is
~/.audacity-data
where "tilde forward slash" means the users home folder.
On Mac OS X it is
~/Library/Application Support/audacity/
On Windows 2000/XP it is
Documents and Settings<user name>Application DataAudacity
On Windows Vista/Windows 7/Windows 8 it is
Users<user name>AppDataRoamingAudacity
Re: A more accessible way to set up latency correction
Posted: Tue Nov 19, 2013 10:50 pm
by steve
That phasing effect is because the latency correction is very close to (within a few milliseconds of) the actual round trip latency.
If the latency correction is exactly equal to the actual latency then you won't even hear that phasing effect. It will sound just like the original but 6 dB louder.
You could try using a recording program that supports ASIO and install ASIO4ALL.
ASIO provides low latency, so it is more likely to provide close enough correction out of the box.
Audacity cannot be shipped with ASIO support due to licensing restrictions, but there are other free audio editors available that do support ASIO, such as Krystal Audio Engine.
Re: A more accessible way to set up latency correction
Posted: Tue Nov 19, 2013 10:56 pm
by steve
Generate a click track
Choose Click Track from the Generate menu.
The second control is the Tempo [beats per minute] edit box, and its default value is 120. Type 60, and then press Tab twice to move to the next edit box.
The Beats per measure [bar] edit box has a default value of 4. Type in the number 1, and then press Enter to press the default OK button.
The click track is created. The track is initially selected, and a time range is selected which includes all the audio.
Record the click track
To record the click track being played back through your headphones, you'll obviously need to take them off temporarily. If you're using a separate microphone, rather than a headset microphone, then position it close to the headphones so that it can pick up the clicks. Press R to start the recording, and then press Spacebar to stop the recording after a handful of clicks.
With the first track still being the focus, press Shift + U to mute it, and then playback the recorded track. If the clicks are very quiet compared to Jaws, then amplify the track:
Unselect the first track, and select the second track
Press Home, then Shift + End to select a time range.
Choose Amplify from the effects menu.
In the Amplify dialog, just press Enter to accept the default amplification.
Find the position of a click in the recorded track
The following instructions describe how to find the position of the recorded click which corresponds to the click which occurs at 1 second in the generated track, and then update Audacity's latency correction. It's assumed that the original track is still muted from when you checked the level of the recorded track above.
Press Home to set both the selection start and selection end/length spin boxes in the selection bar to zero.
Press Ctrl + F6 to move to the selection bar. Tab to the End/Length radio buttons, and make sure that the Length option is selected.
Then Tab to the Selection Start spin box, and change the format to hh:mm:ss + milliseconds using its context menu.
To set the selection start to 1 second, press End to move to the last digit (milliseconds), press Left Arrow three to move to the seconds digit, and then press Up Arrow to increment it to one.
Press Spacebar to listen to the first few clicks. There are two cases: if the recorded click is later than the original click at 1 second, then time to the first click is much less than the one second spacing of the remaining clicks; if the recorded click is earlier than original click, then the time to the first click is roughly the same as the one second spacing between the remaining clicks. Finding the position of the recorded click, and modifying Audacity's latency correction is described for these two cases in the following steps.
To find the position of the recorded click when it's later than the original click, go round the loop of incrementing the selection start by 10 milliseconds and then pressing Spacebar to check the time to the first click. When you've just gone past the click, it will suddenly change to roughly a second. Decrement the selection start by 10 milliseconds so that you can still hear the first click almost immediately, and then press Insert + Up Arrow to read the number of milliseconds. Adjust the latency correction by subtracting this number from it. For example, if the initial correction was -130ms, and the recorded click was 40ms late, then the latency correction should be changed to -170ms.
To find the position of the recorded click when it's earlier than the original click, go round the loop of decrementing the selection start by 10 milliseconds, and then pressing Spacebar to check the time to the first click. When you move to just before the click, or during it, the click will suddenly sound immediately. Press Up Arrow, followed by Down Arrow to leave the time unchanged, but to get Jaws to read the number of milliseconds. Subtract this number from 1000 to get the number of milliseconds by which the recorded click was early. Then adjust the latency correction by adding this number to it. For example, if the initial correction was -130ms and the recorded click was 20ms early, then the latency correction should be changed to -110ms.
Re: A more accessible way to set up latency correction
Posted: Tue Nov 19, 2013 11:04 pm
by Robert J. H.
Thank you Steve.
On Windows 7, I get the path via the environment variable "APPDATA". And there's of course the "Portable Settings" folder that should be examined first, actually.
Re: A more accessible way to set up latency correction
Posted: Tue Nov 19, 2013 11:20 pm
by steve
On Linux you can use the HOME environment variable.
Re: A more accessible way to set up latency correction
Posted: Tue Nov 19, 2013 11:42 pm
by steve
I don't know of any reliable way to find the directory from which Audacity is running (which I think would be required to find a Portable Settings folder). Let me know if you find one

Re: A more accessible way to set up latency correction
Posted: Tue Nov 19, 2013 11:52 pm
by Robert J. H.
steve wrote:I don't know of any reliable way to find the directory from which Audacity is running (which I think would be required to find a Portable Settings folder). Let me know if you find one

How about