AVS Forum banner
  • Everything You Wanted to Know About HDMI Cables. Ep. 7 of the AVSForum Podcast is now live. Click here for details.

simultaneous/multiple outputs with Alsa?

17K views 27 replies 5 participants last post by  sidamos  
#1 ·
I'm 99.9% certain alsa can do this.. and I've found some .asoundrc's for it.. altho I can't believe it should be as involved as they are.


Situation is this..


- speakers in zone 2 (outside on the back deck)

- most mid-level AVRs cannot send signals to Zone 2 that originate from a digital input (ie. from my HTPC) (the new Denon's (11 series) appear to deal with this finally.. I think.. but I have an 10-series, so...)

- htpc is configured to send 5.1 out HDMI

- figured why not echo/mirror front L/R to the analog output jack on the rear.. I could input that to the AVR on, say, the CD inputs, and then Zone 2 would be able to access that audio (ie. internet radio, etc)


The examples I find (ie. http://www.mail-archive.com/alsa-use.../msg23645.html ) (perhaps by poor choice of search keywords) all seem to involve much more than I would expect.. but maybe that's what it takes. I just want to send the same audio to 2 outputs at the same time (hdmi + 2-ch analog)


anyone have this setup and willing to share info?


EDIT: I do not have any real desire to send different sounds to the 2 outputs.. same signal... just being sent out as digital and analog...
 
#3 ·

Quote:
Originally Posted by dmears /forum/post/19039681


I know this might not be the answer you want, but I have pulseaudio and it seamlessy redirects audio to multiple outputs (what it calls "sinks"). I often have it going to my HT system and bluetooth headphones.

do tell... I use Ubuntu 10.04 and I've not truly ripped PA out of it.. so I'm not sure how much is there and usable... but it might give me a reason to like it...


I have the Pulse audio volume control panel installed... it shows me the same kind of info the stock Ubuntu panel does.. it shows both outputs.. I just can get any sound out of the internal audio.


It could be that my .asoundrc file is preventing this (sending all audio to HDMI), but I'm 99% sure I need this file to keep my HDMI audio (nvidia) so I'd need to add to it.. hence the searches I did.


I also tried speaker-test.. and got nothing...
 
#5 ·

Quote:
Originally Posted by mythmaster /forum/post/19041494


Well, it *should* be as simple as setting up slaves for each of your outputs then using the "copy" plugin.


Reference: http://www.alsa-project.org/alsa-doc...m_plugins.html

that looks a bit more straight-forward than what I was finding, thanks! Will give it a try over the weekend.


Still puzzled that I could not get speaker-test to work, explicitly specifying the output channel (0,0) (my HDMI is 1,3)
 
#6 ·
In pulseaudio, in the volume control panel, you can choose (via a dropdown if I recall correctly) to have simultaneous outputs. We're in the middle of a move so I don't have access to my system, but I'll try to look it up once its up and running. I recall that there was another place where you had to enable simultaneous audio output but I can't remember where.


I really dislike the obscure documentation for Linux audio, so I think you're probably better off trying mythmaster's suggestion above first, before messing around with pulseaudio. Just to reduce the aggravation.
 
#9 ·
I am stumpified... I can now _choose_ between HDMI *OR* analog output but cannot get both working at the same time.


I've tried 2 approaches in .asoundrc
Code:
Code:
pcm.!default hdmi:NVidia
pcm:iec958 hdmi:NVidia

pcm.foo {
        type copy               # Copy PCM
        slave {                 # Slave definition
            pcm {
                    type hw;
                    card 0; 
                    device 0;
                   # subdevice 0;
            }   
        }
}
and
Code:
Code:
pcm.!default hdmi:NVidia
pcm:iec958 hdmi:NVidia

pcm.copy {
        type hw;
        card 0; 
        device 0;
        subdevice 0;
}    

pcm.duplicate {
type copy
slave.pcm "copy"
slave.channels 2
route_policy duplicate
}
Using the Ubuntu sound panel (or the PulseAudio cound panel) I can toggle the sound to either output, but see no option there to allow both.


I thought the .asoundrc would do that.. but no luck so far.


From what I read, I do not need to reboot/restart between .asoundrc changes, only to relaunch the application in question (I say this in case someone knows better so hey can correct me)


Pics of the Alsa panel ( http://joustingwindmills.com/mac/ubuntu_panel.png ) and the Pulse panel ( http://joustingwindmills.com/mac/pulse_panel.png and http://joustingwindmills.com/mac/pulse_output.png )


EDIT: trying with 2-ch internet radio and music right now.
 
#11 ·

Quote:
Originally Posted by mythmaster /forum/post/19048347


Here's something to try. Substitute your actual device numbers, of course. I have no way of testing it:

Code:
Code:
pcm.!default plug:both

pcm.both {
    type copy
    slaves.a.pcm "hw:0,0"
    slaves.b.pcm "hw:0,1"
}

Nope.. same thing.. I can toggle between the 2 (which is more than I could do yesterday), but nada zippo for getting them both on at the same time...


as part of getting the Nvidia HDMI to work, I had to edit modprobe/sound.conf
Code:
Code:
alias snd-card-0 snd-hda-intel
alias sound-slot-0 snd-hda-intel
options snd-hda-intel enable_msi=0 probe_mask=0xffff,0xfff2
could anything in that be gumming up the works?
 
#12 ·

Quote:
Originally Posted by dmears /forum/post/19043389


In pulseaudio, in the volume control panel, you can choose (via a dropdown if I recall correctly) to have simultaneous outputs. We're in the middle of a move so I don't have access to my system, but I'll try to look it up once its up and running. I recall that there was another place where you had to enable simultaneous audio output but I can't remember where.


what version of ? (Ubuntu?) are you running? The docs I see say many of the Pulse control panels have been deprecated.. paman seemed to have the sink controls.. but is gone now
Image
 
#13 ·

Quote:
Originally Posted by zim2dive /forum/post/19048980


...could anything in that be gumming up the works?

I doubt it.


I'm not 100% on the syntax of that code that I gave you. You want something *similar* to this , but I think that there's a bunch of stuff in there that you wouldn't need.


You could probably do a few substitutions in that file and get it to work, namely, the "card" names in the 2 bottom ctl sections and the pcm "hw:..." numbers in the 2 pcm sections above them (aureon and intel8x0) if that makes any sense to you.


Go ahead and post the output of
Code:
Code:
aplay -L
and I'll look deeper into it.


EDIT: or I might have meant "aplay -l"
Image
 
#14 ·

Quote:
Originally Posted by mythmaster /forum/post/19049167


I doubt it.


I'm not 100% on the syntax of that code that I gave you. You want something *similar* to this , but I think that there's a bunch of stuff in there that you wouldn't need.


You could probably do a few substitutions in that file and get it to work, namely, the "card" names in the 2 bottom ctl sections and the pcm "hw:..." numbers in the 2 pcm sections above them (aureon and intel8x0) if that makes any sense to you.


Go ahead and post the output of
Code:
Code:
aplay -L
and I'll look deeper into it.


EDIT: or I might have meant "aplay -l"
Image

I'm willing to try the substitions on my own, but not sure what strings to use... here are both outputs
Image
Code:
Code:
>aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: Intel [HDA Intel], device 0: ALC883 Analog [ALC883 Analog]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: Intel [HDA Intel], device 1: ALC883 Digital [ALC883 Digital]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: NVidia [HDA NVidia], device 3: NVIDIA HDMI [NVIDIA HDMI]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
htpc:zimmy/tmp/makemkv_v1.5.8_oss >aplay -L
null
    Discard all samples (playback) or generate zero samples (capture)
front:CARD=Intel,DEV=0
    HDA Intel, ALC883 Analog
    Front speakers
surround40:CARD=Intel,DEV=0
    HDA Intel, ALC883 Analog
    4.0 Surround output to Front and Rear speakers
surround41:CARD=Intel,DEV=0
    HDA Intel, ALC883 Analog
    4.1 Surround output to Front, Rear and Subwoofer speakers
surround50:CARD=Intel,DEV=0
    HDA Intel, ALC883 Analog
    5.0 Surround output to Front, Center and Rear speakers
surround51:CARD=Intel,DEV=0
    HDA Intel, ALC883 Analog
    5.1 Surround output to Front, Center, Rear and Subwoofer speakers
surround71:CARD=Intel,DEV=0
    HDA Intel, ALC883 Analog
    7.1 Surround output to Front, Center, Side, Rear and Woofer speakers
iec958:CARD=Intel,DEV=0
    HDA Intel, ALC883 Digital
    IEC958 (S/PDIF) Digital Audio Output
hdmi:CARD=NVidia
    HDA NVidia, NVIDIA HDMI
    HDMI Audio Output
 
#15 ·
Ok, I found and modified this for you:

Code:
Code:
pcm.!default {
        type plug
        slave {
                pcm multi
        }
        ttable.0.0 1.0
        ttable.1.1 1.0
        ttable.0.2 1.0
        ttable.1.3 1.0
}

pcm.multi {
        type multi
        slaves.a.pcm "hw:0,0"
        slaves.a.channels 2
        slaves.b.pcm "hw:1,3"
        slaves.b.channels 2
        bindings.0.slave a
        bindings.0.channel 0
        bindings.1.slave a
        bindings.1.channel 1
        bindings.2.slave b
        bindings.2.channel 0
        bindings.3.slave b
        bindings.3.channel 1
}

ctl.!default {
        type hw
        card "Nvidia"
}
It needs to be adjusted for 6 channels on the HDMI, but I'm not sure how to do that with the ttables yet. This is the bindings part, though:
Code:
Code:
bindings.0.slave a
        bindings.0.channel 0
        bindings.1.slave a
        bindings.1.channel 1
        bindings.2.slave b
        bindings.2.channel 0
        bindings.3.slave b
        bindings.3.channel 1
        bindings.4.slave b
        bindings.4.channel 2
        bindings.5.slave b
        bindings.5.channel 3
        bindings.6.slave b
        bindings.6.channel 4
        bindings.7.slave b
        bindings.7.channel 5
 
#16 ·
I *think* this is correct now:

Code:
Code:
pcm.!default {
        type plug
        slave {
                pcm multi
        }
        ttable.0.0 1.0
        ttable.1.1 1.0
        ttable.0.2 1.0
        ttable.1.3 1.0
        ttable.2.4 1.0
        ttable.3.5 1.0
        ttable.4.6 1.0
        ttable.5.7 1.0

}

pcm.multi {
        type multi
        slaves.a.pcm "hw:0,0"
        slaves.a.channels 2
        slaves.b.pcm "hw:1,3"
        slaves.b.channels 6
        bindings.0.slave a
        bindings.0.channel 0
        bindings.1.slave a
        bindings.1.channel 1
        bindings.2.slave b
        bindings.2.channel 0
        bindings.3.slave b
        bindings.3.channel 1
        bindings.4.slave b
        bindings.4.channel 2
        bindings.5.slave b
        bindings.5.channel 3
        bindings.6.slave b
        bindings.6.channel 4
        bindings.7.slave b
        bindings.7.channel 5
}

ctl.!default {
        type hw
        card "Nvidia"
}
 
#21 ·
I saw the PA option that you mentioned dmears in Ubuntu Studio 10.04, but it's not in kxstudio. So, I don't know if it's just in older or newer versions of PA or if it only shows up depending on other settings. That would certainly be the easiest approach for zim.


I'm playing around with kxstudio now, and it has the most confusing audio setup possible. Everything runs through jack2 including PA. ALSA won't even work without jack2 running (from command-line mplayer anyway). I haven't succeeded with SPDIF passthrough yet, but it's not that big of a deal. I'll go back to Gentoo eventually for a long list of reasons.
 
#22 ·

Quote:
Originally Posted by mythmaster /forum/post/19051718


Anyway, one last thing: you should take PA out of the mix just to be sure that the .asoundrc is being properly used. Run "killall pulseaudio" then something like this:
Code:
Code:
mplayer -ao alsa http://streamer-mtc-aa03.somafm.com:80/stream/1018

I killed PA.. but forgot to try the -ao alsa... no change I will re-try -ao part

Quote:
Originally Posted by dmears /forum/post/19055094


Ouch! I hate when I get forced into an inelegant solution too. Re. the version of Ubuntu I'm using it's 10.04 - but I had this all set up in the 9.x versions.

I'm on 10.04

Quote:
Originally Posted by mythmaster /forum/post/19055462


I saw the PA option that you mentioned dmears in Ubuntu Studio 10.04

???? I'm searching backwards thru the thread and don't see any mention of Ubuntu studio? What would that do for me?


thanks!
 
#23 ·
No, I'm just saying that I saw it while using Ubuntu Studio. I don't know what he was using when he saw it.


Ubuntu Studio is just basically Ubuntu with a bunch of A/V production apps included. You can install it without all of them, though. I don't know what version of PA it uses or if it is a different version than Ubuntu uses.
 
#26 ·
hmmm.... ok, so I tried mplayer with -ao alsa... I tried all 4(?) .asoundrc variants... this one

Code:
Code:
pcm.!default {
        type plug
        slave {
                pcm multi
        }
        ttable.0.0 1.0
        ttable.1.1 1.0
        ttable.0.2 1.0
        ttable.1.3 1.0
        ttable.2.4 1.0
        ttable.3.5 1.0
        ttable.4.6 1.0
        ttable.5.7 1.0

}

pcm.multi {
        type multi
        slaves.a.pcm "hw:0,0"
        slaves.a.channels 2
        slaves.b.pcm "hw:1,3"
        slaves.b.channels 6
        bindings.0.slave a
        bindings.0.channel 0
        bindings.1.slave a
        bindings.1.channel 1
        bindings.2.slave b
        bindings.2.channel 0
        bindings.3.slave b
        bindings.3.channel 1
        bindings.4.slave b
        bindings.4.channel 2
        bindings.5.slave b
        bindings.5.channel 3
        bindings.6.slave b
        bindings.6.channel 4
        bindings.7.slave b
        bindings.7.channel 5
}

ctl.!default {
        type hw
        card "Nvidia"
}
gave me sound from both outputs... and was the only one that worked (the others either played thru 1 or the other).


So it can be done.. the question is what is stopping it from working more widely?