Digital Audio Tutorial

From MythTV Official Wiki
(Redirected from AllensDigitalAudioHowto)
Jump to: navigation, search

Important.png Note: This tutorial was written for version 0.21, and the MythTV audio options page may appear different in later versions.

Overview

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

Note that this may be an older version than your Alsa software if you use a packaged installation of Linux. Fedora 10 stock kernel (2.6.27) is too old, but Fedora 11 stock kernel (2.6.30) is adequate.

Debian-based users may be able to upgrade to the latest version in the depository by doing this:

$ sudo apt-get upgrade alsa

If that doesn't do it, recent users may be able to get the latest backported drivers from the daily ASLA ppa.

Users of older systems can upgrade their alsa configuration under Mythbuntu 8.10 with the script available in http://ubuntuforums.org/showthread.php?p=6589810#post6589810 this thread. After downloading the script AlsaUpgrade-1.0.x-rev-1.16.tar, extract the script from the tar file and execute it like so...

 sudo ./AlsaUpgrade-1.0.x-rev-1.16.sh -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 alaamixer. 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

If you see 3 S/PDIF sliders (such as on my onboiard nVidia 7100/630i), you need to ensure that these are not muted. Muted sliders show "MM" next to them, and to clear this, you need to press "M" to change the setting to "OO". Note that the volume setting is not changeable for digital channels.

Remove .asoundrc

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

$ locate .asoundrc

Notes

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 177.xxx 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

After any change to asound.conf, you must either reboot or run

 $ sudo /etc/init.d/alsa-utils restart

before changes will take effect.

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. (mikeholden: this setting works for my onboard 7100/630i over HDMI using stock Fedora 11, once alsamixer is set up with unmuted S/PDIF channels)

  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.

MythTV 0.23 and trunk

This version treats audio differently.

Apparently, you will need a control port definition in asound.conf. Adjust the card number to match your system.

  ctl.!default {
     type hw
     card 0
  }

Special system specific things

DVI to HDMI

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

And from Jim comes this piece of advice: don't put 'Option "UseEDID" "False" ' in your xorg.conf file. Jean-Yves says it isn't necessary. I have no idea but if you get stuck it is something to fool with.

Zotac ION

For additional experiences while setting up ALSA on the ZOTAC IONITX-A-U for HDMI output please check out the links below.

THESE LINKS ARE DEAD AT THE MOMENT

Some additional information can be found in this post: [1]

I'm using XFCE and couldn't get the HDMI audio to work until I installed the 'mixer' into my panel. From there, I hit the 'switches' button and selected the third option entitled, "IEC958 1" which I believe corresponds to the HDMI option. After doing that, all audio magically began to work.

Troubleshooting

If you have problems, test without myth using a .wav track copied from one of your CDs, or just play the CD itself. 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

GA-ma78gm-s2h

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

Then

$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
  }

GA-73PVM-s2h

Has onboard nVidia 7100/630i.

Go into the BIOS and set onboard audio and HDMI audio to "auto".

Then:

$ aplay -l

**** List of PLAYBACK Hardware Devices ****
card 0: NVidia [HDA NVidia], device 0: ALC885 Analog [ALC885 Analog]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: NVidia [HDA NVidia], device 1: ALC885 Digital [ALC885 Digital]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: NVidia [HDA NVidia], device 3: NVIDIA HDMI [NVIDIA HDMI]
  Subdevices: 0/1
  Subdevice #0: subdevice #0

Note the 3rd item is HDMI. You will need a recent alsa/asound version as detailed earlier, otherwise only the 1st 2 items will be displayed.

Set up your asound.conf file like this:

pcm.!default {

   type plug
   slave.pcm "hdmi"

}

Also, ensure your S/PDIF channels are unmuted in alsamixer.

m3n78-em

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.

Fedora

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.