Fix PulseAudio loopback delay
Sort of a follow up (in spirit) to two of Jon’s previous posts regarding pulse audio loopback; I noticed that there was quite a bit of delay (~500ms to 1second) in the default configuration and began searching for a way to fix it. After some research I found an alternative way to achieve the loopback but with must less delay.
1. Install paman
First install the PulseAudio Manager application so that you can correctly identify the input device (i.e. your mic or line-in) and your output device (i.e. the sound card you are using).
sudo apt-get install paman
You can find the input sources under the Sources section and the output devices under the Sinks section of the Devices tab. Make note of the names of the two devices.
2. Unload any previous loopback modules
If you had followed Jon’s previous posts then you will need to unload the modules (and potentially change your PulseAudio configuration so they don’t get loaded again on next restart). This is to stop it from doubling all loopback sound.
3. Create an executable script
Create a script and copy the following command into it:
pacat -r --latency-msec=1 -d [input] | pacat -p --latency-msec=1 -d [output]
where [input] is the name of your input device found in step 1 and [output] is the name of the output device. In my case it would look like:
pacat -r --latency-msec=1 -d alsa_input.pci-0000_05_02.0.analog-stereo | pacat -p --latency-msec=1 -d alsa_output.pci-0000_05_02.0.analog-surround-51
4. Run script
By simply running the script now you should get correct loopback and with much less delay than using the default loopback module. Even better if you set this script to run at startup you won’t have to worry about it ever again.
Previously I was running KDE 4.3.3 on top of Fedora 11 (for the first experiment) and KDE 4.6.5 on top of Gentoo (for the second experiment).
Check out my profile for more information.
Visit my personal website at http://www.tylerburton.ca.


Thank you very much. I was searching a solution for this problem some time ago. Works really fine.
This worked perfectly to eliminate the .25-.5 second audio sync delay when playing video.
# cat .pulse/default.pa
.include /etc/pulse/default.pa
load-module module-loopback latency_msec=80
… doesn’t anyone consult the manual these days?
no need for root; this method is likely to pound on your machine HARD … esp at 1msec … most humans will not detect lag until it approaches or exceeds 100msec.
I also use pacat in the way described on this page with tvtime, but I’ve found that there are still cases where latency is introduced if the play pacat instance gets behind. Once it gets behind it stays behind. To address this problem I’ve made a modification to pacat. The details are on my site:
http://selliott.org/node/59
C Anthony,
I find that module-loopback still occasionally has unreasonable latency even if a low latency_msec is specified.
I’ve refined my patch a bit and added another one. I’ve mentioned my patches on the pulseaudio mailing list:
http://lists.freedesktop.org/archives/pulseaudio-discuss/2012-May/013588.html
But the consensus sees to be that the problem should be fixed in tvtime. I can’t say I blame them, but anyone who is still experiencing latency with the pacat solution mentioned in this post are welcome to try my patches. They are named “pacat-drain-experimental.diff” and “pulseaudio-limited-watermark-experimental.diff”. You can read more about them here:
http://selliott.org/node/59
I’m happy to receive feedback.
hell yeah, dude
Alright, how do I unload the modules and change the config so that they don’t get loaded again on restart?
Also, what do you mean by “create an executable script”?
You can create an executable script by making a new text file and placing this as the first line:
#!/bin/sh
(terminal commands go here)
Then mark the file as executable by issuing the command
chmod +x myscript
Now you can run it like a normal program
./myscript
This can rape your machine as C Anthony said. If you simply want line in playback, you should just install alsa-utils, type alsamixer -c 0 (or 1 test to find your sound card), and look for the input playback selector, (the only one without a volume slider) to choose your input device. Also don’t forget to raise the line in’s playback volume.