Kodi Community Forum

Full Version: Almost solved: PROPER Dual Audio on Linux
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Anyone have a suggestion to get hdmi and optical to output surround at the same time? Would this work? Or would I have to convert the audio to be able to output 6 channels via spdif? I'm assuming I could streamline this a lot more, but if I do need to convert the audio, this should get me started in the correct direction.

Code:
# asound.conf for Dual Audio - HDMI (5.1) + Optical out (5.1)
# by puntloos
# This should allow you to send audio to two devices, one HDMI (for surround) and one optical
# 1- Location of asound.conf in OpenELEC is ./storage/.config/asound.conf - create or modify that file.  
# 2- Modify the bottom part of the file to match your hardware

pcm.!default {
        type plug
        slave {
                pcm "both_digital"
        }
}

# First we create a 'both' route, that has 12 channels
pcm.both_digital {
        type route
        slave {
                pcm multi
                channels 12
        }
        # And we route the channels 1:1
        # 6 inputs (0-5) get mapped into 12 outputs (0-11)
        # (this is how we copy channels)
        # Channels are corrected for ION1
        ttable.0.0 1.0
        ttable.1.1 1.0
        ttable.2.4 1.0
        ttable.3.5 1.0
        ttable.4.2 1.0
        ttable.5.3 1.0
        ttable.0.6 1.0
        ttable.1.7 1.0
        ttable.2.8 1.0
        ttable.3.9 1.0
        ttable.4.10 1.0
        ttable.5.11 1.0
}

# Then define a multi device that splits the 12-channel input
# Into 2x 6 output

pcm.multi {
        type multi
        slaves.a {
                pcm "hdmi_hw"
                channels 6
        }
        slaves.b {
                pcm "optical_hw"
                channels 6
        }

    # Bind stuff to the HDMI outputs
        bindings.0.slave a
        bindings.0.channel 0
        bindings.1.slave a
        bindings.1.channel 1
        bindings.2.slave a
        bindings.2.channel 2
        bindings.3.slave a
        bindings.3.channel 3
        bindings.4.slave a
        bindings.4.channel 4
        bindings.5.slave a
        bindings.5.channel 5

        # And to the Optical outputs
        bindings.6.slave b
        bindings.6.channel 0
        bindings.7.slave b
        bindings.7.channel 1
        bindings.8.slave b
        bindings.8.channel 2
        bindings.9.slave b
        bindings.9.channel 3
        bindings.10.slave b
        bindings.10.channel 4
        bindings.11.slave b
        bindings.11.channel 5
}

# And here is my actual hardware
# Note that this is linked to the output of 'aplay -l'
# HDMI output
pcm.hdmi_hw {
        type hw
        card 0
        device 3
        channels 6
}

# Optical output
pcm.optical_hw {
        type hw
        card 0
        device 1
        channels 6
}

Thanks!
-Erik
Thx looking forward to try it out Smile
(2013-06-03, 20:37)Hawaltie Wrote: [ -> ]
(2013-06-01, 08:31)Bjur Wrote: [ -> ]Anyone that can give a hint?

Bjur,

It seems that we have a similar config. This is my asound.conf offering audio on both HDMI and SPDIF. It works on OE 3.0.3

Code:
# asound.conf for Dual Audio - HDMI (2.0) + Stereo out
# by puntloos
# This should allow you to send audio to two devices, one HDMI (for surround) and one other device, which can be digital or even analog outputs
# 1- Location of asound.conf in OpenELEC is ./storage/.config/asound.conf - create or modify that file.  
# 2- Modify the bottom part of the file to match your hardware

pcm.!default {
        type plug
        slave {
                pcm "both_digital"
        }
}

# First we create a 'both' route, that has 4 channels
pcm.both_digital {
        type route
        slave {
                pcm multi
                channels 4
        }
        # And we route the channels 1:1
        # 2 inputs (0-1) get mapped into 4 outputs (0-3)
        # (this is how we copy channels)
        ttable.0.0 1.0
        ttable.1.1 1.0
        ttable.0.2 1.0
        ttable.1.3 1.0
}

# Then define a multi device that splits the 4-channel input
# Into 2x 2 output

pcm.multi {
        type multi
        slaves.a {
                pcm "hdmi_hw"
                channels 2
        }
        slaves.b {
                pcm "dac_hw"
                channels 2
        }

    # Bind stuff to the HDMI outputs
        bindings.0.slave a
        bindings.0.channel 0
        bindings.1.slave a
        bindings.1.channel 1

        # And to the DAC outputs
        bindings.2.slave b
        bindings.2.channel 0
        bindings.3.slave b
        bindings.3.channel 1
}

# And here is my actual hardware
# Note that this is linked to the output of 'aplay -l'
# HDMI output
pcm.hdmi_hw {
        type hw
        card 0
        device 3
        channels 2
}

# Stereo output
pcm.dac_hw {
        type hw
        card 1
        device 1
        channels 2
}

Thx looking forward to try it out Smile
(2013-06-03, 20:37)Hawaltie Wrote: [ -> ]
(2013-06-01, 08:31)Bjur Wrote: [ -> ]Anyone that can give a hint?

Bjur,

It seems that we have a similar config. This is my asound.conf offering audio on both HDMI and SPDIF. It works on OE 3.0.3

Code:
# asound.conf for Dual Audio - HDMI (2.0) + Stereo out
# by puntloos
# This should allow you to send audio to two devices, one HDMI (for surround) and one other device, which can be digital or even analog outputs
# 1- Location of asound.conf in OpenELEC is ./storage/.config/asound.conf - create or modify that file.  
# 2- Modify the bottom part of the file to match your hardware

pcm.!default {
        type plug
        slave {
                pcm "both_digital"
        }
}

# First we create a 'both' route, that has 4 channels
pcm.both_digital {
        type route
        slave {
                pcm multi
                channels 4
        }
        # And we route the channels 1:1
        # 2 inputs (0-1) get mapped into 4 outputs (0-3)
        # (this is how we copy channels)
        ttable.0.0 1.0
        ttable.1.1 1.0
        ttable.0.2 1.0
        ttable.1.3 1.0
}

# Then define a multi device that splits the 4-channel input
# Into 2x 2 output

pcm.multi {
        type multi
        slaves.a {
                pcm "hdmi_hw"
                channels 2
        }
        slaves.b {
                pcm "dac_hw"
                channels 2
        }

    # Bind stuff to the HDMI outputs
        bindings.0.slave a
        bindings.0.channel 0
        bindings.1.slave a
        bindings.1.channel 1

        # And to the DAC outputs
        bindings.2.slave b
        bindings.2.channel 0
        bindings.3.slave b
        bindings.3.channel 1
}

# And here is my actual hardware
# Note that this is linked to the output of 'aplay -l'
# HDMI output
pcm.hdmi_hw {
        type hw
        card 0
        device 3
        channels 2
}

# Stereo output
pcm.dac_hw {
        type hw
        card 1
        device 1
        channels 2
}
(2013-06-05, 09:43)Bjur Wrote: [ -> ]Thx looking forward to try it out Smile
(2013-06-03, 20:37)Hawaltie Wrote: [ -> ]
(2013-06-01, 08:31)Bjur Wrote: [ -> ]Anyone that can give a hint?

Bjur,

It seems that we have a similar config. This is my asound.conf offering audio on both HDMI and SPDIF. It works on OE 3.0.3

Code:
# asound.conf for Dual Audio - HDMI (2.0) + Stereo out
# by puntloos
# This should allow you to send audio to two devices, one HDMI (for surround) and one other device, which can be digital or even analog outputs
# 1- Location of asound.conf in OpenELEC is ./storage/.config/asound.conf - create or modify that file.  
# 2- Modify the bottom part of the file to match your hardware

pcm.!default {
        type plug
        slave {
                pcm "both_digital"
        }
}

# First we create a 'both' route, that has 4 channels
pcm.both_digital {
        type route
        slave {
                pcm multi
                channels 4
        }
        # And we route the channels 1:1
        # 2 inputs (0-1) get mapped into 4 outputs (0-3)
        # (this is how we copy channels)
        ttable.0.0 1.0
        ttable.1.1 1.0
        ttable.0.2 1.0
        ttable.1.3 1.0
}

# Then define a multi device that splits the 4-channel input
# Into 2x 2 output

pcm.multi {
        type multi
        slaves.a {
                pcm "hdmi_hw"
                channels 2
        }
        slaves.b {
                pcm "dac_hw"
                channels 2
        }

    # Bind stuff to the HDMI outputs
        bindings.0.slave a
        bindings.0.channel 0
        bindings.1.slave a
        bindings.1.channel 1

        # And to the DAC outputs
        bindings.2.slave b
        bindings.2.channel 0
        bindings.3.slave b
        bindings.3.channel 1
}

# And here is my actual hardware
# Note that this is linked to the output of 'aplay -l'
# HDMI output
pcm.hdmi_hw {
        type hw
        card 0
        device 3
        channels 2
}

# Stereo output
pcm.dac_hw {
        type hw
        card 1
        device 1
        channels 2
}

Thx looking forward to try it out Smile
(2013-06-03, 20:37)Hawaltie Wrote: [ -> ]
(2013-06-01, 08:31)Bjur Wrote: [ -> ]Anyone that can give a hint?

Bjur,

It seems that we have a similar config. This is my asound.conf offering audio on both HDMI and SPDIF. It works on OE 3.0.3

Code:
# asound.conf for Dual Audio - HDMI (2.0) + Stereo out
# by puntloos
# This should allow you to send audio to two devices, one HDMI (for surround) and one other device, which can be digital or even analog outputs
# 1- Location of asound.conf in OpenELEC is ./storage/.config/asound.conf - create or modify that file.  
# 2- Modify the bottom part of the file to match your hardware

pcm.!default {
        type plug
        slave {
                pcm "both_digital"
        }
}

# First we create a 'both' route, that has 4 channels
pcm.both_digital {
        type route
        slave {
                pcm multi
                channels 4
        }
        # And we route the channels 1:1
        # 2 inputs (0-1) get mapped into 4 outputs (0-3)
        # (this is how we copy channels)
        ttable.0.0 1.0
        ttable.1.1 1.0
        ttable.0.2 1.0
        ttable.1.3 1.0
}

# Then define a multi device that splits the 4-channel input
# Into 2x 2 output

pcm.multi {
        type multi
        slaves.a {
                pcm "hdmi_hw"
                channels 2
        }
        slaves.b {
                pcm "dac_hw"
                channels 2
        }

    # Bind stuff to the HDMI outputs
        bindings.0.slave a
        bindings.0.channel 0
        bindings.1.slave a
        bindings.1.channel 1

        # And to the DAC outputs
        bindings.2.slave b
        bindings.2.channel 0
        bindings.3.slave b
        bindings.3.channel 1
}

# And here is my actual hardware
# Note that this is linked to the output of 'aplay -l'
# HDMI output
pcm.hdmi_hw {
        type hw
        card 0
        device 3
        channels 2
}

# Stereo output
pcm.dac_hw {
        type hw
        card 1
        device 1
        channels 2
}

Still no success have tried many hours now without default showing up.

I don't have any asound.conf file, so have tried to nano ./storage/.config/asound.conf but it said it failed when i wanted to save.
So I did a mkdir ./storage
cd ./storage
mkdir .config
cd .config
nano asound.conf
and then I could save, but still nothing...

Any last ideas from anyone before I throw in the towel??

I'm on E350 Zacate and Openelec 3.03 have also tried 3.04.
Hello Bjur,
maybe is a stupid answer but you wrote "it said it failed when i wanted to save" did you try with su or sudo to have the good privilege..
Thanks for the answer. No can you give an example?
I was able to save when I created the directorys one by one, so it should be the same..
Seems to me that you are starting in the wrong directory. When you are loggin into openelec try to get to the root folder (cd ..).
hello, i would say

sudo nano ./storage/.config/asound.conf

you will use admin privilege to save your file.
Thanks for the suggestions. I will try it out when I have some time.
(2013-05-16, 23:49)puntloos Wrote: [ -> ]
(2013-05-16, 23:46)omobeanz Wrote: [ -> ]
(2013-05-16, 12:38)puntloos Wrote: [ -> ]The problem is that the stereo channel currently is the 'sum of all channels' - meaning that indeed sound that is 100% rear also comes through my front speakers.
Perhaps this is what someone might want who wants to watch a movie on a stereo system, but in MY case I have different needs. My intended setup (or one of them, at least) will only send front left, center and front-right to the stereo channel. The trouble though is that with mixing multiple channels (especially 5.1 or 7.1) into two means you could go over the channel's limit. You need to pre-amplify (or rather attenuate) the channels before mixing, else you might run into clipping IF the mix is already pretty loud, which is common for TV shows and uncommon for movies.

This is why Matthias T for example used this mixing matrix:
Code:
# Different routing setting taken from http://wiki.ubuntuusers.de/.asoundrc
  ttable.0.0 1
  ttable.1.1 1
  ttable.2.0 0.707
  ttable.3.1 0.707
  ttable.4.0 0.5
  ttable.4.1 0.5
  ttable.5.0 0.5
  ttable.5.1 0.5

Suggest you try something like this and report back =)

Hmmm, this is different to my understanding of how that table works. I thought my setup was sending only channel 0 and 1 to stereo, meaning front right and left only, then sending 7.1 (channels 0, 1, 2, 3, 4, 5, 6, 7, 8) over HDMI. At least that's how it seems to be when I tested it but I could be completely wrong.

Well no this is a different step. What my quote does is downmixing to stereo. I'm not sure if that is exactly what you want mind you, (or if it does what Matthias wants) but the point is that what you describe sounds like the "sum of the data" you are sending to read exceeds the maximum, so to fix your problem I think you need to 'send less' somehow.

At least that's my theory on what you're hearing. I could be completely wrong too, but just to experiment I would suggest just dropping all inputs to the channels you find distorted to half.
Hey there:
As an explanation for this setup I want to say that the HDMI part is directly connected to the TV. That means I only use the TV sound as a "nighttime-mode", but for this setup I needed to downmix a 5.1 source to stereo, because the dialogues are mostly mixed to the center. so I put the volumes of the sub and the center to .707 and the rears at .5 to the left and right. Until now I didn't experienced clipping or that sort, the dialogues are clear and the bass is present.
For the rest I have a 5.1 system directly hooked to the sound-card (3-jack-out) without a receiver or anything, thats why I can't use passtrough. Until now XMBC-Alpha4 (06-01-2013) I can't find the digital part in XBMC anymore, so I can't test your settings...any ideas?

I don't understand omobeanz-setup either. What happens If you have a 5.1 source but only a stereo-output (TV-for example) which can not downmix by itself? is there any downmixing in the configfile?

EDIT: I can test again! I had to purge pulseaudio because it messed up the XBMC-settings
Just wanted to say that 3po's edited stereo conf is working perfectly on my Arctic MC001 on Openelec 3.06 and Frodo 12.2. Many thanks to Puntloos and c3po! Smile
Hi Everyone

Sorry I know this is probably the wrong place to ask but it seems like you guys have made some progress. I did search but couldnt find a post or anything.

Has anyway tried getting dual audio output working on a windows 7 install?

Thanks
I have been using XBMC Eden on my Acer Revo 1600 (I think!) running Ubuntu 12.04 LTS for a while now and everything has been hunky dorey - I've upgraded to Frodo (12.2 stable Git: 32b1a5e) for the better PVR support and most stuff is working fine., however the audio isn't working properly.

There are three audio outputs on this machine
1) The HDMI Audio Output (used when watching TV)
2) The Front 3.5mm audio jack (used listening to music on the AVAmp or watching a film)
3) A USB FM Transmitter used for listening to music in the garden.

The issue I have been having is that after a while (often on a channel change, but could be 10 seconds into a video or 2 hours) the audio starts sounding rough (a bit like listening to a weak DAB digital radio signal before the bubbling mud gets too loud) and the log file is full of line after line of
Code:
20:48:31 T:3004508992   ERROR: CAESinkALSA::HandleError(snd_pcm_writei(2)) - snd_pcm_writei returned -11 (Resource temporarily unavailable)

If I change the audio output from "Default (HDA NVidia ALC662 rev1 Analog) ()" to "HDA Nvidia (both) (), ALC662 rev1 Analog)" it stops for a short while and then does it again.

If I change the adaptor to any of
  • B-LINK USB Audio (Audio), S/PDIF - FM Transmitter Only
  • B-LINK USB Audio (Audio), Analog - FM Transmitter Only
  • HDA NVidia, HDMI - TV Only
  • HDA NVidia, ALC662 rev1 Analog - TV Only
  • B-LINK USB Audio (), Analog - FM Transmitter Only
  • HDA NVidia (dfront), ALC662 rev1 Analog - AV Amp Only
  • HDA NVidia (0), HDMI 0 - TV Only
I don't have the audio glitches, but as the pink italicised text shows I only get audio on the one output.

Any ideas how to get this working properly?

Some additional info below:-

uname -a
Code:
Linux williams 3.6.0-030600-generic #201209302035 SMP Mon Oct 1 00:43:10 UTC 2012 i686 i686 i386 GNU/Linux

cat /etc/lsb-release
Code:
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=12.04
DISTRIB_CODENAME=precise
DISTRIB_DESCRIPTION="Ubuntu 12.04 LTS"

Code:
## uninstall Pulse Audio!

pcm.!default plug:both

ctl.!default
{
    type hw
    card HDMI
}

pcm.both
{
    type route;
    slave.pcm
    {
        type multi;
        # 3.5mm audio jack
        slaves.a.pcm "dfront";
        # HDMI Output
        slaves.b.pcm "dmixer";
        # FM Transmitter
        slaves.c.pcm "dfm";
        
        slaves.a.channels 2;
        slaves.b.channels 2;
        slaves.c.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;
        
        bindings.4.slave c;
        bindings.4.channel 0;
        bindings.5.slave c;
        bindings.5.channel 1;
    }
    # Translation.channel.bindingnum 1
    ttable.0.0 1;
    ttable.1.1 1;
    
    ttable.0.2 1;
    ttable.1.3 1;
    
    ttable.0.4 1;
    ttable.1.5 1;
        
}

ctl.both
{
    type hw;
    card HDMI;
}


pcm.dmixer {
    type dmix
    ipc_key 1024
    slave {
        pcm "hw:0,3"
        period_time 0
        period_size 1024
        buffer_size 8192
        #periods 128
        #rate 44100
        rate 48000
     }
     bindings {
        0 0
        1 1
     }
}

# speaker-test -Dpcm.both -c2 -twav
pcm.dfront {
    type dmix
    ipc_key 1024
    slave {
        pcm "hw:0,0"
        period_time 0
        period_size 1024
        buffer_size 8192
        #periods 128
        #rate 44100
        rate 48000
     }
     bindings {
        0 0
        1 1
     }
}

pcm.dfm {
    type dmix
    ipc_key 1024
    slave {
        pcm "hw:1,0"
        period_time 0
        period_size 1024
        buffer_size 8192
        #periods 128
        #rate 44100
        rate 48000
     }
     bindings {
        0 0
        1 1
     }
}

ctl.dmixer
{
    type hw;
    card "HDMI"
}

ctl.dfront
{
    type hw;
    card "FRONT"
}

ctl.dfm
{
    type hw;
    card "FMRADIO"
}

cat ~/.xbmc/userdata/advancedsettings.xm
Code:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<advancedsettings>
    <splash>true</splash>
    <loglevel>1</loglevel>
    <network>
        <cachemembuffersize>2097152</cachemembuffersize>
    </network>
    <video>
        <ignoresecondsatstart>15</ignoresecondsatstart>
    </video>
       <audio>
        <resample>0</resample>
        <audiophile>1</audiophile>
        <audiosinkbufferdurationmsec>200</audiosinkbufferdurationmsec>
        <allowtranscode44100>0</allowtranscode44100>
        <streamsilence>1</streamsilence>

        <dont_resample>1</dont_resample>
        <audiophile>1</audiophile>
    </audio>
</advancedsettings>
Note - none of the audio stuff was in originally, added <audio><streamsilence>0</streamsilence></audio> to no avail, then the above - also to no avail Sad
I am trying to get dual audio outputs. I have installed XBMCbuntu on my box (version 12.2). My AV receiver has two zones. The first I want to use HDMI, and the second can only use audio source, usually analog stereo signals. I would like to try the asound.conf solution posted at the beginning of this post, but am a bit confused about where to place this file. It looks like the directory structure is different between OpenElec and XBMC running on a full Linux install. Can some one direct me to where to place the file in my case?
asound.conf goes in /etc/
Hey kevjs1982

I have the same problem, choppy/dirty audio with the same entries in the log when that happens.

I think that it might be because of the sample rate, different on your 2 outputs (this is what I am going to try, I will post results)

Quote:pcm.hdmi_hw {
type hw
card 0
device 3
channels 2
rate 48000
}

# Stereo output
pcm.dac_hw {
type hw
card 1
device 0
channels 2
rate 48000
}

I could find this, pasting the error message on google:

http://www.overclock.net/t/527916/gentoo-sound-problems

This however doesn't explain why it works for a while...

The error message I get:

Quote:13:38:38 T:2940042048 ERROR: CAESinkALSA::HandleError(snd_pcm_writei(2)) - snd_pcm_writei returned -11 (Resource temporarily unavailable)
13:38:38 T:2940042048 ERROR: CAESinkALSA::HandleError(snd_pcm_writei(1)) - snd_pcm_writei returned -11 (Resource temporarily unavailable)
13:38:38 T:2940042048 ERROR: CAESinkALSA::HandleError(snd_pcm_writei(2)) - snd_pcm_writei returned -11 (Resource temporarily unavailable)
13:38:38 T:2940042048 ERROR: CAESinkALSA::HandleError(snd_pcm_writei(1)) - snd_pcm_writei returned -11 (Resource temporarily unavailable)
13:38:38 T:2940042048 ERROR: CAESinkALSA::HandleError(snd_pcm_writei(2)) - snd_pcm_writei returned -11 (Resource temporarily unavailable)
13:38:38 T:2940042048 ERROR: CAESinkALSA::HandleError(snd_pcm_writei(1)) - snd_pcm_writei returned -11 (Resource temporarily unavailable)
13:38:38 T:2940042048 ERROR: CAESinkALSA::HandleError(snd_pcm_writei(2)) - snd_pcm_writei returned -11 (Resource temporarily unavailable)
Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15