4

I am watching this example of how to add simultaneous mode support to PulseAudio. The example shows how to add just one device which is the hardware's one:

### Load analog device
load-module module-alsa-sink device=hw:0,0
load-module module-combine-sink sink_name=combined
set-default-sink combined

My question is how to add two (or more) devices and how to add virtual devices?

EDIT:


I tried the instruction to combine two sinks:

$pacmd load-module module-combine-sink sink_name=combined2 sink_properties=device.description="Combined with a null sink" slaves=combined,MyTestSink

but I get the error Module load failed. Something's wrong with the syntax or what else can be wrong here? I have the combined and MyTestSink names on in the output of $pacmd list-sinks.

1 Answers1

5

The example looks incomplete. You use the slaves option to add several sinks to the combined sink:

load-module module-combine-sink sink_name=combination-sink sink_properties=device.description=myCombinationSink slaves=sink1,sink2[,...] channels=2

where sink1 etc. are the sinks you want to combine.

Also, usually you don't need to load modules for ALSA hardware, they should be loaded automatically.

Use list-sinks to get a list of available sinks (or use pavucontrol if you prefer a GUI).

Edit

hw:0,0 is an ALSA name for a device. The module-alsa-* modules make ALSA devices available as Pulseaudio sources and sinks. When you use other Pulseaudio modules which refer to existing sources/sinks, you use of course the Pulseaudio names (see pacmd list-sinks etc., without the angular brackets). The ALSA names are not relevant in Pulseaudio.

I'm not sure what you mean by "virtual devices". Pulseaudio has sources and sinks, of various different kinds. Some of those correspond to physical hardware available via ALSA, some of those correspond to streaming audio on the network, some of those correspond to physical Bluetooth devices (not via ALSA), and some of those are neither. Pulseaudio doesn't care what they are, they are just sources and sinks, and none of them is called "virtual".

Edit

Sink names on my system:

$ pacmd list-sinks | grep name:
name: <alsa_output.pci-0000_00_1b.0.analog-stereo>
name: <alsa_output.usb-Roland_UA-25EX-00.analog-stereo>

$ pactl list short sinks
0       alsa_output.pci-0000_00_1b.0.analog-stereo      module-alsa-card.c     s16le 2ch 44100Hz        IDLE
1       alsa_output.usb-Roland_UA-25EX-00.analog-stereo module-alsa-card.c     s16le 2ch 44100Hz        RUNNING

So, on my system:

pacmd load-module module-combine-sink sink_name=combined sink_properties=device.description=CombinedSink slaves=alsa_output.pci-0000_00_1b.0.analog-stereo,alsa_output.usb-Roland_UA-25EX-00.analog-stereo

To repeat: No, you cannot use names like hw:1 for Pulseaudio. These are ALSA names for ALSA devices accessed through ALSA libraries. You can use them in Pulseaudio in exactly one place, namely when an ALSA module (module-alsa-devices or module-aslsa-card) is loaded that makes the ALSA devices available to Pulseaudio. Everywhere else you use the Pulseaudio sink names obtained from the list commands above (or by loading modules that provide sinks like module-null-sink and giving them names).

Edit

I'm not sure what you mean by "absolute name". The name is whatever the module that provides the sink chooses to set. It can often be specified as a parameter when the module is loaded, or it can be chosen by the module when it's not specified, like it is done for the ALSA sinks (using the hardware location) when the modules are loaded by default when Pulseaudio starts. But all this doesn't matter: Just look at what sinks you have, and use the right one. And if you load additional modules, name the sink, if you like.

dirkt
  • 32,309
  • Thank you. It's very interesting. So the slaves=sink0,sink1..sinkN channels=N not sure... what format should I use the hw:0,0 or virtual device name or...? I mean what if I want to combine hardware's (build-in) headphones and virtual devices at the same time to have them simultaneous? what exactly identificators should I use to point to hardware and virtual devices? – user390525 May 13 '18 at 12:01
  • I could see configuration snippet as load-module module-null-sink for example. So can such kind of null sink be included to the simultaneous items list by using the instruction https://wiki.archlinux.org/index.php/PulseAudio/Examples#Simultaneous_HDMI_and_analog_output ? – user390525 May 15 '18 at 23:59
  • No, I mean what id-s should I use in the example you give slaves=sink0,sink1..sinkN channels=N? Should it be sink names or what? And can I have something like this slaves=sink0,hw:1,0..sinkN for example? Give more details please – user390525 May 19 '18 at 21:46
  • Its a bit confusing... So the sink name must be an absolute one? I mean if I have load-module module-null-sink sink_name=myNullSink0 can I use ...sink_properties=device.description="Combined Sink" slaves=myNullSink0... ? Comment please – user390525 May 21 '18 at 20:14
  • OK. Thanks. I'll try the given solution a bit later and report my results here – user390525 May 27 '18 at 11:24
  • I've been thinking... how not to use the pacmd util but the pulseaudio configuration file for this kind of algorithm? – user390525 Jun 07 '18 at 21:15
  • Of course you can also do it via the configuration files. However, I prefer to first try it out directly, because it's easier to change stuff if things don't work. Once it works, I put it in the configuration files. But if you prefer editing the configuration files and reloading Pulseaudio, be my guest. – dirkt Jun 08 '18 at 06:49
  • I tried the instruction to combine two sinks as $pacmd load-module module-combine-sink sink_name=combined2 sink_properties=device.description="Combined with a null sink" slaves=combined,MyTestSink but it throws Module load failed. Something's wrong with the syntax or what can be wrong here? I have the combined and MyTestSink on list-sinks output :S I edited my question please see it – user390525 Jun 11 '18 at 23:39
  • 1
    Hm, I copied this from my notes, and it looks like the quotes and spaces in the description don't work anymore for some reason. Try a device description without spaces and quotes, e.g. sink_properties=device.description=CombinedSink. – dirkt Jun 12 '18 at 03:59
  • OK I guess you right. I replaced the to something like this device.description=Combined_with_a_null_sink with no quotes and spaces. So now I have the module name as combined2 on pactl list short sinks output; So, yes, that was really the syntax issue; But why the syntax get changed from version to version or something? Are there any doc-s about that? – user390525 Jun 13 '18 at 10:36
  • 2
    @user390525 as for using a description that has spaces, see my answer to another question: https://unix.stackexchange.com/a/728602/111181 – jarno Dec 15 '22 at 19:56