Saturday, August 6, 2005

Capturing Toslink/SPDIF Using Creative LiveDrive In Linux

Here is how I configured Linux to record an Toslink/SPDIF audio source. It's quite easy once you figure out what all the buttons do. I do not know if the Creative LiveDrive actually captures the digital stream or re-encodes it. I haven't been able to find out one way or the other and I just don't know enough to tell for sure. What I do know is that using the digital input minimizes the opportunity for noise to be introduced into the sample you are recording, especially if you do have the option of a digital source.

The process wasn't difficult, but that observation comes from hindsight. I'm sure there's a tool out there which only takes a few clicks to do what I did here, but this is what worked for me.

The first thing I did was connect an optical cable from my audio source to the Creative LiveDrive. I used Monster audio cables as they are what I had available. Obviously not a difficult operation. The next thing to do was puzzle out how the alsa controls mapped into the Creative card. It turns out, that to set up for audio capture you need to do several steps. The problem is that the generic alsamixer doesn't necessarily place related controls next to one another.

The Creative device under Alsa has two record options that need to be set. This is what confused me the most because I thought it was a more or less direct selection of the audio input I wanted to have available as the 'capture device'. The first is a selector that goes between 'Mic', 'CD', 'Video', 'Phone', 'Aux', 'Mix', 'Mix Mono' and 'Line'. In the alsamixergui tool, these are the controls that have selectable 'record' buttons, but the mute control is inoperative. It appears that you have only a limited number of channels you can record and the trick is to identify them and select them.

A little trial and error will enable you to figure out which controls are the ones that select the primary record source and which toggle individual inputs on and off. If clicking record on one option turns off another, then it's one of the selection set. If it can be turned on and off without causing the selection set to change, then it is an independent control. When configured correctly, you will have exactly two controls 'enabled' for recording. Mine were labeled 'Line' and 'IEC958 LiveDrive'. Next to the 'IEC958 LiveDrive' was an identical one without a 'record' button above it. This was the 'capture volume' for that input. There are two separate volume controls. The first is the volume that goes to the speakers, the second is the volume level put into the recording. I set the capture volume to 100% and the listen volume to about 60%.

At this point, arecord should capture audio from the digital source. You can use the following command to capture a quick test:
arecord -f dat -d 10 > sample.wav. That takes a 10 second sample from the default recording source and saves it to sample.wav in 48KHz, 24bit, stereo mode. Here is where the big questions about whether or not the optical input resamples the audio comes to the fore. What is the right rate to be sampling at? Honestly I don't know. But, now you can go about figuring the right settings. If it doesn't work, go through the mixer and turn everything to zero and try clicking on all the record buttons to ensure that those that can be turned off have been. Then, with an audio source playing (such as aplay and a wav file you know to be good), go through the mixer and methodically try turning each of them up.

For myself, I have the following mixer controls set: Master, about 70%, Bass & Treble are at 50%, PCM, Surround, Wave, Wave Center, Wave LFE, and IEC958 LiveDrive (capture) at 100%. Finally I adjust the IEC958 LiveDrive control to listen to the source audio when desired.

Frustratingly, the mixer shows controls labeled 'IEC958 TTL' but I'm yet to figure out what one needs to do in order to record from them. Good luck.

No comments:

Post a Comment