This is how I have set up a virtual microphone on PulseAudio, for usage with skype or something.
It plays what’s normally coming through your microphone, but it can also play music or something else at the same time.
First, some PulseAudio vocabulary:
- Sink: Speakers/other output device
- Source: Microphone/other input device
- Monitor: Essentially creating a source that plays whatever’s coming through it’s associated sink
- Null Sink: A virtual sink that doesn’t interface with the hardware at all
- Loopback Module: Connects a source to a sink
Here’s how we’re going to set this up:
We’re going to create a null sink, called “null0.” Whatever you want to play will be connected to this sink, and this sink will forward it through the system. Next, we’re going to connect null0’s monitor to the speakers with a loopback module, so we can hear it.
Next, we’re going to create another null sink, “null1.” This will be the actual virtual microphone. We’re going to use a loopback module to connect the real micrphone into the virtual one, and antoher loopback module to connect null0 to this one.
Once this is all set up, null1’s monitor will be your virtual microphone, ready for use. To play a sound through the virtual microphone and your speakers, play it through null0. To play it through just the virtual microphone, use null1.
Now, we need to set this all up. Here are the commands to do this:
pactl load-module module-null-sink sink_name=null0 sink_properties=device.description="Speakers_And_Virtual_Microphone" pactl load-module module-null-sink sink_name=null1 sink_properties=device.description="Virtual Microphone" pactl load-module module-loopback sink=null1 source=<YOUR MICRPHONE ID> pactl load-module module-loopback sink=<YOUR SPEAKERS ID> source=null0.monitor pactl load-module module-loopback sink=null1 source=null0.monitor
In order to find your speaker id, use
pactl list sinks and look for the one that you think is your speaker. Look for the name information, and copy/paste that.
Do pretty much the same thing to find the microphone id, but use
pactl list sources instead.
The only thing left is getting programs use the right speaker/microphone. I like to use pavucontrol for that. Your virtual microphone should be “Monitor of Virtual_Microphone,” and the sinks should be “Speakers_And_Virtual_Microphone” and “Virtual_Microphone.”