How to create a virtual audio output and route it in Ubuntu-based distro
I am on elementaryOS 0.4.1 Loki, which is based on Ubuntu 16.04.1.
I want to use OBS, a screen recorder, to record gameplay along with the sounds that come from the same video game. I also want to use a voice chat application in the background while playing the game, but I do not want any of it recorded by OBS.
OBS can’t selectively ignore the audio of certain programs, but it can record sound from a specified input device.
I want to create a virtual input and use pavucontrol’s output list to route my voice chat application to that input so it’s not picked up by OBS. At the same time, I want this input to play back to a headphone/line out port.
I know this can be done in Windows with software such as Virtual Audio Cables, but I don’t know how to do the same thing in Linux.
I already attempted to do something with sudo modprobe snd-dummy but it doesn’t let me route the dummy to a headphone output.
How should I approach this?
Let me repeat: A single program or group of programs A (game) should output sound both to OBS and the headphone, while another single program or group of programs B (voice chat) should only output sound to the headphone, all on the Pulseaudio level. Correct?
snd-dummy, it works on the ALSA level. Instead, create a “null sink” on the Pulseaudio level:
pacmd load-module module-null-sink sink_name=game_sink sink_properties=device.description=Game-Sink
pavucontrol or, if it can do that, the sound configuration of elementary OS to switch all group A sound outputs to that sink. Each sink in Pulseaudio comes with a corresponding “monitor” source (you can see those in the OBS menu you included), so setup OBS to record from “Monitor of Game Sink”.
That takes care of recording from group A only, but doesn’t output it to the headphones. For that, you need a loopback from the mentioned monitor source to the headphone sink:
pacmd load-module module-loopback source="game_sink.monitor" sink="your-headphone-sink"
You can find out the names of all sinks, including the headphone sink, with
pacmd list-sinks | grep name:
Leave out the angular brackets when using the names as arguments.