Knowledge Base

Preserving for the future: Shell scripts, AoC, and more

Listen to your own microphone in pulseaudio

Recently I wanted to pipe my mic input to my headphones (in addition to sending it on to Discord). I learned how to listen to my line-in input with pulseaudio. This is a direct ripoff of https://thelinuxexperiment.com/pulseaudio-monitoring-your-line-in- interface/. You need to know the names of your sources (inputs) and sinks (outputs) that pulseaudio uses.

pacmd list-source-outputs | grep 'source:'
pacmd list-sink-inputs | grep 'sink:'

But my tab autocompletion worked, so the above steps may not be entirely necessary if you have a simple setup like me. So now you can run pacat and pipe the input to the output.

pacat -r --latency-msec=1 -d alsa_input.pci-0000_00_1b.0.analog-stereo | pacat -p --latency-msec=1 -d alsa_output.pci-0000_00_1b.0.analog-stereo

Another way to do it, but it incurs a terrible delay:

pactl load-module module-loopback
pactl unload-module module-loopback

And actually, the pacat with the 1-millisecond delay because untenable after enough time because its 1ms delay adds up over time. It might be worth scripting killing that every 10 minutes and starting a new pacat process pair.

Comments