102

I think this is a pretty simple concept. I have one sound card and one pair of bluetooth headphones. I want to play my audio through both my sound card and my bluetooth headphones.

I believe Windows has checkboxes allows you to "check" outputs to enable/disable them, but Ubuntu seemingly has the equivalent of radio selectors (you can only select one at a time).

Bonus Question: On a similar note, I have 5 analog output channels on my sound card (in addition to my digital & HDMI audio) -- I would like to be able to determine what comes out of each of those ports (e.g. "front speakers" on all 5 or "front", "center", "back", etc).

Thanks in advance!

  • I have read all answers, checking answer date too. What is the current solution for ubuntu 18.04? – LeonidMew Jan 21 '19 at 8:56
  • 2
    Yes, the version of paprefs in Ubuntu 18.04 repos is useless (because it still thinks GConf is in fashion and hence fails to work). The best alternative is to, you know, load the module-combine-sink of PulseAudio yourself (because that's all paprefs does behind-the-scene anyway). Use command pactl load-module module-combine-sink and check the Sounds section of Ubuntu Settings. – AneesAhmed777 Aug 11 '19 at 16:16
  • In Ubuntu 19.10 solution with paprefs works out of box again. – Marcin Skórzewski Nov 22 '19 at 7:15
111

With paprefs you have access to a virtual output device that enables simultaneous output to all attached sound cards/devices:

sudo apt install paprefs 

Then in terminal run paprefs, select "Simultaneous Output" tab, and check "Add virtual output for simultaneous output on all local sounds cards".

paprefs

The additionally created audio output device for simultaneous output may be selected in the "Output" tab from pulseaudio sound preferences menu:

enter image description here

In this example it is shown for a HDMI-device but as soon as your Bluetooth device is recognized it will also be available for simultaneous output.

The changes may need a restart of pulseaudio to take effect either by logging out and back in to your session or by running pulseaudio -k in a terminal.


In case paprefs does not do the job or if you prefer to have paprefs not installed use this command from the command line:

pactl load-module module-combine-sink
| improve this answer | |
  • 1
    This gets the job done. As I get deeper into audio development, I would really like to be able to select specific devices and/or ports, though. – Nathan J.B. Nov 13 '11 at 3:14
  • 1
    @NathanJ.Brauer: you may be interested in this answer. For changing ports see also the pulseaudio wiki I linked to there. – Takkat Nov 13 '11 at 7:43
  • 1
    oh never mind sudo apt install paprefs works – tatsu Jan 28 '18 at 14:18
  • 2
    this one doesn't work for me in 18.04. If you know how I can do this with ALSA please help me here: askubuntu.com/q/1042485/586277 – ICE Jun 2 '18 at 19:38
  • 3
    doesnt work for me in ubuntu 16.04. I don't see any such option like "Simultaneous output" in the sound preferances window – node_man Mar 26 '19 at 9:46
23

Ubuntu

I've just confirmed this solution (from 4 years ago) still works on Ubuntu 14.04 LTS.

Install

Open terminal and type sudo apt-get install paprefs go to the tab exactly as per the picture above and select the option.

Initial Run

Then; remaining in terminal, type pulseaudio -k to kill and restart pulseaudio.

Then go to your sound settings and you will see the option to output to multiple sound devices.

Props to whoever wrote paprefs it's a brilliant little piece of software I would actually like to see included in Ubuntu without requiring additional installation.

Apple Macs OS X

A similar solution is available via an included piece of software and whats so great about pulseaudio is that the sound seems to be perfectly in-sync from both outputs so it must be adjusting for the lag as well which is why its so impressive; otherwise we would be hearing a slightly delayed version from one output and another.

| improve this answer | |
  • 1
    thanks for doing the work to check if solution is still valid! – peter karasev Jan 12 '16 at 15:58
  • 2
    This also works on Ubuntu 16.04.1 LTS – aggsol Jan 21 '17 at 14:42
7

In Kubuntu 18.04, Plasma 5.12 paprefs is not needed, as a similar setting is already there:

enter image description here

A new output option should become available after reboot, called “Simultaneous output”.

enter image description here

Or in pavucontrol:

enter image description here


In 18.10 with Plasma 5.13.5 that “Simultaneous output” option has been removed, so paprefs is needed.

| improve this answer | |
  • "Simultaneous output" is still available on my ArchLinux with KDE 5.19.2 – noone Jul 6 at 10:26
6

To complement the excellent answer from Takkat, I found the default name given to the new device was excessively long and distorted the Sound Settings dialog. In order to shorten that name, I had to additionally execute the following command:

gconftool --set --type string /system/pulseaudio/modules/combine/args0 sink_properties=device.description=Combined

Sound settings with combined device

| improve this answer | |
6

I could not get Takkat's proposal work out of the box in Debian 8.7, although I restarted the system. I assume you have completed Takkat's proposal in installing paprefs. Extension on Takkat's answer which works based on Arch Linux wiki where keep analog input and Pulse calls that "duplex"

# /etc/pulse/default.pa
# http://unix.stackexchange.com/a/180374/16920
load-module module-alsa-sink device=hdmi:0
load-module module-combine-sink sink_name=combined
set-default-sink combined

Then restart pulseaudio:

pulseaudio -k
| improve this answer | |
5

Because LeonidMew was asking about 18.04 (I'm using 18.04.2), here's my version.

The GUI paprefs tried to combine one HDMI with one analog output, instead of both hdmi. So I edited the file /etc/pulse/default.pa as described by Léo Léopold Hertz

$ gedit /etc/pulse/default.pa  # make changes as in method a or b below
$ pulseaudio -k # then restart pulseaudio

Both the following methods work on their own, so pick one (make sure to add these lines to the top of the file, I put it right after .fail ! Otherwise it doesn't work).

Method A

load-module module-alsa-sink device=hw:0,0
load-module module-combine-sink sink_name=combined

Method B

load-module module-alsa-sink device=hw:1,3 sink_name=hdmi
load-module module-alsa-sink device=hw:1,7 sink_name=hdmi2
load-module module-combine-sink sink_name=combined slaves=hdmi,hdmi2
set-default-sink hdmi-combined

Reference

Method A

For reference, the hw:0,0 comes from aplay -l

$ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: PCH [HDA Intel PCH], device 0: ALC892 Analog [ALC892 Analog]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 1: ALC892 Digital [ALC892 Digital]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: NVidia [HDA NVidia], device 3: HDMI 0 [HDMI 0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: NVidia [HDA NVidia], device 7: HDMI 1 [HDMI 1]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: NVidia [HDA NVidia], device 8: HDMI 2 [HDMI 2]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: NVidia [HDA NVidia], device 9: HDMI 3 [HDMI 3]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

Method B

And the 1:7 and 1:3 comes from

$ pacmd list-sinks | grep -e 'name:' -e 'alsa.device ' -e 'alsa.subdevice '
    name: <alsa_output.pci-0000_00_1b.0.iec958-stereo>
        alsa.subdevice = "0"
        alsa.device = "1"
    name: <alsa_output.pci-0000_01_00.1.hdmi-stereo-extra1>
        alsa.subdevice = "0"
        alsa.device = "7"

On the GNOME "sound settings" I set the other HDMI from 2nd monitor as output, and then re-ran the command

$ pacmd list-sinks | grep -e 'name:' -e 'alsa.device ' -e 'alsa.subdevice '
    name: <alsa_output.pci-0000_00_1b.0.iec958-stereo>
        alsa.subdevice = "0"
        alsa.device = "1"
    name: <alsa_output.pci-0000_01_00.1.hdmi-stereo>
        alsa.subdevice = "0"
        alsa.device = "3"

To verify these numbers are correct, I ran

$ aplay -D plughw:1,3 /usr/share/sounds/alsa/Front_Right.wav
$ aplay -D plughw:1,7 /usr/share/sounds/alsa/Front_Right.wav

which sounded on their respective monitors.

| improve this answer | |

Not the answer you're looking for? Browse other questions tagged or ask your own question.