Audio latency not as simple as it looks.
Results 1 to 3 of 3
  1. #1
    Tech Guru Fatlimey's Avatar
    Join Date
    Mar 2008
    Location
    Redmond, WA
    Posts
    1,169

    Default Audio latency not as simple as it looks.

    Been reading up on writing audio software (Audio Anecdotes) and come across something that surprised me about audio latency.

    Usually, when you set up an audio device you get a slider that sets the "buffer size", often measured in milliseconds. That represents the amount of time the audio hardware can output until it has consumed all the data in the buffer. Simple enough.

    But audio buffers are actually implemented as a Ring Buffer. There are two markers, the Read point and the Write point, and they follow each other around the circular buffer, where the Write point can never overtake the Read point. The latency of the audio in that situation is the distance between the two markers - that's the amount of sound that has to be played before any new sounds can be sent. Often, this distance is way less than the size of the buffer - that's problem no.1 in calculating your latency: Buffer size only control the maximum latency in the system. Making your buffer smaller does little to the average latency, that actual use case you are trying to control.

    The second problem is that, with fast CPUs being able to fill audio buffers way faster than they are consumed by the audio hardware there is a trick where the software has filled a buffer with audio data to be played. Suddenly the user tweaks a parameter or presses a button that means different audio should now be playing. The CPU can ignore the Write position, jump back into the already written audio data and start rewriting old audio with new values. There's no need for the system to wait for the buffer to be emptied before generating new audio. The latency for this system is much less than the size of the buffer and is only proportional to the speed of your CPU. The faster your CPU, the further back in time it can jump, start refilling and still be ahead of the Read position.

    So, setting your buffer size to the minimum before it crackles is no longer the correct thing to do. Just pick a healthy amount and let the software do it's job.

    Yes, this really needs diagrams to explain it properly...

    (Not that I can prove that any particular piece of software actually uses this technique, but it's definitely out there in the wild)
    Last edited by Fatlimey; 06-24-2010 at 01:51 PM.

  2. #2
    DJTT Infectious Moderator photojojo's Avatar
    Join Date
    Apr 2010
    Location
    Sherman, TX
    Posts
    13,939

    Default

    My latency set itself at 30ms when I installed Traktor on my MBP. I forgot to change it for about a month, mostly because I never noticed any thing wrong with my audio.
    Chris Jennings FHP

    Podcast - Soundcloud - Mixcloud - Beatport Charts - x

  3. #3
    Tech Mentor DJPhaidon's Avatar
    Join Date
    Nov 2008
    Location
    Reno, NV
    Posts
    482

    Default

    Good find Limey. More reading material

    13" MacBook Pro 2.7 i7 w/dual Raid0 OWC SSDs - S4 - Ableton Live 8- Lemur- iPad 2

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •