Audio latency
In QJackCtl's setup dialog, there are two params that affect audio latency:
- Frames/period
- Periods/buffer
If the sample rate is 44,100 Hz, then a frame takes 1/44,100 seconds. So, how long does it take to get a frame through the computer?
If frames/period is 1024 and periods/buffer is 2, each buffer carries 1024 * 2 frames. That's 2048 frames. Since each frame takes 1/44,100 seconds, the buffer takes 2048/44,100 seconds = 46.44 ms to process.
TODO: What is involved in processing exactly, though?
So, sound input goes in, then at least 46.44 ms later, something comes out.
That's kind of a lot! If you are playing a guitar into your computer, then having an amp modeler process it and send it back out, you may notice a delay which will throw you off. I read that every 10ms of latency corresponds with being ~10 feet further from an analog source. So, 10ms is acceptable for me.
When I set frames/period to 128 and frames/period to 2 to get a latency of 5.8 msec, I started getting xruns when using Guitarix. The computer was not keeping up with the incoming buffers, so it'd dump zeroes to the output, which sound like pops in the output.
I found out that my computer, by default, dynamically slows down the CPU to save power, which causes latency issues.
I was getting pops in my guitar amp modeler (and sometimes in pd), and that seemed to take care of it.
I was clued in by the install script for Ardour, which said this:
!!! WARNING !!! - Your system seems to use frequency scaling.
This can have a serious impact on audio latency.
For best results turn it off, e.g. by chosing the ‘performance’ governor.”
So, even though that app crashes when I try to create a project in it, I'm thankful to it.
There's this indicator-cpufreq
package you can install, which puts a thing in the system menu bar to turn that off!
sudo apt-get install indicator-cpufreq
When I turn set the governor to "Performance" via that applet, I don't get the pops anymore.
#cpu #frequencyscaling #audio #ubuntu #jack