Pulseaudio fun

July 21, 2020, 1:51 am

Over the last few months i have customized my pulseaudio configuration, to match my needs. I may have some more advanced requirements, then the usual user, but maybe someone can use some of the stuff i did.

All commands i show here can be added to the pulseaudio configfile /etc/pulse/default.pa by just removing the "pacmd". If you dont add them to that file, the changes you made will only last as long as you do not restart pulseaudio or your system. You may use pulseaudio -k for that.

Finding a Sink

You may need to find the name of your output device. You may use pacmd list-sinks for that. The default audio device is marked with a "*"

Remap Sound

On my Primary soundcard the output is the wrong way around. Most of the time i dont notice, but sometimes it can be confusing or may lead to a death in counterstrike.

So i fixed this with this simple command:

pacmd load-module module-remap-sink master=alsa_output.pci-0000_24_00.0.analog-stereo master_channel_map=front-left,front-right channel_map=front-right,front-left

This adds a new virtual sound device, that redirects the sound to my normal sound device.

Now this new sink can be set as default sink:

set-default-sink alsa_output.pci-0000_24_00.0.analog-stereo.remapped

Of caouse you can also set the default source:

set-default-source alsa_input.pci-0000_24_00.0.analog-mono

Adding a Virtual Source, Sink and connect them

To be able to record a application and listen to it on the sametime, i decided to add a virtual Sink to redirect the sound.

pacmd load-module module-null-sink sink_name=Virtual
pacmd update-sink-proplist Virtual device.description=Virtual
pacmd load-module module-virtual-source source_name=VirtualSource master=Virtual.monitor

The first two lines create a Virtual Sink, the last line adds the monitor of the sink as source, so its basicly a loopback.

Forwording Sound from one Sink to another

Sometimes i want to listen to what i am recording, without interupting the recording. So i added two shortcuts to my system, that execute one of theese commands:

/bin/bash -c 'pacmd load-module module-loopback sink=alsa_output.pci-0000_24_00.0.analog-stereo.remapped source=Virtual.monitor ; notify-send "Sound Forward on" --icon=audio-card'
/bin/bash -c 'pacmd unload-module module-loopback ; notify-send "Sound Forward off" --icon=process-stop'

So i can now enable or disable the Forward functionality with the press of a button.

undo change

You miss spelled a device name? You can just unload a module again with help of these two commands:

pacmd list-modules
pacmd unload-module 23                # unloads module number 23
pacmd unload-module module-loopback   # unloads all loopback modules

With the first command you can see a list with all loaded modules. Pay attention to the index of each module. With that number you can specify which module to unload. But careful, the numbers may change everytime you restart pulseaudio, so i do not recomend hardcoding these numbers anywhere.

Everything fucked up? just restart pulseaudio like mentioned earlier.