Create a new pipewire virtual device that to combines an real input and output into a new input

audiolinuxmicrophonepipewire

My problem is this: I'm talking to some friends via voice chat and at some point I'd also like to mix some music into it. So my current setup is this:

Microphone (Input device) -> Voice software
Music player -> Headphones (Output device)

I'd like to have this:

Music player -> Headphones

Music player -\
               -> ? -> Voice software
Microphone   -/

I've had a look at the Pipewire wiki quite a bit and especially the part about Virtual-Devices seemed to be very relevant but after playing around with a lot of pw-loopback I eventually gave up.

In the end, I think I'll need to end up with a virtual input device so that it's even selectable in my recording applications.

Is this even the right approach?

Best Answer

If you want to mix your voice input (mic) and the output of music player, then the setup would be like this:

Music player -\
               -> Combined Sink/Source -> Virtual Microphone -> Voice software
Microphone   -/

Here is the walktrough:

1. Create the combined-sink interface

pactl load-module module-null-sink media.class=Audio/Sink sink_name=my-combined-sink channel_map=stereo

2. Create a Virtual Microphone

pactl load-module module-null-sink media.class=Audio/Source/Virtual sink_name=my-virtualmic channel_map=front-left,front-right

3. Link your microphone & the music player output into the combined sink

Note: The microphone interface name & the music player output interface name may be different. Run pw-link -o to show list of the outputs.

pw-link spotify:output_FL my-combined-sink:playback_FL
pw-link spotify:output_FR my-combined-sink:playback_FR

pw-link alsa_input.pci-0000_00_1f.3.analog-stereo:capture_FL  my-combined-sink:playback_FL
pw-link alsa_input.pci-0000_00_1f.3.analog-stereo:capture_FR  my-combined-sink:playback_FR

4. Link your combined sink to the virtual microphone

pw-link my-combined-sink:monitor_FL my-virtualmic:input_FL
pw-link my-combined-sink:monitor_FR my-virtualmic:input_FR

Now you can tell the voice software to make use this virtual microphone or set the virtual microphone as the default voice input.

Related Question