Pulseaudio Microphone Loopback (Listen While Recording)

Before the tomatoes come flying my way, I quite like Pulseaudio and think it’s done a lot of nice things for the “user experience” of many Linux desktops. That being said, I got a new headset today that features two 3.5mm audio jacks: one for the headphones, the other for included boom microphone. However, when plugging in said device and using it with the headphones on, I find it rather difficult to use VoIP applications (like Teamspeak) when I can’t hear my own voice (narcissistic, right?). I lose track of what I’m saying when everything is all muffled. So, what’s needed is a microphone loopback, so I can hear myself through the headphones while I’m talking. To give credit where it’s due, I found the pieces for this at this link, but to remove the microphone loopback, it wants you to manually look up the module index number and then use a command to unload it. I’m lazy, so I dumped this into two executable files in /usr/local/bin.

First, a file called “loadmicloop”, that has a single line in it:

pactl load-module module-loopback latency_msec=1

Secondly, a file called “unloadmicloop”, that also has a single line in it:

pactl unload-module $(pactl list short | grep latency_msec=1 | awk '{print $1}')

The first one is pretty obvious: it tells pactl to load the loopback module with a 1 milisecond latency. The second one passes the results of a grep and awk of the short list of loaded Pulseaudio modules that’s been sliced to only be the index number of the looback module. That module number is then unloaded by “pactl unload-module”. This is handy, as I wouldn’t want it on all the time, and it’d be great to see that in future versions of the sound control panel for microphones, perhaps as a simple toggle on and off.

In all reality I should probably give this 10 more minutes and make the two commands “on” and “off” parameters to one executable, but, as mentioned, I’m lazy and it works for a dirty hack.

Did you find this article useful? Pass it on!
  1. Sweet, nice to know how to get the loopback/monitoring to fully with a command.

Leave a Comment