View previous topic :: View next topic |
Author |
Message |
abduct Apprentice
Joined: 19 Mar 2015 Posts: 215
|
Posted: Wed Jul 25, 2018 12:15 am Post subject: ALSA configuration applications |
|
|
Is there a way via asound.conf to have sound mapped to multiple outputs.
Currently I have it set to 0,0 which is my laptop speakers, but my HDMI output is 0,3. I normally have to edit the config manually and restart the software if I wish to output sound over another output.
Is there any software that can:
-Send audio to both outputs at once
-Allow outputs to be muted
I've heard horror stories of pulseaudio and I would like to stay away from it. It's perferable if there is an application that just edits the config files for me from either the command line or GUI so I can just stick with ALSA, but if I need a overhaul of sound software so be it.
I've seen JACK, would this application suit my needs or is there a better option?
Thanks.
Edit:: More or less what I am looking for is the abilitiy to send auto to my speakers and HDMI at the same time then individually mute them. |
|
Back to top |
|
|
johngalt Apprentice
Joined: 09 Sep 2004 Posts: 258 Location: 3rd Rock
|
Posted: Wed Jul 25, 2018 12:54 am Post subject: |
|
|
Glad you asked this question - I'm about to come up to a working install of my LVM setup on my desktop, and sound is going to be the second thing I tackle, and I am keenly interested in a similar set up, where I can have sound on multiple outputs and control vol / muting at the endpoints.
Looking forward to the answers you get. _________________
desultory wrote: | If you want to retain credibility as a functional adult; when you are told that you are acting boorishly, the correct response is to consider that possibility and act accordingly to correct that behavior. |
Amen. |
|
Back to top |
|
|
Jaglover Watchman
Joined: 29 May 2005 Posts: 8291 Location: Saint Amant, Acadiana
|
Posted: Wed Jul 25, 2018 1:59 am Post subject: |
|
|
There is nothing to configure on ALSA level, all outputs are there, for you to use. For instance, I have a TV set connected to my computer via HDMI as a third display. When I want to send sound there I run player like this:
Code: | mpv --audio-device=alsa/hdmi:CARD=PCH,DEV=1 file_to_be played |
Meanwhile ALSA default is still the analogue output, I can play sound thru my PC speakers from other applications. _________________ My Gentoo installation notes.
Please learn how to denote units correctly! |
|
Back to top |
|
|
steve_v Guru
Joined: 20 Jun 2004 Posts: 388 Location: New Zealand
|
Posted: Thu Aug 16, 2018 6:36 am Post subject: |
|
|
As neither the onboard DAC or HDMI are going to disappear (as in e.g. USB sound devices), I'd just duplicate the stream to both in asound.conf, with software volume control if required.
Then simply mute the output you're not using.
The ALSA docs are a bit vague, but it's all there.
Here's an excerpt from my asound.conf, doing pretty much this with a SPDIF output rather than HDMI:
Code: | pcm.!default {
type plug
slave {
pcm "duplex"
}
}
pcm.duplex {
type asym
playback {
pcm "duplicate"
}
capture {
pcm "dsnoop"
}
}
pcm.duplicate {
type plug
slave.pcm {
type multi
slaves {
a { pcm "dmix:0,0" channels 2 }
b { pcm "spdif_softvol" channels 2 }
}
bindings [
{ slave a channel 0 }
{ slave a channel 1 }
{ slave b channel 0 }
{ slave b channel 1 }
]
}
ttable [
[ 1 0 1 0 ]
[ 0 1 0 1 ]
]
}
pcm.spdif_softvol {
type softvol
slave {
pcm "dmix:0,1"
}
control {
name "SPDIF Playback Volume"
card "0"
}
hint {
show on
description "SPDIF"
}
} |
It's probably wrong on some level, but it works fine for me and sounds like what you're after. |
|
Back to top |
|
|
LIsLinuxIsSogood Veteran
Joined: 13 Feb 2016 Posts: 1179
|
Posted: Thu Aug 16, 2018 8:33 am Post subject: |
|
|
Rewritten (after reading I decided to try again)...
First thing is probably that you should consider what types of audio streams that is you want to have output (system audio, application audio, a mic, a aux input, etc. etc. and let that help be a deciding factor. Since the work involved can always be way more by deciding on the wrong approach, so you will be way better off considering up front, for example, if it doesn't matter to you that some audio is on either one, or both but just want sound from a couple of applications to be outputted this way. Is that possibly the case? And what is the purpose primarily for this system? Is it work or personal, does it make use of lots of multimedia or minimal amounts? The more specific you are about what the needs are for things like audio sources as well then you can make the whole process much easier.
As jaglover mentioned, and if your situation is as easy as his is (to watch movies with mpv) then much of the work is done at the application itself and does not really require any extra effort at the more complex programming level of ALSA driver.
Thinking of what alsa is for it is basically a good way to test the output, and provide acccess to those devices via things like speaker channels and other stuff like that. It does that for various audio streams or output, which you cannot just bundle together or else you are sort of missing the point (and making things more difficult for yourself). Still if what you want is to have something like that, then I would suggest that you rethink your own position on not using pulseaudio. The sound server that is a front end and can run system wide is not ALSA, but pulseaudio. Therefore if you want all your sound to be controllable with that type of a option for the output and muting then it (pulseaudio) is much more likely to be your solution here. And while you did express your own feeling about it there wasn't much reasons behind it, so I leave that to you to decide. Maybe you could see how far you are able to get with just ALSA before you need to use it, or some other front end that manages the more challenging aspects of sound like audio lag and syncing or buffering when streams don't match, etc.
One other thing to mention is depending on the particular of your setup I think that there are actually many A/V receivers that would automatically do this for you without any further setup needed other than plugging in a bunch of cables and allowing the circuitry to do its magic of connecting speakers to outputs.
More importantly, checking if your application or general purpose for the sound on your system is able to be done with different devices all from the application itself then checking about whether the application has already a working solution would make the most sense (I think). And if not, then going down the road of using a combination of tools might as well. ALSA configuration if you haven't done it and are looking for a challenge is going to be an easy way to get red in the face and also needs to be done correctly usually before you install pulseaudio, if you change your mind and go that route.
Note about certain Linux Applications
If your goal is to use some linux applications to send output to multiple devices than that is something you can probably check and research about the application as well to see if it is allowed. MPD for example does allow for this by actually offering a section in the configuration file for that app specifically for audio and audio outputs. I regularly make use of it to play audio from different devices. The various devices in that confiruation are integrated as checkboxes in the main Server settings for the application which can be accessed from any machine with a connection to the server.
Last edited by LIsLinuxIsSogood on Thu Aug 16, 2018 9:18 am; edited 2 times in total |
|
Back to top |
|
|
steve_v Guru
Joined: 20 Jun 2004 Posts: 388 Location: New Zealand
|
Posted: Thu Aug 16, 2018 8:50 am Post subject: |
|
|
LIsLinuxIsSogood wrote: |
You have mentioned that you don't want to use pulseaudio. Something to clear up is that pulseaudio is really nothing more than a front-end that interfaces with various applications. | Uhh, it's a bit more than just a "frontend"... But this is not the place for that argument.
LIsLinuxIsSogood wrote: | However if one thing you are after is to have all system audio outputted to 2 devices then you really should consider it since something ALSA really don't do as more of a back-end tool is manage things like streams and the application layer of audio signals or output. | ALSA can do this, without pulseaudio, with one caveat...
LIsLinuxIsSogood wrote: | a delay probably in milliseconds between the speakers. | It can't compensate for clock drift between two DACs without a physical sync cable. Pulseaudio can apparently, but I've never used it or needed it, so I can't comment on it's effectiveness.
Unless the OP is intending to listen to the same audio from two cards simultaneously in the same room (and has good ears), this is irrelevant.
If the question is as I understand it: "Can I duplicate a stream to two soundcards (or two outputs on the same card), and mute one or the other on demand?", then ALSA has a plugin (multi) to do exactly that, without the overhead and latency that pulseaudio introduces.
Duplicating a stream to two or more devices is well within the realms of an audio "backend".
Then again, since you edited while I was typing this... nevermind. |
|
Back to top |
|
|
LIsLinuxIsSogood Veteran
Joined: 13 Feb 2016 Posts: 1179
|
Posted: Thu Aug 16, 2018 9:19 am Post subject: |
|
|
I edited sorry. Becuase it is late wher eI am and forgot the rest of the world.
steve_v can you please share the following two things:
1) the caveat for limitation of ALSA
2) a link or explanation of the plugin used to duplicate streams
EDIT: sorry for mispelling your name above initially, which I've since fixed... |
|
Back to top |
|
|
steve_v Guru
Joined: 20 Jun 2004 Posts: 388 Location: New Zealand
|
Posted: Thu Aug 16, 2018 9:41 am Post subject: |
|
|
LIsLinuxIsSogood wrote: | Becuase it is late wher eI am and forgot the rest of the world. | It's late here too.
LIsLinuxIsSogood wrote: |
1) the caveat for limitation of ALSA |
As I mentioned, when duplicating streams to two devices ALSA has no way of compensating for clock drift - so audio may become very slightly out of sync.
For playback this is probably not going to be noticeable at all - it may become a problem when capturing audio in a PA setting though.
One other thing I should mention: This setup might cause issues with applications that expect mmap access to the soundcard. The only examples I have run into are very old binary games, and it's not really an issue as one can just give them the raw device anyway.
LIsLinuxIsSogood wrote: | 2) a link or explanation of the plugin used to duplicate streams |
Here, and here. With a bit of reading between the lines. |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|