March 23, 2009

Notes on using multiple ALSA cards

The last few weeks have been quite exciting. I studied how to configure two ALSA chipsets to operate simultaneously. Then I worked on to bring a stable version of lportal-1.1, and hacked MFserver to stream video from a PC over the network to a PPC-based PVR device (Maximum T-8000). And learning the basics of git in the meanwhile! :) Lots of fun. My testbench was Sabayon-4 with Linux kernel 2.6.27, and had to switch from kernel ALSA to a newer version to get it working properly. After learning a bit about ALSA, it boiled down to configuring /etc/modprobe.d/alsa to define the card indices and their driver. I have a setup with integrated Intel audio which has altogether 5 analog 3.5" stereo audio plugs and a S/PDIF connector .. on the motherboard. I just today got a connector card for this, but I already had an M-AUDIO Audiophile 2496 that has a coax S/PDIF output available. I connected this with a cheap 1 m single RCA coax cable to Pioneer stereo system. After all the work of compiling ALSA headers for the correct kernel and hassling with the kernel modules, I got both cards working simultaneously. I could play the same audio file in two different processes and send the output to analog and digital simultaneously. Both input sources are selected by the "CD" switch on the amplifier, and a separate analog/digital button is available to select the source. Cool! To my ears it seems that the digital is crisp and clear, but suffers from constant static cracles during some tracks. Analog source is a bit muddier, but the dynamic range is somehow more pleasant for me, so I left the analog device the default output. I decided to use ~/.asoundrc to set the default output device: To set the Audiophile's digital output:
pcm.!default iec958:M2496
Or the integrated Intel analog:
pcm.!default front:Intel
Speaker-test is a good testing tool:
$ speaker-test -c2 -Diec958:CARD=M2496,DEV=0
 $ speaker-test -c2 -Dfront:CARD=Intel
I use Amarok 2 to play music, using Phonon and KDE-4.2.1. Works fine.

No comments: