Simultaneous Audio Output to Independent Devices

From MythTV Official Wiki
Jump to: navigation, search

To send sound to both DVI and HDMI via ALSA

eg. to TV and Amplifier simultaneously using an .asoundrc file in your home directory.

Firstly a note or two -

  1. Sound CAN be sent over DVI, if you sound card supports it. Preferably use a DVI to HDMI connector / cobale (often cheaper than an HDMI to HDMI cable)
  2. Your sound device (presumably a graphics card with built in sound eg. NVidia GT430 as used here) needs to treat DVI and HDMI connectors similarly
  3. The sound device (graphics card) needs to support digital sound (though analog sound should work the same way afaik)

Secondly, Pulse is probably easier if that is what you use, but this is useful for those of us using ALSA

The asoundrc file

# .asoundrc
# Add to your home directory
# works with NVidia GT430 ... once the video card itself is set to work correctly
#
# Note that motherboard sound has been disabled so graphics card is card 0 (likely to be card 1 if motherboard sound is enabled)
# Type "aplay -l" into a terminal to list the sound devices on your machine, use the output to adjust this file if necessary eg. card number
#
# Default ALSA to send to both DVI and HDMI
pcm.!default {
    type plug
    slave {
        # The following line actually does the work
        pcm "hdmi_dvi_both"
    }
}
# DVI connection on GT430
pcm.!hdmi3 {
    type hw
    card 0
    device 3
    channels 2
}
# Doesn't seem to be necessary, just for completeness
ctl.!hdmi3 {
    type hw
    card 0
    device 3
    channels 2
}
pcm.!hdmi7 {
    type hw
    card 0
    device 7
    channels 2
}
pcm.!hdmi8 {
    type hw
    card 0
    device 8
    channels 2
}
# HDMI Connection on GT430
pcm.!hdmi9 {
    type hw
    card 0
    device 9
    channels 2
}
# Doesn't seem to be necessary, just for completeness
ctl.!hdmi9 {
    type hw
    card 0
    device 9
    channels 2
}

pcm.multi_dig {
    type multi
    # Define DVI slave
    slaves.a {
        pcm "hdmi3"
        # In this version, only pass 2 channels (like SPDIF)
        channels 2
    }
    # Define HDMI slave
    slaves.b {
        pcm "hdmi9"
        # In this version, only pass 2 channels (like SPDIF)
        channels 2
    }
    # Bind the 2 DVI channels to a name ie "a"
    bindings.0.slave a
    bindings.0.channel 0
    bindings.1.slave a
    bindings.1.channel 1

    # Bind the 2 HDMI channels to a name ie "b"
    bindings.2.slave b
    bindings.2.channel 0
    bindings.3.slave b
    bindings.3.channel 1
}
# Define the routing which actually sends the signal to both DVI and HDMI
pcm.hdmi_dvi_both {
    type route
    slave {
         pcm "multi_dig"
         # The channels definition is critical to define the total number of channels out (2 sets of 2)
         channels 4
    }
    # The first dot after "ttable" defines the channel out 
    # The second dot defines the channel as bound above in the "multi-dig" definition
    # Define 4 channels out in total, 2 each for DVI and HDMI
    ttable.0.0 1
    ttable.1.1 1
    ttable.0.2 1
    ttable.1.3 1
}
# You may have to mess around with your TV and Amp depending on what they support
# My current setup is MythTv v 0.23
# my amp supports Dolby, DTS and AC3
# my TV support DTS and AC3 ... but NOT Dolby (just get nasty "noise" if "dolby" selected in MythTv)
# I sent HDMI to TV because of default colour space etc
# and DVI to amp cause its not sensitive to colour etc. (just used for sound)
# BUT need to tell NVidia Config to send video to both (default is DVI only)

Paste the above file into your home directory as ".asoundrc"

MythTv Setup

In the MythTv menus go to

MythTv Setup / General / Audio System

and set the "Audio output device" to ALSA:default or ALSA:hdmi_dvi_both


Depending on your TV and Amp you may also need to change the settings for 5.1 sound. Your devices may or may not support

  1. AC3 (nothing else selected)
  2. Dolby
  3. DTS

In my case,

  1. TV supports AC3 and DTS but NOT Dolby
  2. Amp supports all the above (but not 7.1 bitstream)

So I selected 5.1 sound and DTS, but NOT Dolby in MythTv Audio setup Now I can use either TV sound or Amp sound or both