Problems with PulseAudio config

Still new to all of this? Feel free to post in any of the subforums on this site, but in this subforum newbie questions are especially encouraged!

Moderators: MattKingUSA, khz

Post Reply
billyjoepiano
Posts: 1
Joined: Mon Dec 11, 2023 10:00 pm

Problems with PulseAudio config

Post by billyjoepiano »

I am trying to play two stereo channels with different (but synchronized) outputs -- a stereo backing track on one output (PreSonus Audiobox, via USB) with a click track on the other (in-built headphone jack for the laptop).

After much struggle figuring out the correct configuration, I was able to get this setup working yesterday. It is basically like a surround-sound 4.0 setup, mapped through two stereo outputs, as described here: https://www.freedesktop.org/wiki/Softwa ... dsoundcard

Code: Select all

pacmd load-module module-alsa-sink device=hw:PCH sink_name=rearSink channel_map=rear-left,rear-right channels=2 sink_properties=device.description=RearSink

pacmd load-module module-combine-sink sink_name=combinedSink slaves=alsa_output.usb-PreSonus_AudioBox_USB_96_000000000000-00.iec958-stereo,rearSink channel_map=front-left,front-right,rear-left,rear-right channels=4 remix=no sink_properties=device.description=Combined4Channel

One thing to note is that I had to run this from the command line, because if I tried to include in default.pa (either in ~/.config/pulseaudio or /etc/pulseaudio) it would not work and I'd see an error message logged in systemctl --user status pulseaudio.service. I found that I needed to wait about 15-30 seconds after the pulseaudio.service daemon started before these commands would work and actually created the sinks successfully.

I had this working successful for several hours yesterday, including after several reboots and tweaks.

However, today this setup doesn't want to work at all. Both the default headphones sink and the "rearSink" output to the PreSonus when they are selected, before I create the combinedSink but then nothing comes out of the rear when the combinedSink is created and selected (or when the rearSink itself is selected, after combinedSink is created). Sometimes, the default headphones and rearSink, when selected, output nothing at all, usually after the combinedSink is created.

I've been trying every which way of doing this... several restarts, checking (and not checking) where audio comes out from different selected devices in the Gnome setup at each step... but no luck.

The system will often freeze up when testing the audio outputs after the custom configurations are made, and the only way to get it unfrozen is to try to get to a terminal and run kill -9 on the pulseaudio process (regular kill and systemctl --user stop pulseaudio.service don't seem to make any difference when that happens)

Here is the output of pacmd list-sinks before any of the custom configurations are enabled:

Code: Select all

2 sink(s) available.
  * index: 0
	name: <alsa_output.usb-PreSonus_AudioBox_USB_96_000000000000-00.iec958-stereo>
	driver: <module-alsa-card.c>
	flags: HARDWARE DECIBEL_VOLUME LATENCY DYNAMIC_LATENCY
	state: SUSPENDED
	suspend cause: IDLE
	priority: 9047
	volume: front-left: 35359 /  54% / -16.08 dB,   front-right: 35359 /  54% / -16.08 dB
	        balance 0.00
	base volume: 65536 / 100% / 0.00 dB
	volume steps: 65537
	muted: no
	current latency: 0.00 ms
	max request: 0 KiB
	max rewind: 0 KiB
	monitor source: 0
	sample spec: s32le 2ch 44100Hz
	channel map: front-left,front-right
	             Stereo
	used by: 0
	linked by: 0
	configured latency: 0.00 ms; range is 0.50 .. 2000.00 ms
	card: 1 <alsa_card.usb-PreSonus_AudioBox_USB_96_000000000000-00>
	module: 8
	properties:
		alsa.resolution_bits = "32"
		device.api = "alsa"
		device.class = "sound"
		alsa.class = "generic"
		alsa.subclass = "generic-mix"
		alsa.name = "USB Audio"
		alsa.id = "USB Audio"
		alsa.subdevice = "0"
		alsa.subdevice_name = "subdevice #0"
		alsa.device = "0"
		alsa.card = "2"
		alsa.card_name = "AudioBox USB 96"
		alsa.long_card_name = "PreSonus AudioBox USB 96 at usb-0000:00:14.0-2, high speed"
		alsa.driver_name = "snd_usb_audio"
		device.bus_path = "pci-0000:00:14.0-usb-0:2:1.0"
		sysfs.path = "/devices/pci0000:00/0000:00:14.0/usb3/3-2/3-2:1.0/sound/card2"
		udev.id = "usb-PreSonus_AudioBox_USB_96_000000000000-00"
		device.bus = "usb"
		device.vendor.id = "194f"
		device.vendor.name = "PreSonus Audio Electronics, Inc."
		device.product.id = "0303"
		device.product.name = "AudioBox USB 96"
		device.serial = "PreSonus_AudioBox_USB_96_000000000000"
		device.string = "iec958:2"
		device.buffering.buffer_size = "705600"
		device.buffering.fragment_size = "352800"
		device.access_mode = "mmap+timer"
		device.profile.name = "iec958-stereo"
		device.profile.description = "Digital Stereo (IEC958)"
		device.description = "AudioBox USB 96 Digital Stereo (IEC958)"
		module-udev-detect.discovered = "1"
		device.icon_name = "audio-card-usb"
	ports:
		iec958-stereo-output: Digital Output (S/PDIF) (priority 0, latency offset 0 usec, available: unknown)
			properties:
				
	active port: <iec958-stereo-output>
    index: 1
	name: <alsa_output.pci-0000_00_1b.0.analog-stereo>
	driver: <module-alsa-card.c>
	flags: HARDWARE HW_MUTE_CTRL HW_VOLUME_CTRL DECIBEL_VOLUME LATENCY DYNAMIC_LATENCY
	state: SUSPENDED
	suspend cause: IDLE
	priority: 9039
	volume: front-left: 65536 / 100% / 0.00 dB,   front-right: 65536 / 100% / 0.00 dB
	        balance 0.00
	base volume: 52057 /  79% / -6.00 dB
	volume steps: 65537
	muted: no
	current latency: 0.00 ms
	max request: 0 KiB
	max rewind: 0 KiB
	monitor source: 2
	sample spec: s16le 2ch 44100Hz
	channel map: front-left,front-right
	             Stereo
	used by: 0
	linked by: 0
	configured latency: 0.00 ms; range is 0.50 .. 2000.00 ms
	card: 2 <alsa_card.pci-0000_00_1b.0>
	module: 9
	properties:
		alsa.resolution_bits = "16"
		device.api = "alsa"
		device.class = "sound"
		alsa.class = "generic"
		alsa.subclass = "generic-mix"
		alsa.name = "CS4206 Analog"
		alsa.id = "CS4206 Analog"
		alsa.subdevice = "0"
		alsa.subdevice_name = "subdevice #0"
		alsa.device = "0"
		alsa.card = "0"
		alsa.card_name = "HDA Intel PCH"
		alsa.long_card_name = "HDA Intel PCH at 0xc1c10000 irq 52"
		alsa.driver_name = "snd_hda_intel"
		device.bus_path = "pci-0000:00:1b.0"
		sysfs.path = "/devices/pci0000:00/0000:00:1b.0/sound/card0"
		device.bus = "pci"
		device.vendor.id = "8086"
		device.vendor.name = "Intel Corporation"
		device.product.id = "1e20"
		device.product.name = "7 Series/C216 Chipset Family High Definition Audio Controller"
		device.form_factor = "internal"
		device.string = "front:0"
		device.buffering.buffer_size = "352800"
		device.buffering.fragment_size = "176400"
		device.access_mode = "mmap+timer"
		device.profile.name = "analog-stereo"
		device.profile.description = "Analog Stereo"
		device.description = "Built-in Audio Analog Stereo"
		module-udev-detect.discovered = "1"
		device.icon_name = "audio-card-pci"
	ports:
		analog-output-speaker: Speakers (priority 10000, latency offset 0 usec, available: no)
			properties:
				device.icon_name = "audio-speakers"
		analog-output-headphones: Headphones (priority 9900, latency offset 0 usec, available: yes)
			properties:
				device.icon_name = "audio-headphones"
	active port: <analog-output-headphones>

Here is the output of cat /proc/asound/cards:

Code: Select all

 0 [PCH            ]: HDA-Intel - HDA Intel PCH
                      HDA Intel PCH at 0xc1c10000 irq 52
 1 [NVidia         ]: HDA-Intel - HDA NVidia
                      HDA NVidia at 0xc1080000 irq 17
 2 [A96            ]: USB-Audio - AudioBox USB 96
                      PreSonus AudioBox USB 96 at usb-0000:00:14.0-2, high speed

And here is the output of pacmd list-sinks after adding my custom configuration from the command line

Code: Select all

4 sink(s) available.
  * index: 0
	name: <alsa_output.usb-PreSonus_AudioBox_USB_96_000000000000-00.iec958-stereo>
	driver: <module-alsa-card.c>
	flags: HARDWARE DECIBEL_VOLUME LATENCY DYNAMIC_LATENCY
	state: RUNNING
	suspend cause: (none)
	priority: 9047
	volume: front-left: 35359 /  54% / -16.08 dB,   front-right: 35359 /  54% / -16.08 dB
	        balance 0.00
	base volume: 65536 / 100% / 0.00 dB
	volume steps: 65537
	muted: no
	current latency: 209.18 ms
	max request: 68 KiB
	max rewind: 68 KiB
	monitor source: 0
	sample spec: s32le 2ch 44100Hz
	channel map: front-left,front-right
	             Stereo
	used by: 1
	linked by: 1
	configured latency: 200.00 ms; range is 0.50 .. 2000.00 ms
	card: 1 <alsa_card.usb-PreSonus_AudioBox_USB_96_000000000000-00>
	module: 8
	properties:
		alsa.resolution_bits = "32"
		device.api = "alsa"
		device.class = "sound"
		alsa.class = "generic"
		alsa.subclass = "generic-mix"
		alsa.name = "USB Audio"
		alsa.id = "USB Audio"
		alsa.subdevice = "0"
		alsa.subdevice_name = "subdevice #0"
		alsa.device = "0"
		alsa.card = "2"
		alsa.card_name = "AudioBox USB 96"
		alsa.long_card_name = "PreSonus AudioBox USB 96 at usb-0000:00:14.0-2, high speed"
		alsa.driver_name = "snd_usb_audio"
		device.bus_path = "pci-0000:00:14.0-usb-0:2:1.0"
		sysfs.path = "/devices/pci0000:00/0000:00:14.0/usb3/3-2/3-2:1.0/sound/card2"
		udev.id = "usb-PreSonus_AudioBox_USB_96_000000000000-00"
		device.bus = "usb"
		device.vendor.id = "194f"
		device.vendor.name = "PreSonus Audio Electronics, Inc."
		device.product.id = "0303"
		device.product.name = "AudioBox USB 96"
		device.serial = "PreSonus_AudioBox_USB_96_000000000000"
		device.string = "iec958:2"
		device.buffering.buffer_size = "705600"
		device.buffering.fragment_size = "352800"
		device.access_mode = "mmap+timer"
		device.profile.name = "iec958-stereo"
		device.profile.description = "Digital Stereo (IEC958)"
		device.description = "AudioBox USB 96 Digital Stereo (IEC958)"
		module-udev-detect.discovered = "1"
		device.icon_name = "audio-card-usb"
	ports:
		iec958-stereo-output: Digital Output (S/PDIF) (priority 0, latency offset 0 usec, available: unknown)
			properties:
				
	active port: <iec958-stereo-output>
    index: 1
	name: <alsa_output.pci-0000_00_1b.0.analog-stereo>
	driver: <module-alsa-card.c>
	flags: HARDWARE HW_MUTE_CTRL HW_VOLUME_CTRL DECIBEL_VOLUME LATENCY DYNAMIC_LATENCY
	state: SUSPENDED
	suspend cause: IDLE
	priority: 9039
	volume: front-left: 65536 / 100% / 0.00 dB,   front-right: 65536 / 100% / 0.00 dB
	        balance 0.00
	base volume: 52057 /  79% / -6.00 dB
	volume steps: 65537
	muted: no
	current latency: 0.00 ms
	max request: 0 KiB
	max rewind: 0 KiB
	monitor source: 2
	sample spec: s16le 2ch 44100Hz
	channel map: front-left,front-right
	             Stereo
	used by: 0
	linked by: 0
	configured latency: 0.00 ms; range is 0.50 .. 2000.00 ms
	card: 2 <alsa_card.pci-0000_00_1b.0>
	module: 9
	properties:
		alsa.resolution_bits = "16"
		device.api = "alsa"
		device.class = "sound"
		alsa.class = "generic"
		alsa.subclass = "generic-mix"
		alsa.name = "CS4206 Analog"
		alsa.id = "CS4206 Analog"
		alsa.subdevice = "0"
		alsa.subdevice_name = "subdevice #0"
		alsa.device = "0"
		alsa.card = "0"
		alsa.card_name = "HDA Intel PCH"
		alsa.long_card_name = "HDA Intel PCH at 0xc1c10000 irq 52"
		alsa.driver_name = "snd_hda_intel"
		device.bus_path = "pci-0000:00:1b.0"
		sysfs.path = "/devices/pci0000:00/0000:00:1b.0/sound/card0"
		device.bus = "pci"
		device.vendor.id = "8086"
		device.vendor.name = "Intel Corporation"
		device.product.id = "1e20"
		device.product.name = "7 Series/C216 Chipset Family High Definition Audio Controller"
		device.form_factor = "internal"
		device.string = "front:0"
		device.buffering.buffer_size = "352800"
		device.buffering.fragment_size = "176400"
		device.access_mode = "mmap+timer"
		device.profile.name = "analog-stereo"
		device.profile.description = "Analog Stereo"
		device.description = "Built-in Audio Analog Stereo"
		module-udev-detect.discovered = "1"
		device.icon_name = "audio-card-pci"
	ports:
		analog-output-speaker: Speakers (priority 10000, latency offset 0 usec, available: no)
			properties:
				device.icon_name = "audio-speakers"
		analog-output-headphones: Headphones (priority 9900, latency offset 0 usec, available: yes)
			properties:
				device.icon_name = "audio-headphones"
	active port: <analog-output-headphones>
    index: 2
	name: <rearSink>
	driver: <module-alsa-sink.c>
	flags: HARDWARE DECIBEL_VOLUME LATENCY DYNAMIC_LATENCY
	state: RUNNING
	suspend cause: (none)
	priority: 9030
	volume: rear-left: 16853 /  26% / -35.39 dB,   rear-right: 16853 /  26% / -35.39 dB
	        balance 0.00
	base volume: 65536 / 100% / 0.00 dB
	volume steps: 65537
	muted: no
	current latency: 199.70 ms
	max request: 34 KiB
	max rewind: 34 KiB
	monitor source: 4
	sample spec: s16le 2ch 44100Hz
	channel map: rear-left,rear-right
	used by: 1
	linked by: 1
	configured latency: 200.00 ms; range is 0.50 .. 2000.00 ms
	module: 25
	properties:
		alsa.resolution_bits = "16"
		device.api = "alsa"
		device.class = "sound"
		alsa.class = "generic"
		alsa.subclass = "generic-mix"
		alsa.name = "CS4206 Analog"
		alsa.id = "CS4206 Analog"
		alsa.subdevice = "0"
		alsa.subdevice_name = "subdevice #0"
		alsa.device = "0"
		alsa.card = "0"
		alsa.card_name = "HDA Intel PCH"
		alsa.long_card_name = "HDA Intel PCH at 0xc1c10000 irq 52"
		alsa.driver_name = "snd_hda_intel"
		device.bus_path = "pci-0000:00:1b.0"
		sysfs.path = "/devices/pci0000:00/0000:00:1b.0/sound/card0"
		device.bus = "pci"
		device.vendor.id = "8086"
		device.vendor.name = "Intel Corporation"
		device.product.id = "1e20"
		device.product.name = "7 Series/C216 Chipset Family High Definition Audio Controller"
		device.form_factor = "internal"
		device.string = "hw:PCH"
		device.buffering.buffer_size = "352800"
		device.buffering.fragment_size = "176400"
		device.access_mode = "mmap+timer"
		device.description = "RearSink"
		device.icon_name = "audio-card-pci"
    index: 3
	name: <combinedSink>
	driver: <module-combine-sink.c>
	flags: DECIBEL_VOLUME LATENCY DYNAMIC_LATENCY
	state: IDLE
	suspend cause: (none)
	priority: 1000
	volume: front-left: 26388 /  40% / -23.70 dB,   front-right: 26388 /  40% / -23.70 dB,   rear-left: 26388 /  40% / -23.70 dB,   rear-right: 26388 /  40% / -23.70 dB
	        balance 0.00
	base volume: 65536 / 100% / 0.00 dB
	volume steps: 65537
	muted: no
	current latency: 0.00 ms
	max request: 68 KiB
	max rewind: 0 KiB
	monitor source: 5
	sample spec: s16le 4ch 44100Hz
	channel map: front-left,front-right,rear-left,rear-right
	             Surround 4.0
	used by: 0
	linked by: 0
	configured latency: 200.00 ms; range is 0.50 .. 200.00 ms
	module: 26
	properties:
		device.class = "filter"
		combine.slaves = "alsa_output.usb-PreSonus_AudioBox_USB_96_000000000000-00.iec958-stereo,rearSink"
		device.description = "Combined4Channel"
		device.icon_name = "audio-card"

Note that I am running Ubuntu desktop 22.04 on a 2011 MacBook Pro. AudioPulse version is 15.99. And yes, I know the link at the top says you need version 16 for the "remix=no" flag to work, but the module description in this version says that it supports it, and it was working fine yesterday. I had to upgrade from 20.04 to 22.04 just to get 15.99. I've thought that perhaps the next step is trying to build 16.1 from source code...?

User avatar
nikgnomicradio
Established Member
Posts: 109
Joined: Wed Feb 07, 2018 9:31 pm
Has thanked: 1 time
Been thanked: 7 times
Contact:

Re: Problems with PulseAudio config

Post by nikgnomicradio »

I switched from Xubuntu to Manjaro in 2015 because they were 12 months behind on PulseAudio.
(IIRC Ubuntu was still using v5.0 when I had v8.0)

PulseAudio 16.1 has a bugfix for module-combine-sink:

https://gitlab.freedesktop.org/pulseaud ... ases/v16.1

Fix frequent crashing in module-combine-sink, regression in 16.0

(Latest PulseAudio has a new module module-virtual-sink that may be useful for this, but no online documentation for this module)

Also suggest you consider building PulseAudio Graph Control to see how the PulseAudio modules interact

Keep PulseAudio system configuration /etc/pulse/default.pa unmodified and create a custom configuration in home folder, adding extra modules in simple steps

Code: Select all

cp /etc/pulse/default.pa  ~/.config/pulse/default.pa

Open ~/.config/pulse/default.pa in a text editor and replace all the configuration for module-udev-detect and module-detect:

Code: Select all

### Automatically load driver modules depending on the hardware available
.ifexists module-udev-detect.so
load-module module-udev-detect
.else
### Use the static hardware detection module (for systems that lack udev support)
load-module module-detect

with 2 static sinks:

Code: Select all

load-module module-alsa-sink device=hw:PCH,0 sink_name=SinkA
.nofail
load-module module-alsa-sink device=hw:A96,0 sink_name=SinkB
.fail

(.nofail will prevent PulseAudio crashing if the USB device is not plugged in or available)

Save configuration changes, restart pulseaudio and check if both sinks are loaded

Code: Select all

systemctl --user restart pulseaudio; pacmd dump

If both sinks are working ok, add module-combine-sink at the end of the configuration file after a .nofail:

Code: Select all

.nofail
load-module module-combine-sink sink_name=combinedSink slaves=SinkA,SinkB channels=2 remix=no

Save configuration changes, restart pulseaudio and check if 3 sinks are loaded and working as expected

For the final part of remapping sinks it might be better to use module-remap-sink instead of remapping sinkA

Code: Select all

.nofail
load-module module-remap-sink sink_name=RearSink master=SinkA channels=2 master_channel_map=rear-left,rear-right channel_map=front-left,front-right remix=no
load-module module-combine-sink sink_name=combinedSink slaves=SinkB,rearSink channels=4 remix=no channel_map=front-left,front-right,rear-left,rear-right

I have never had good results when trying to remap sinks so I am not confident about the last part working
I am also not sure the 2 different devices will remain synchronised even if the reconfiguration works as expected. I only have experience of reconfiguring audio devices on desktop systems to use 2 independent stereo outputs on the same device

Post Reply