The Digital Sound entry in this Wiki is very complete. However, from my experience, it was a lot more than I needed. As such, some of the important information got lost.

+

The [[Configuring Digital Sound]] entry in this Wiki is very complete. However, from my experience, it was a lot more than I needed. As such, some of the important information got lost.

By default, with Fedora Core 5, all of the correct entries are automatically put together for you. Hence, there is no need for a local .asoundrc or /etc/asound.conf in order to send digital audio out via the SPDIF adapter. All you need to reference '''ALSA:spdif''' when performing your tests. But this is '''not''' the end solution, so please, read onwards.

By default, with Fedora Core 5, all of the correct entries are automatically put together for you. Hence, there is no need for a local .asoundrc or /etc/asound.conf in order to send digital audio out via the SPDIF adapter. All you need to reference '''ALSA:spdif''' when performing your tests. But this is '''not''' the end solution, so please, read onwards.

Line 57:

Line 57:

Testing the output with a snippet of an ac3 file that I had on hand (you can pull one off of a DVD if need be) produced audible static:

Testing the output with a snippet of an ac3 file that I had on hand (you can pull one off of a DVD if need be) produced audible static:

<pre>aplay -D ALSA:spdif test.ac3</pre>

<pre>aplay -D ALSA:spdif test.ac3</pre>

−

This is, actually, a good sign. Testing with "mplayer" (see the "Testing" section near the end of this document) should output digital AC3 sound which will tell you that the device is working. You can also test with a MP3 file and get audio (maybe..), but it will be slightly faster due to the difference between the MP3's 44.1khz and the expected digital audio at 48khz. Don't worry.. this will get resolved.

+

This is, actually, a good sign. Testing with "mplayer" (see the "Testing" section near the end of this document) should output digital AC3 sound which will tell you that the device is working. You can also test with a MP3 file and get audio (maybe), but it will be slightly faster due to the difference between the MP3's 44.1khz and the expected digital audio at 48khz. Don't worry... this will get resolved.

== Configuration files ==

== Configuration files ==

Revision as of 01:39, 5 February 2007

Many motherboards come with an on-board S/PDIF connector. This interface provides a mechanism for the output (and, on some motherboards, the input) of raw digital audio. With a MythTV setup, the S/PDIF connection is truly the key toward passing digital audio out of the system and in to your home theater receiver.

Most modern Linux distributions ship with the ALSA libraries and corresponding utilities pre-installed and configured out of the box. This simplifies the setup. If your distribution doesn't install ALSA by default, consult the [Configuring Digital Sound] entry on this wiki.

There are many How-To's and WIKI entries available for configuring digital sound, and there are others that focus on sending the output via SPDIF, but none seem to combine the two.

The MythTV WIKI Configuring Digital Sound page provides a good starting point for configuring ALSA. However, due to the pre-installation nature of Fedora Core 5 and the ALSA suite, a fair chunk of the WIKI document does not apply and a lot of the information gets lost in the mix.

It is just way too easy to get confused between S/PDIF, /dev/adsp, /dev/dsp, /dev/mixer, and all of the others.

Contents

Requirements

You need to have S/PDIF available on your motherboard or sound card.

You need to have an S/PDIF adapter that brings some form of digital port to the exterior of the machine (optical audio, coaxial audio). One such adapter is from Vidabox. Check the Sound card entry in this WIKI.

Find and Un-Mute Your S/PDIF

In this scenario, the goal is to have all audio sent out via the S/PDIF adaptor. Fedora Core 5, by default, has the S/PDIF output muted. First and foremost, you need to make sure that your system recognizes the on-board S/PDIF:

Specifically, we are concerned with "iec958", which shows up above. "spdif" also shows up, and, as you can see, it is simply an alias to the "iec958" device.

Now, bring up alsamixer and, using the arrow keys, move over to the "iec958" device and un-mute it by hitting the "m" key. Hit "esc" to exit and save the settings. (this image was taken directly from the Gentoo Wiki).

With the S/PDIF interface unmuted, we are free to start sending audio down the line.

The Configuring Digital Sound entry in this Wiki is very complete. However, from my experience, it was a lot more than I needed. As such, some of the important information got lost.

By default, with Fedora Core 5, all of the correct entries are automatically put together for you. Hence, there is no need for a local .asoundrc or /etc/asound.conf in order to send digital audio out via the SPDIF adapter. All you need to reference ALSA:spdif when performing your tests. But this is not the end solution, so please, read onwards.

Testing the output with a snippet of an ac3 file that I had on hand (you can pull one off of a DVD if need be) produced audible static:

aplay -D ALSA:spdif test.ac3

This is, actually, a good sign. Testing with "mplayer" (see the "Testing" section near the end of this document) should output digital AC3 sound which will tell you that the device is working. You can also test with a MP3 file and get audio (maybe), but it will be slightly faster due to the difference between the MP3's 44.1khz and the expected digital audio at 48khz. Don't worry... this will get resolved.

Configuration files

This entry will be in addition to the default ALSA settings that come with Fedora Core 5.

I also added the following to my /etc/modprobe.conf file as suggested in the Gentoo document, but it seemed to make no difference if it was there or not. I added it for the sake of consistency, but I will probably remove it.

In this case, I know that on my motherboard I have a bunch of on-board output options (L/R, Subwoofer, L/R rear, etc) in addition to the on-board S/PDIF. So, I know that my spdif is "card 0, device 1". Hence, the "dsp_map" setting is set to the device, which is "1". This may or may not be the same for your system.

Configure MythTV for Digital Sound

This part is the easy part. Fire up mythfrontend and navigate to:
Utilities/Setup->Setup->General
On Page 3, change the default audio device to "ALSA:default" and change the passthrough device to "ALSA:default". Finally, check the box next to "AC3 to SPDIF passthrough".

Configure MythMusic for Digital Sound

There is conflicting documentation out there that says you need to make changes to the Music Settings page. However, if you do the steps above, you will not need to make any changes here.

Testing

Although it has been left out (I hope to add this shortly), it is best to test things at every step to make sure you are doing things correctly. I cannot stress this enough since it directly helps to debug where things might be going wrong.

You can test with mplayer via:

mplayer -ao alsa:device=spdif -ac hwac3 dvd://

or

mplayer -ao alsa:device=spdif -ac hwac3 test.iso

Since I happened to have a number of my DVD's imported in to MythVideo, I had the ISO images easily accessible to test with.

I was unable to get the ALSA utility "speaker-test -c6" to work over the digital audio output.