Sound to multiple output devices with pulse?

Is it possible to output one playback stream to multiple devices simultaneously with the current PulseAudio / Phonon setup?

The PulseAudio mixer only has radio buttons to choose one device per playback stream. I believe the hardware is capable of this, since I remember doing that before we had PulseAudio. How can I duplicate an audio stream?

Here’s one application scenario: I am travelling with my family, all crammed in small hotel room. My wife and me want to watch a movie on my laptop without waking up our kids. I just happen to have one analogue headphone available and one wireless USB headset with me. (Of course, the low tech solution is to bring an 3,5mm Y-cable to attach two analogue headsets, but I would really love to use the USB headset together with the analogue one.)

Another similar thing that bugs me is that my laptop’s built-in speakers now always seem dead when an analogue headphone is plugged in. This is mostly what one wants, and before PulseAudio, one had to manually switch them off which was generally annoying. However, the downside is for example with notifications. For example, before PulseAudio, I could configure Skype to always ring over the laptop’s built-in speakers, regardless of whether the analogue headphones were plugged in. This is no longer possible, since PulseAudio does not distinguish between built-in speakers and built-in analogue port any more, while old Alsa did. So in my office, where some analogue headphones are plugged into the docking station, I never hear Skype ringing if I don’t wear the headphones.

Don’t get me wrong: I love PulseAudio in general and don’t want to switch back, these are just two rare scenarios that I regret being lost.

PS:
I should add that I tried paprefs -> simultaneous output and ticked the checkbox there to “create virtual device for output on all devices”. However, even after a restart of the entire machine, I notice no difference in Kmix, Phonon nor pavucontrol. paprefs remembered the settings, but I cannot see any effect (likewise for network sound and multicast).

I am on KDE, btw.

Is it possible ? Yes. It is possible.

Pulse allows one to play multiple streams to one output device, or to multiple output devices directed as one wishes to each or more output devices. Pulse also allows one to take the input of multiple input devices and stream it to single applications or to multiple applications directed as one wishes.

One needs to be careful not to filter out the selection of devices/streams with pulse. The control I use for this is the application ‘pavucontrol’ (pulse audio volume control) and it is important that in the ‘SHOW’ select at the bottom of most tabs that one selects to show everything.

I was playing with pulse and multiple input and output devices in this thread: Looking (maybe) for audio mixer for use with Pulse Audio … (see post#4, #5, and #11 in theat thread) of course that is a different and more difficult case than what you are trying to do (I don’t think you will need the ‘sinks’).

My wife and I always adopt the low tech solution here. Our analogue headsets are small and take up less space than a USB headset. Still, this is likely easy to setup for an extra USB headset.

I do NOT know pulse well enough to give specific advice, other than to believe that I can do what you are trying to do without difficulty. I don’t have USB headphones nor USB speakers, so I can not test this (nor trial a representative setup) myself. You would need to provide screen prints of the different ‘menu tabs’ from pavucontrol (showing your selections, and show what OTHER selections were available that you did NOT choose) in order for me to provide any concrete suggestions.

Indeed thats the way the vast majority of users want this. Imagine if your mixer does not have a headset volume control (which IS the case for many different audio hardware) and one plugs in their headset and the speakers can not be muted. Thats incredibly annoying.

So while I appreciate you liked that extra feature, IMHO its not as important as having the volume of speakers muted for those of us whose hardware does not allow as many mixer selections.

I already selected to show all in the bottom right of pavucontrol, but I don’t see how this can help? For each stream, I can only select one output device. I would like to select two output devices!

Here are the screen shots of pavucontrol and paprefs. The language is unfortunately set to German, but “Alle” means “All” is the important bit. :wink:
http://img37.imageshack.us/img37/8033/pavcontrol.png
So if I hit the button “internal audio analog stereo” I have a choice to select “USB Headset Analog Stereo”, but that switched the sound to this device, making the “internal audio analog stereo” silent.

http://img560.imageshack.us/img560/4381/pavcontrol2.png

Uploaded with ImageShack.us
Here we can see my three devices: “internal audio analog stereo”, “USB Headset Analog Stereo” and an HDMI output (which unfortunately only works under windows, but that is another story in another post)

Here is the ticked checkbox for adding virtual devices for simultaneous output:
http://img861.imageshack.us/img861/3269/paprefs.png
However, if I ask pavucontrol to show me virtual devices, the tabs are just empty.

So apart from these additional sinks, which you think I might not need, what else should I try or do then?

First, I do not speak German. The selections are difficult enough in English, so I can not say if you have the correct selections. Unless perfect translations can be provided I can not provide good recommendations (and even if perfect translated my recommendations may not be good - this is NEW TO ME ALSO).

I have NO IDEA if your Anzelgen selection is correct. My guess is 50-50 chance its not correct - and that guess is because I don’t speak German.

Under the Weidergabe (playback I assume) I would be looking for a selection that reads “Internes Audio Analog Stereo + USB Headset Analog Stereo”. ie both should be listed as one selection. Both not being listed as one selection suggests something needs to be configured elsewhere.

Under the Ausgaberate (output devices) you have "Internes Audio Analog Stereo) selected to “Analoge Ausgabe” and “USB Headset Analog Stereo” set to “Analog Augabe”. What are the other selections ? Are there any ? A wrong selection there could mean Weidergabe does not have the correct selections available elsewhere.

The same is true for Konfiguration (which you did not show). The wrong selection there (if there is a selection) could mean you do not have the correct selections available elsewhere.

If one DOES have the correct selections, and IF one ONLY see’s what you show, then sinks may be needed.

But I don’t speak German, and I can’t play with your drop down menu’s to see what can be done.

Well, there are only three choices and I tried them all. For the “Playback” tab the choices are “All”, “Applications” & “Virtual Tracks”. For me, the first two are equal and the last is empty. For the output-devices tab, I The choices are: “All devices”, “Hardware-Devices” & “Virtual-Devices”. The first two show the same, while the last is empty. Not much that can go wrong here, three choices are easy to try.

**No, I can only select them individually, there is no “+” choices anywhere. It just lists my all my devices single. Any idea what needs to be configured where - or where to read to figure it out? **

The only other choice is “Analogue Headset”, which mutes the built-in speakers and forces audio through the 3,5mm line out. However, if a headset is plugged in, then I cannot tell a difference between the setting (i.e. it is always through the headset). For the USB-Headset shown, the choice is the same, but I could not discern any difference between “Analogue Output” and “Analogue Headset”. For another USB-Headset of mine, there is no such choice at all,

How do I get to see the configuration? I only know about “pavucontrol”, “paprefs”, “phonon” and “kmix” to twiddle with my audio. Is there a config file?

Of course. However, thus far the choices are very limited and obviously “show all” is better than “only show virtual devices”, but I just tried all three possible choices for each tab anyway. I think I need to enable something somewhere to get more choices available.

I really appreciate your help, thanks! :slight_smile:

Konfiguration is a tab in pavucontrol :
http://thumbnails15.imagebam.com/13600/fb2450135995835.jpg](http://www.imagebam.com/image/fb2450135995835)
[click on above for larger image]

I’ve used one of your images as an example.

Unfortunately I don’t have a USB headset (nor USB speakers) so I can not play with the settings and give you an example.

I’ve got one step ahead:
On a different machine running Kubuntu, ticking a checkbox in paprefs immediately offered me the desired option for simultaneous output in pavucontrol (which I had accidentally open while playing with paprefs), while playing audio!

So in paprefs, tab “Simultaneous Output” the single checkbox labelled “Add virtual output device for simultaneous output on all local sound cards” ought to do it (yes, i changed the language setting to english) , but it does not work on my openSUSE 11.4 machine. I compared all setting in paprefs and pavucontrol - on the Kubuntu machine it works, on my openSUSE machine it does not.
:frowning:

So something on my machine is broken. I cannot remember tweaking anything audio related, though, at least not since the 11.4 installation (not upgrade - but I did keep my entire home directory). Any ideas how to fix it?

PS@oldcpu: I was aware of that Configuration-Tab in pavucontrol,thanks, but I thought you mentioned something else, as that particular tab does not offer me much choice: for each non-virtual device I can choose a mode (i.e. off, duplex, in-only, out-only, stereo, mono).

Can you run the following command on each GNU/Linux distro (Kubuntu and openSUSE) obtaining two separate URL/website addresses (one from each):


/usr/sbin/alsa-info.sh

and post here the output URLs (website address) provided, so we can look for differences. Select the SHARE/Upload option. Ensure PC is connected to Internet. And ensure USB device is plugged in using same method (ie if you plugged in USB speakers before boot on one, do the same on the other). The idea here in comparing differences is to do an ‘apples to apples’ comparison. [note - post website/url address, don’t post the massive script output as its too much and will clutter the thread needlessly]

Ok, here is the alsa-info link for the Kubuntu machine. It is one of many in a University pool, and has just two built-in sound devices:
Kubuntu machine where simultaneous output is offered as a choice.
Note that I did not actually try these devices. All I did was ticking the checkbox in paprefs and immediately seeing two virtual loopback devices popping up in pavucontrol, as well as additional “+” options to choose from for application audio stream that were not there before I clicked that simultaneous-checkbox.

Here is the alsa-info from my openSUSE laptop, currently having 5 devices, of which 2 are disabled (in previous tests I had enabled them, but since they don’t work reliably, I usually disable them via the config dialogue in pavucontrol):
openSUSE laptop where simultaneous output is not offered.

A few minutes ago, I also removed the directories .pulse and .pulse-cookies from my home directory (moved away to a backup location) and restarted the machine. The .pulse directory got recreated.

Thanks!

Thanks, but that did not help.

It looks to me that you did not have the USB device plugged in to the Kubuntu PC when you ran the script. Hence there is NOTHING there that can help me help you.

Sorry.

Even though I do not have your hardware, I think I found a way that might work for you, although you will need to ‘play’ with this a bit to adapt it to your hardware. This in fact is just a ‘hack’ on my part and I don’t really know what I’m doing (I’m just re-using some sink/loopback commands I’ve used before when trying to record with multiple devices)

Anyway, details:

I have an old PC with openSUSE-11.4 installed on it, where this old PC has two sound cards. A mother board sound device, and a rather ancient PCI (not PCI-e) sound blaster compatible card. This is a REAL old PC … an athlon-1100 that is ~10 years old, running LXDE on openSUSE so as to not be too slow.

So ‘pretending’ one of these cards is your USB sound device I did the following:

  1. I installed pavucontrol and pulseaudio-utils. Both of these package are needed for what I was going to do.

  2. I set up my configuration as follows:

http://thumbnails16.imagebam.com/13607/042acd136064527.jpg](http://www.imagebam.com/image/042acd136064527)
[click on image for larger view]

  1. As a regular user, I then added a sink with this command:

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

(I simply ‘madeup’ the name twospeakers. Use any name you like).

  1. As a regular user, I also added the following once

pactl load-module module-loopback sink=twospeakers

  1. I setup my “Output devices” as follows (note the sink present)

http://thumbnails10.imagebam.com/13607/645e61136064529.jpg](http://www.imagebam.com/image/645e61136064529)
[click on image for larger view]

  1. I setup my play back as follows (note the sink present)

http://thumbnails41.imagebam.com/13607/af4e51136064532.jpg](http://www.imagebam.com/image/af4e51136064532)
[click on image for larger view]

  1. and it worked. Sound came out of both speakers simultaneous. Sort of worked. There is a fraction of a second lag between the two speakers which makes it unusable for speakers, but it is possibly useable for headsets. I can’t explain the lag as I know next to nothing about this. Its possibly the age of the PC or its possibly the method I chose to do this is simply not a good method (even though it sort of works).

There is likely an easier way, but what can I say ?

If you want to make it permanent? Then take a look here Looking (maybe) for audio mixer for use with Pulse Audio (toward the end of the thread (post#11) to see how to make this permanent, and pay attention to the fact I only used ONE ‘pactl’ load-module with loopback as opposed to two in that thread).

This is an UGLY approach. Real UGLY. I hope someone comes up with a smoother approach.

This archlinux guide appears to provide a better approach, where one specifies the audio device associated with the sink:https://wiki.archlinux.org/index.php/PulseAudio#Simultaneous_Digital_and_Analog_Output (go to Simultaneous Digital and Audio in that thread).

I may give that a try (of course with an openSUSE twist).

I tried that, but it does not work well on my old PC (an athlon-1100). The sound on one of the sound devices slows down to slow motion, even though sound comes out through both speakers. The fraction of a second lag in the approach I proposed above appears to take up less CPU load than the approach from the ArchLinux page (although the ArchLinux approach is more elegant and more understandable/logical).

I know, I’m replying to my own post, but I am putting this in context.

I found a way to get rid of the lag with the quoted original approach.

  1. I installed pavucontrol and pulseaudio-utils. Both of these package are needed for what I was going to do.

  2. I set up my configuration as follows:

http://thumbnails16.imagebam.com/13607/042acd136064527.jpg](http://www.imagebam.com/image/042acd136064527)
[click on image for larger view]

  1. As a regular user, I then added a sink and a loopback with these command (where this is what improved the performance):

pacmd
load-module module-null-sink sink_name=twospeakers 
load-module module-loopback sink=twospeakers

(I simply ‘madeup’ the name twospeakers. Use any name you like).

  1. I setup my “Output devices” as follows (note the sink present)

http://thumbnails10.imagebam.com/13607/645e61136064529.jpg](http://www.imagebam.com/image/645e61136064529)
[click on image for larger view]

  1. I setup my play back as follows (note the sink present)

http://thumbnails41.imagebam.com/13607/af4e51136064532.jpg](http://www.imagebam.com/image/af4e51136064532)
[click on image for larger view]

  1. and it worked. Sound came out of both speakers simultaneous. No lag this time. Sound synchronized. Note that as soon as one types “exit” it will close the session opened by ‘pacmd’. So if one wishes to make this permanent, then one will need to adopt a different approach and edit the appropriate configuration files !

Another reply to myself. It turns out this only removes the lag for a short time, and then after a while the lag starts again. Possibly a small pulse audio (or other process) memory leak causes a deterioration with time.

Still, I think I have discovered a more elegant way to do this without using a sink. That would be an edit to the 50-sound.conf file, … but I need to investigate this a bit more before suggesting a solution.

STurtle, when your USB speakers are plugged in, could you provide the output of:


cat /etc/modprobe.d/50-sound.conf

Further to this thread, I noted the following from the pulse audio FAQ page: FAQ – PulseAudio

Can I use PulseAudio to playback music on two sound cards simultaneously?](http://www.pulseaudio.org/wiki/FAQ#CanIusePulseAudiotoplaybackmusicontwosoundcardssimultaneously)

Yes! Use module-combine for that.


 load-module module-alsa-sink device="front:Intel" sink_name=output0
load-module module-alsa-sink device="front:HDA" sink_name=output1
load-module module-combine sink_name=combined slaves=output0,output1
set-sink-default combined

 This will combine the two sinks output0 and output1  into a new sink combined. Every sample written to the latter will be  forwarded to the former two. PulseAudio will make sure to adjust the  sample rate of the slave device in case it deviates from the master  device. You can have more than one slave sink attached to the combined  sink, and hence combine even three and more sound cards. 
   
Much fancier is to use the automatic mode. To make use of that simply check the "Simultaneous Output" checkbox in paprefs. 

 **Can I use PulseAudio to combine two stereo soundcards into a virtual surround sound card?](http://www.pulseaudio.org/wiki/FAQ#CanIusePulseAudiotocombinetwostereosoundcardsintoavirtualsurroundsoundcard)**

   Yes! You can use use module-combine for that. 

 load-module module-oss-mmap device="/dev/dsp" sink_name=output0 channel_map=left,right channels=2
load-module module-oss-mmap device="/dev/dsp1" sink_name=output1 channel_map=rear-left,rear-right channels=2
load-module module-combine sink_name=combined master=output0 slaves=output1 channel_map=left,right,rear-left,rear-right channels=4

 This is mostly identical to the previous example. However, this time we  manually specify the channel mappings for the sinks to make sure  everything is routed correctly.

Please keep in mind that PulseAudio will constantly adjust the sample  rate to compensate for the deviating quartzes of the sound devices. This  is not perfect, however. Deviations in a range of 1/44100s (or 1/48000s  depending on the sampling frequency) can not be compensated. The human  ear will decode these deviations as minor movements (less than 1cm) of  the positions of the sound sources you hear. 
 

I assume for those above modules to load, one needs to first run “pacmd” … knowing that the setting will be lost when ‘pacmd’ is exited. But one can then add those load module lines (if they pass the test after using ‘pacmd’) into the /etc/pulse/default.pa configuration file.

Reference the ‘paprefs’ suggestion, of course one then needs to install ‘paprefs’ as it may not be installed by default (it is not installed by default on my LXDE PC). I also note using ‘paprefs’ did NOT work with my openSUSE-11.4 LXDE running Tumbleweed, as the option never appeared for simultaneous devices. I may test that WITHOUT Tumbleweed to confirm this is not a Tumbleweed issue.

Can I use PulseAudio to playback music on two sound cards simultaneously?
I’ve done this and it works! I have one onboard and one nvidia graphic card with hdmi.
Hdmi is connected to a tv and onboard card is connected to speakers and play simultaneously!

oldcpu has a very good explanation on top of my post, though mine is a bit different probably on my setup.
I’ll post what I did though it is not applicable to the op but just to give an idea.

I edited /etc/pulse/default.pa and add this line for my HDMI

### Load HDMI device
load-module module-alsa-sink device=hw:1,7
load-module module-combine sink_name=combined
set-default-sink combined

I have pulse audio device chooser installed and under configure local sound server
I enabled simultaneous output

After restarting pulseaudio I opened pavucontrol and under playback, choose simultaneous output for both onboard and nvidia card.