If you’re a musician trying to record tracks in your favorite DAW and you’re hearing tons of glitches, stutters, and audio dropout, or you’re an “audiophile” getting too much crackle and distortion while playing your favorite 24/192kHz lossless-quality music files, Appuals has just the guide for you!
Understanding Buffer and Latency in Audio
Let’s define some terms:
Buffering – the process of grouping samples into batches for processing.Buffer Size – the number of samples in one batch.Audio Cycle – the processing of one audio buffer.Latency – the time duration of the buffer.
Our ears generally decide how much latency is tolerable to us. Its pretty much established that most humans cannot discern audio intervals less than about 10 milliseconds – basically, two sounds played 10ms apart sound like they are instantly together. So, latency can be calculated by dividing the buffer size by the sample rate and using some simple algebra we can work out the required buffer size:
Latency = BufferSize / SampleRateBufferSize = Latency * SampleRateBufferSize = 0.01 * 44100 = 441
At a sample rate of 44.1KHz, 10ms is 441 samples. Since some sound cards only support buffer sizes that are powers of 2 (like RAM), this is often rounded up to 512 samples (about 12ms) or down to 256 samples (6ms) – depending on what your computer is capable of. For your computer to produce a glitch free audio stream, the computer needs to provide a fresh buffer of samples to the sound card roughly every 10 milliseconds. If it is unable to keep up with that buffer rate, then there is nothing that will fill in the blank spaces between audio, and you will have glitches. The type of glitch you hear will depend on a couple of things.
Short delays typically sound like a “tick”.Longer delays either produce no sound – “drop outs”, or sometimes the buffered samples from the previous cycle are replayed causing “stuttering”.
The key to performance tuning a PC for real-time audio processing is eliminating anything that might cause it to be held up on other tasks for longer than the duration of the buffer. So, to reduce or completely eliminate audio glitches during live monitoring of input signal, or playback of output signal, there are a number of things you can do that revolve around your Windows settings.
Power Management:
Just like optimizing your computer for intensive gaming, the first thing we want to do is make sure your computer is set to a high-performance power plan, with some things disabled.
Power Plan: High PerformanceTurn off Hard Disk: NeverMinimum and Maximum processor state: 100%USB Suspend: NeverPCI Express link state management: Off
Device Manager:
Hard Drive Compression and Indexing
Processor Scheduling
Windows multi-tasking revolves around a process called time slicing. This allows each program a tiny amount of time to run. By continuously cycling through all the running programs it appears as if they’re all running at once. This Processor Scheduling setting controls the duration of each of these time slices. Longer time slices are better for background processing, whereas shorter timer slices can make the user-interface seem more responsive. You might be wondering which is best for audio processing; There’s no correct answer! It entirely depends on what you’re doing, so one might perform better than the other. Longer time slices might give your audio software more time to process audio but they can also keep the processor tied up on other tasks and prevent audio processing.
It’s probably best to start with “Background services” mode:
Core Parking Core
Core parking is a CPU-specific feature available in some modern processors (e.g.: Intel i7 processors) in which entire CPU cores will be disabled to minimize power consumption. This is good for power management but can affect real-time audio performance because there is a small delay when unparking which can lead to drop outs if that processing power is needed. By default, Windows hides the setting for core parking but it can be shown with a few tweaks to the system registry. In the Advanced Settings window navigate to Processor Power Management -> Processor performance core parking min cores. The value you enter for this setting is the minimum percentage of processor cores that must kept running (not parked). Set this to 100% to prevent any cores from being parked.
Page File Settings
The Paging File is a special file that Window’s uses for additional storage when physical memory starts to run low. The paging file is also referred to as the “swap file” because pages of memory are swapped between it and physical memory. By default, Windows is typically configured automatically manage the size of the paging file however you should consider setting it to a fixed size so it doesn’t need to be resized while performing. To configured the paging file: You now need to consider how big the paging file on each drive should be:
Always put the page file on the fastest hard drive. If you have an SSD drive you definitely want to put the swap file on that drive.You generally only need a paging file on one drive however you can get a very small performance increase by using multiple drives.A guideline for the total size of all paging files should be roughly 1.5 times the amount of physical RAM in your computer. E.g.: 4GB Physical RAM = 6GB Paging File.If you have lots of physical RAM (e.g.: > 8GB) you can usually get away with a smaller paging file. E.g.: if you have 32GB RAM it doesn’t much sense to allocate 48GB to the paging file (this might be a considerable fraction of an SSD drive).
Multiple Audio Devices
If you have a dedicated sound card for audio performance its worth disabling the built-in sound device, or other sound cards if you’re not using them. Sound card drivers are notorious for causing DPC latency issues. Also disabling them can also simplify the setup of your audio software since the ability to select these devices will be removed.
LatencyMon
There’s a great, freely available tool for checking ISR and DPC latency issues called LatencyMon. This tool will tell you whether your computer is optimized for optimal input/output audio, and what drivers on your computer are affecting your overall latency.
After you have downloaded LatencyMon: If all the times reported by LatencyMon are less than the amount of headroom then DPCs and ISRs probably aren’t going to be causing you issues. If on the other hand the reported times are longer than the available headroom (or if they’re more than about 500µs (0.5ms), then you should probably take closer look. LatencyMon will show which drivers had the slowest ISR and DPC times.
How to Get the Most out of USB Audio Music Playback on Windows / FoobarFix: Skype Problem with Playback Device on Windows 10FIX: Sounds Playback Menu Pops UP on Windows 10Fix: Video Freezes During Playback on Windows 10