Linux звук на несколько устройств

Play sound through two or more outputs/devices

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 that allow 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).

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.

Ubuntu 20.04 — paprefs worked for all hard-connected speakers, after closing all audio settings & restarting the pulsaudio killall pulseaudio however it disconnected my bluetooth speaker — had to reconnect and switch to it and back to the multioutput 🙂

it works but the timing is a mess. i understand now why no professional wanted to write software for linux. the complete audio architecture is a bit of a mess. pulseaudio being more network oriented and jack single audio device. it is hard to create tight sync between multiple audio devices. The synchronisation issues are simply not easy to solve.

6 Answers 6

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

Then in the 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 the PulseAudio Sound Preferences menu ( pavucontrol ):

pavucontrol screenshot

In this example it is shown for an 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 

To unload the module from the command line and reset PulseAudio to defaults, just restart PulseAudio with:

pactl unload-module module-combine-sink 

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.

Читайте также:  Все репозитории kali linux

@NathanJ.Brauer: you may be interested in this answer. For changing ports see also the pulseaudio wiki I linked to there.

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

doesnt work for me in ubuntu 16.04. I don’t see any such option like «Simultaneous output» in the sound preferances window

@Jollywatt — Separate volume control of each audio device is possible through PulseAudio Preferences ( pavucontrol ), under both ‘Playback’ and ‘Output’ tabs.

Ubuntu

I’ve just confirmed this solution still works on Ubuntu 14.04 LTS.

  1. Install: Open terminal and type sudo apt install paprefs go to the tab exactly as per the picture above and select the option.
  2. Initial Run:
    1. Remaining in terminal, type pulseaudio -k to kill and restart pulseaudio (this way with current systemd pulseaudio user service).
    2. Then go to your sound settings and you will see the option to output to multiple sound devices.
    3. 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 Mac 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.

    Thanks, just confirmed this works in Linux Mint 20. It’s per user so you have to do the command as the desktop user.

    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

    enter image description here

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

    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 

    For me, this one worked when I had device=»hw:0,0″ as per aplay -l (see forums.linuxmint.com/viewtopic.php?t=264540#p1436479)

    Make sure to put at top of file! This works for me (hw:0,0) on Ubuntu 18.04.2, playing on two HDMI monitors, after I moved the lines to the top.

    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.subdevice = "0" alsa.device = "1" name: 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.subdevice = "0" alsa.device = "1" name: 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.

    Источник

    Раздельный вывод звука на акустику и наушники

    В Windows на интегрированной звуковой карте Realtek High Definition Audio можно было сделать раздельный вывод звука на акустику и наушники. В Linux если я подключаю наушники, то отключается линейный выход. Хоть в настройках KDE и есть профили «Аналоговый стерео выход» и «Аналоговый стерео дуплекс», но никакого положительного эффекта они не дают.

    Как сделать возможным переключение между наушниками и линейным выходом на встроенной звуковой карте?

    Можно попробовать профиль Pro Audio, если он есть. При нем все выходы активны.

    Некоторые ограничения и «ненужную» автоматику аудио можно обойти, используя alsamixer или amixer(в скриптах).

    Профиль Pro Audio есть и вроде бы должен решать поставленную задачу, но звука в акустике нет, если подключены наушники и alsamixer тоже ничем не помог

    Обрати внимание на переключатели типа ‘Auto-Mute Mode’, ‘Independent HP’

    Auto-Mute Mode = Enabled Но и изменить значение в Alsamixer не получается

    Оно пока такое только теоретически умеет. В реальной жизни пульса с этим справится намного лучше, вплоть до маппинга синков к конкретным джекам.

    А что это такое, раздельный вывод звука?

    В Linux если я подключаю наушники, то отключается линейный выход.

    Так это ж хорошо. А как надо настроить, чтобы звук одновременно шел и из наушников и из колонок или чтобы переключение между ними было вручную?

    На каком дистрибутиве дело происходит?

    Кстати, как там в Windows, можно ли сделать чтоб разные программы воспроизводили и записывали звук через разные устройства? Я просто ею уже лет 10 не пользуюсь.

    В моем случае нет никакой разницы. Что с Pipewire не работает линейный выход, что с PulseAudio

    Я возможно коряво выразился, но смысл в том, чтобы я при подключенных наушниках мог выбирать, куда мне вывести звук: на линейный выход на задней стороне системного блока или на порт наушников на лицевой стороне. При этом естественно не дергая наушники из гнезда

    Также в Windows приятным бонусом есть возможность задать определенной программе нужный выход. Например в Skype указать наушники, а не системный по-умолчанию

    Я возможно коряво выразился, но смысл в том, чтобы я при подключенных наушниках мог выбирать, куда мне вывести звук: на линейный выход на задней стороне системного блока или на порт наушников на лицевой стороне.

    Можно выбрать в pavucontrol на вкладке вывода активный порт (Наушники или линейный). Как на встройке же вывести что-то отдельно на колонки, а что-то на наушники не знаю.

    Можно выбрать в pavucontrol на вкладке вывода активный порт (Наушники или линейный)

    Вот в этом основная проблема. Выбираю, но если наушники вставлены в гнездо, то в колонках тишина, хоть тресни!

    Max77 ( 01.04.22 13:41:30 MSK )
    Последнее исправление: Max77 01.04.22 13:41:47 MSK (всего исправлений: 1)

    Попробуй в алсамиксере навестись на Auto-Mute Mode и нажать стрелку вниз.

    Большое спасибо! Как все просто оказалось.

    Наушники и колонки minijack? Колонки стерео?

    В Linux есть обе эти функции. Вне холивара: я даже считал их преимуществом Linux, просто не знал, что в Windows они есть.

     Host: pc Kernel: 5.17.1-arch1-1 arch: x86_64 bits: 64 Desktop: KDE Plasma v: 5.24.4 Distro: Arch Linux Audio: Device-1: Intel 7 Series/C216 Family High Definition Audio driver: snd_hda_intel Device-2: NVIDIA GP104 High Definition Audio driver: snd_hda_intel Sound Server-1: ALSA v: k5.17.1-arch1-1 running: yes Sound Server-2: PipeWire v: 0.3.49 running: yes 

    Max77 ( 01.04.22 18:22:49 MSK )
    Последнее исправление: Max77 01.04.22 18:23:49 MSK (всего исправлений: 1)

    Как сделать, чтобы разные программы воспроизводили звук через разные устройства, я знаю только в пульсе. Тут есть разные способы.

    1. Подключить либо наушники либо колонки по HDMI

    2. Подключить колонки в тот джек на материнской плате, который предназначен для задних колонок (для surround), затем

    mkdir ~/.config/pulse/ cp -v /etc/pulse/default.pa ~/.config/pulse/

    Добавить в конец файла ~/.config/pulse/default.pa

    load-module module-remap-sink sink_name=virtual_speakers master= channels=2 master_channel_map=rear-left,rear-right channel_map=front-left,front-right remix=no load-module module-remap-sink sink_name=virtual_headphones master= channels=2 master_channel_map=front-left,front-right channel_map=front-left,front-right remix=no

    Далее независимо от выбранного способа получится два устройства (физических либо виртуальных).

    Когда надо вручную переключить устройство вывода звука, делаем его «устройством по умолчанию» в pavucontrol либо командой

    Тогда в Pulseaudio 14.0+ все программы, для которых не указано иное, должны воспроизводить звук через это устройство. Я не проверял, но hateWin утверждает, что работает, он не даст соврать.

    Когда надо настроить, чтобы отдельная программа воспроизводила звук через другое устройство, перенести ее на соответствующий sink графической утилитой или командой

    Источник

Оцените статью
Adblock
detector