Pulseaudio and combining sources

Resources here provide good examples if you want to combined certain devices and not all of them (like using paprefs):

https://unix.stackexchange.com/questions/443013/pulseaudio-simultanious-add-two-devices

My example shell script:

#!/bin/bash

# 8x8 channel mode
#MULTIOUT=alsa_output.usb-BEHRINGER_X-USB_23C8EABF-00.analog-surround-71
#MULTIIN=alsa_input.usb-BEHRINGER_X-USB_23C8EABF-00.analog-surround-71??
# 16x16 or any combination with more than 8
MULTIOUT=alsa_output.usb-BEHRINGER_X-USB_23C8EABF-00.multichannel-output
MULTIIN=alsa_input.usb-BEHRINGER_X-USB_23C8EABF-00.multichannel-input

# 8x8 -> 1:front-left 2:front-right 3:center 4:lfe 5:rear-left 6:rear-right 7:side-left 8:side-right
# 16x16 -> 1:front-left 2:front-right 3:rear-left 4:rear-right 5:center 6:lfe 7:side-left 8:side-right

CH1=front-left
CH2=front-right
#8x8
#CH3=center
#CH4=lfe
#CH5=rear-left
#CH6=rear-right
#16x16
CH3=rear-left
CH4=rear-right
CH5=center
CH6=lfe
CH7=side-left
CH8=side-right
CH9=aux0
CH10=aux1
CH11=aux2
CH12=aux3
CH13=aux4
CH14=aux5
CH15=aux6
CH16=aux7
# aux8, aux9, ... auxN

#Create virtual outputs to multi-channel sound card
pacmd unload-module module-remap-sink
sleep 1
#echo CH1_2
pacmd load-module module-remap-sink\
channels=2\
sink_name=CH1_2\
sink_properties=device.description=CH25_26\
remix=no\
master=${MULTIOUT}\
master_channel_map=${CH1},${CH2}\
channel_map=front-left,front-right

pacmd load-module module-remap-sink\
channels=2\
sink_name=CH3_4\
sink_properties=device.description=CH27_28\
remix=no\
master=${MULTIOUT}\
master_channel_map=${CH3},${CH4}\
channel_map=front-left,front-right

pacmd load-module module-remap-sink\
channels=1\
sink_name=CH5\
sink_properties=device.description=CH29\
remix=no master=$MULTIOUT\
master_channel_map=${CH5}\
channel_map=mono

pacmd load-module module-remap-sink\
channels=1\
sink_name=CH6\
sink_properties=device.description=CH30\
remix=no\
master=${MULTIOUT}\
master_channel_map=${CH6}\
channel_map=mono

#Create virtual input from multi-channel sound card
pacmd unload-module module-remap-source
sleep 1
pacmd load-module module-remap-source\
channels=2\
source_name=LR\
source_properties=device.description=LR\
remix=no\
master=${MULTIIN}\
master_channel_map=${CH1},${CH2}\
channel_map=front-left,front-right

pacmd load-module module-remap-source\
channels=2\
source_name=Rec\
source_properties=device.description=Rec\
remix=no\
master=${MULTIIN}\
master_channel_map=${CH3},${CH4}\
channel_map=front-left,front-right

pacmd load-module module-remap-source\
channels=1\
source_name=Discord\
source_properties=device.description=Discord\
remix=no\
master=${MULTIIN}\
master_channel_map=${CH5}\
channel_map=mono

#create virtual sound card to "combine" output devices
pacmd unload-module module-combine-sink
sleep 1

pacmd load-module module-combine-sink\
sink_name=BI_CH29_30\
sink_properties=device.description=BuiltIn+CH25_26\
adjust_time=2\
slaves=alsa_output.pci-0000_00_1f.3.analog-stereo,CH1_2

echo "###########sinks#############"
pactl list sinks short
echo "##########sources############"
pactl list sources short

After running the script above, can simple assign outputs to different channels on X32, XR18 or any multi-channel USB hardware:

Tags: