Collecting and mixing sound input from different microphones

I am able to play sound through two or more outputs/devices using paprefs and adding a virtual output device, as described in this answer: Play sound through two or more outputs/devices

Now I would like to be able to do the same for the input, so basically to collect the sound input from any of the capable devices available and route it, for example, Skype or Slack. It will be very useful for me in large conference rooms, so that I can distribute multiple speaker/mics around in order to have a good sound quality both ways.

Can anybody suggest a solution?


so basically I figured this out myself after a lot of digging on the internet. This is the best answer I found, in another forum, at http://www.pclinuxos.com/forum/index.php/topic,119695.msg905379.html#msg905379

Basically, you will need first to add a fake channel, a "null sink", where the inputs will be collected. We will call it "inputs" and we will create it using this command:

pactl load-module module-null-sink sink_name=inputs

After that, you will need to create as many virtual channels you need for the devices you need to connect, linking that to the "inputs" channel you created before. So please repeat this command for any input you want to mix (and add one if you want to mix also the input of your laptop):

pactl load-module module-loopback sink=inputs

Now you will have to connect this new "loopback" channels to the device you intend to record from. You can do this using "pavucontrol" (install it if missing), open the "Recording" tab, select "Virtual Streams" from the bottom selector and then make sure you connect a different input to each different loopback.

At this point it's just a matter of using your input in your application for recording, and you're all set! Please remember to setup also the output as described in my original question :)

I am happy to receive any better answer too, as this procedure (even if it can be automated) it's still too much error prone and does not automatically includes new devices added later (you will have to setup a new channel and add them again).


Complementing Bruno Bossola answer, the pactl load-module module-loopback accepts another parameter which is source, which can be helpful if we want to automate the process with a single bash script (i.e. avoid the use of pavucontrol GUI everytime).

we can get the name with the following command:

pacmd list-sources | egrep '(^\s+name: .*)|(^\s+device.description = .*)'
output example:
$ pacmd list-sources | egrep '(^\s+name: .*)|(^\s+device.description = .*)'
        name: <alsa_input.hw_0_0>
                device.description = "Built-in Audio"
        name: <alsa_input.usb-046d_C922_Pro_Stream_Webcam_4B17D4DF-02.analog-stereo>
                device.description = "C922 Pro Stream Webcam Analog Stereo"
        name: <alsa_output.pci-0000_00_1f.3.analog-stereo.monitor>
                device.description = "Monitor of Built-in Audio Analog Stereo"
        name: <alsa_input.pci-0000_00_1f.3.analog-stereo>
                device.description = "Built-in Audio Analog Stereo"

lets say we want to combine Monitor of Built-in Audio Analog Stereo (computer audio) with C922 Pro Stream Webcam Analog Stereo (webcam microphone), then our script will be as follows:

#!/bin/bash

if [ "$1" == "-u" ]; then
  pactl unload-module module-loopback
  pactl unload-module module-null-sink
else
  pactl load-module module-null-sink sink_name=combined
  pactl load-module module-loopback source=alsa_input.usb-046d_C922_Pro_Stream_Webcam_4B17D4DF-02.analog-stereo sink=combined
  pactl load-module module-loopback source=alsa_output.pci-0000_00_1f.3.analog-stereo.monitor sink=combined
fi

Basically if -u option is sent when calling the script it will unload everything, otherwise, it will create the null sink and combine the microphone with computer audio into it.