Digital Audio Tutorial

From MythTV Official Wiki
Revision as of 20:06, 15 July 2009 by Wwonderllama (talk | contribs)

Jump to: navigation, search

This is the new and simplified audio interface tutorial for digital sound with MythTV (Allen Edwards 2/17/2009)


The goal here is to set up myth to output the digital stream without doing anything with it. Myth passes this stream to ALSA where a new default configuration will cause that stream to pass to the sound card digital output also without modification. This will ensure that the fidelity of the digital stream is not changed by the computer and puts the burden of decoding, changing volume, determining speaker setup, etc on the sound processor preamp. This approach has the added advantage that digital sound will work with other applications such as Firefox and even Windows XP inside VirtualBox.

Update your system

Update your BIOS

It has been reported by some HDMI users that they could only get HDMI sound working after updating the bios. If you have trouble, you should give this a try. If you are building a system from scratch, this is not a bad idea anyway. If you have a working system you are just tweaking, I would hold off on this but it may be necessary.

Set up BIOS

If you have both HDMI and SPDIF outputs, you may need to make a selection in your BIOS

Update alsa

For HDMI you may need 1.0.18 or later. Straight spdif works with 1.0.16.

Check your version first by doing this:

$ cat /proc/asound/version

You can upgrade to the latest version in the depository by doing this:

$ sudo apt-get upgrade alsa

If that doesn't do it, you can upgrade your alsa configuration under mythbuntu 8.10 is with the script available in this thread.

Download the script AlsaUpgrade-1.0.x-rev-1.16.tar extract the script from the tar file and execute it like so...

 sudo ./ -di

It will take about 15 minutes to complete and afterwards everything works....

This will upgrade ALSA to version 1.0.19

Once you have your system upgraded, you should see the outputs listed in alsamixer that you want to use. You may have to configure your BIOS first. This is mainly for HDMI outputs. SPDIF has been supported for some time so it is unlikely that any new system would have a problem with spdif in this regard.

Update nvidia drivers

It has been suggested by some that you update the nvidia driver if you are using HDMI. Most have said this is not necessary. Upgrading broke one of my systems so you might do this only if needed. See AGP and XvMC note below.

Mythbuntu users can use envy and select install Nvidia driver.

$ envyng -t

You can check the version you have with this command

 cat /proc/driver/nvidia/version

Enable desired iec958 output

Run alsamixer and enable iec958. Use the right arrow key to see it.

$ alsamixer

Note: If you are using a board based on the ALC650 you might see three IEC selections in aslamixer. The last one is an input so that is not an issue. The second one is a slider that needs to be set to 0. See ALC650 wiki for more detail but a suggestion from that is to put this line in /etc/rc.d/rc.local.

amixer set 'IEC958 Playback AC97-SPSA' 0

Remove .asoundrc

Remove or rename .asoundrc if it exists. It probably does not exist.

$ locate .asoundrc


A note on these upgrades. It is good practice to upgrade your system if it is not working and to not upgrade it if it is working without problems.

Users have reported needing ALSA 1.0.18 and Nvidia 180.22 for HDMI on at least one MB. Others have reported HDMI working with Nvidia but ALSA 1.0.18 or later is necessary to get the HDMI output to show in alsamixer.

SPDIF works fine with versions at least several months older than these. I am running spdif with nvidia 173.14.12 and alsa 1.0.16

Set Myth up for digital sound

There are several ways to the same end on this but the method below is the most straight forward at this point.

Audio output device: ALSA:default
Passthrough output device: Default
Max Audio Channels: Stereo (MUST BE SET TO STEREO as of 6/2/2009 for passthrough to work)
Upmix: Passive
Enable AC3 to SPDIF passthrough checked
Enable DTS to SPDIF passthrough checked
Aggressive sound card buffering off
Use internal volume controls off

Discover what settings your sound card wants

run aplay -l and look for an output like this:

$ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: SB [HDA ATI SB], device 0: ALC883 Analog [ALC883 Analog]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: SB [HDA ATI SB], device 1: ALC883 Digital [ALC883 Digital]
  Subdevices: 0/1
  Subdevice #0: subdevice #0

If you have HDMI, you might see something like this:

  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: NVidia [HDA NVidia], device 3: NVIDIA HDMI [NVIDIA HDMI]

You need to find the digital output you want to use, Digital or HDMI and note the card and device numbers. In my case it is card 0 and device 1

Set up ALSA for these settings

Edit the ALSA config files using your favorite editor. For example:

 $ sudo nano /etc/asound.conf

And edit it to match this:

   pcm.!default {
       type hw
       card 0
       device 1

Where you use the card and device numbers from the aplay -l step.

If you do not get sound out of your processor with the above setup, it could be because the processor is having an issue with the formatting. I tested the above on two processors and one worked, one did not. Adding a format line made it so both processors I tested with work. The format line says serial, 32 bit, least significant bit first.

  pcm.!default {
     type plug
     slave {
        pcm "hw:0,1"
        format S32_LE

The following two plugins also worked in my system. These plugins do extensive formatting to insure the data meets the standard. I don't know if it is better to use them or not. For now I am using the above version as it works for all my programs (MythTV, MythMusic, Firefox) and both my processors.

  pcm.!default {
     type plug
     slave.pcm "iec958"

This also worked and is what I am now using for my spdif setup (not HDMI). I was having trouble with low volume static out of the speakers when there was no program playing (menus on screen). In my preliminary test, this helped. I will update on this issue if anything changes. The spdif plug incorporates the format S32_LE so adding that is not needed if you use spdif. I do not know if this will work if the digital audio is not card 0 port 1 as that is what I have.

  pcm.!default {
     type plug
     slave.pcm "spdif"

I am looking forward to having someone with an HDMI system tell me if either or both of these next two files work.

  pcm.!default {
     type plug
     slave.pcm "hdmi"

and the following where the iec958=1 corresponds to the desired output in alsamixer

  pcm.!default {
     type plug
     slave.pcm "iec958=1"

If you hear digital noise or what sounds like static from an old sci-fi movie, it is the digital spdif data stream being sent to the analog part of your sound card. Check your output aplay -l output again for the digital device.

Special system specific things


Some TVs and video cards interact such that the TV thinks the audio is imbedded in the HDMI stream and there you are with SPDIF or Analog and no sound. Some TVs have settings to deal with this and in other cases you need to deal it with the computer. This wiki might help: Configuring_Analog_Sound_DVI_to_HDMI

Zotac ION

ProjectBlog : Zotac ION posts - HDMI Sound post


If you have problems, test without myth. Here are some example test lines:

$ mplayer -ao alsa:device=hw=0.3 -afm hwac3 /some/dolbydigital/audio/file.wav
$ mplayer -ac hwac3 -ao alsa:device=iec958=1 -vo xv -fs /some/dolbydigital/audio/file.mpg
$ aplay -Dplughw:0,1 file.wav
$ aplay -Dspdif file.wav
$ aplay -Diec958  file.wav
$ mplayer -cache 500 -cdrom-device /dev/cdrom cdda://

The last line will play a CD from the drive. It will play if everything is set up correctly. Use these tests to determine if the problem is in the hardware, the config file, or the program.

AGP and XvMC

Nvidia drivers for some time and up to at least 173.14.13 do not work with XvMC. The work around is to disable XvMC with this option:

   Option "NvAGP"  "0"

There is a discussion on it here: NVNEWS


Go into the BIOS and disable the onboard audio - crazy as it sounds.


$aplay -l

And look for this output:

**** List of PLAYBACK Hardware Devices ****
card 0: HDMI [HDA ATI HDMI], device 3: ATI HDMI [ATI HDMI]
  Subdevices: 0/1
  Subdevice #0: subdevice #0

And set up your asound.conf file like this:

pcm.!default {
      type hw
      card 0
      device 3


A m3n78-em user has posted information on using this board. spdif and m3n78-em

I searched for 'ALC1200 alsa' and found the answer on the alsa-user mailing list: S/PDIF-Out on Asus M3A-H/HDMI with ALC1200

Where you make the changes depends on your distribution. I use OpenSuse and tried to use Yast2, but for some reason it was not able to save the changes. I ended up adding this to /etc/modprobe.d/sound

options snd-hda-intel model=6stack-dig 

in MythBuntu i added the same line to /etc/modprobe.d/alsa-base, or, i should say, the script i ran to update my alsa drivers added it for me.

He added this note that may be of interest:
When using the onboard graphics on this motherboard I also got lots of "WriteAudio: buffer underrun" on some HD channels and more or less unwatchable video. After installing a Gainward 8400GS 512MB card this problem is solved.


If you are running Fedora, remove pulseaudio and all its files. There was a post that outlined the process but it is gone. A copy is here: RemovePulseAudio.