[alsa-devel] IEC958 / SPDIF raw capture
Hi,
We have an application in our institute that will require recording of a digital signal via an optical cable. We have to be able to guarantee perfect bitwise reproduction of the signal (the odd bit error is not a problem). We're thinking of using SPDIF and ALSA to capture the signal (obviously we'll have to make sure the signal is properly encoded to begin with).
However, after some initial attempts, it's becoming clear that ALSA can't necessarily guarantee bitwise perfect capture. ALSA might change the format, or resample the signal after capture (although I've heard that can be turned off with "snd_pcm_hw_params_set_rate_resample (capture_handle, hw_params, 0)"). Also, the card that we've been playing with so far (SB Audigy2 ZS) apparently performs some low-pass digital filtering on the input stream anyway, and is therefore no use to us.
So my question is: can this be done? Is there a way of setting up ALSA to produce an unaltered version of the SPDIF input stream? This will undoubtedly require a particular combination of hardware and driver. If so, which card/driver would be recommended? Ideally, we would like to capture the raw SPDIF subframes. Is that possible, and if so, how?
Any help would be greatly appreciated! Thanks,
Donald.
Donald Tournier wrote:
We have an application in our institute that will require recording of a digital signal via an optical cable. We have to be able to guarantee perfect bitwise reproduction of the signal (the odd bit error is not a problem). We're thinking of using SPDIF and ALSA to capture the signal (obviously we'll have to make sure the signal is properly encoded to begin with).
However, after some initial attempts, it's becoming clear that ALSA can't necessarily guarantee bitwise perfect capture. ALSA might change the format, or resample the signal after capture (although I've heard that can be turned off with "snd_pcm_hw_params_set_rate_resample (capture_handle, hw_params, 0)").
If you open the device as "hw:x", ALSA will not do any conversions and will give you the data exactly as it comes from the sound card.
can this be done? If so, which card/driver would be recommended?
PCI(-E) cards based on C-Media chips (CMI87x8, CMI8770, AV200) are known to allow bit-perfect digital capture.
Ideally, we would like to capture the raw SPDIF subframes.
Some very old revisions of the CMI8738 did this, because proper decoding of subframes wasn't implemented, but these aren't sold anymore.
HTH Clemens
Thanks Clemens, that very helpful. We'll try to source one of these C-Media cards as soon as possible.
Also nice to know about the "hw:x" trick, although I'm not too sure how to use that in practice. I've just tried this command, with no success:
$ arecord -D hw:x -t raw output.raw ALSA lib pcm_hw.c:1435:(_snd_pcm_hw_open) Invalid value for card arecord: main:608: audio open error: No such device
How exactly should this be used? Thanks,
Donald.
On 11 February 2010 18:26, Clemens Ladisch clemens@ladisch.de wrote:
Donald Tournier wrote:
We have an application in our institute that will require recording of a digital signal via an optical cable. We have to be able to guarantee perfect bitwise reproduction of the signal (the odd bit error is not a problem). We're thinking of using SPDIF and ALSA to capture the signal (obviously we'll have to make sure the signal is properly encoded to begin with).
However, after some initial attempts, it's becoming clear that ALSA can't necessarily guarantee bitwise perfect capture. ALSA might change the format, or resample the signal after capture (although I've heard that can be turned off with "snd_pcm_hw_params_set_rate_resample (capture_handle, hw_params, 0)").
If you open the device as "hw:x", ALSA will not do any conversions and will give you the data exactly as it comes from the sound card.
can this be done? If so, which card/driver would be recommended?
PCI(-E) cards based on C-Media chips (CMI87x8, CMI8770, AV200) are known to allow bit-perfect digital capture.
Ideally, we would like to capture the raw SPDIF subframes.
Some very old revisions of the CMI8738 did this, because proper decoding of subframes wasn't implemented, but these aren't sold anymore.
HTH Clemens
On Fri, 12 Feb 2010, Donald Tournier wrote:
Thanks Clemens, that very helpful. We'll try to source one of these C-Media cards as soon as possible.
Also nice to know about the "hw:x" trick, although I'm not too sure how to use that in practice. I've just tried this command, with no success:
$ arecord -D hw:x -t raw output.raw ALSA lib pcm_hw.c:1435:(_snd_pcm_hw_open) Invalid value for card arecord: main:608: audio open error: No such device
How exactly should this be used?
Note that 'x' means card number or name. Just use 0 if you have only one card in system or use 'arecord -l' to list cards.
Jaroslav
----- Jaroslav Kysela perex@perex.cz Linux Kernel Sound Maintainer ALSA Project, Red Hat, Inc.
On Thu, 11 Feb 2010, Donald Tournier wrote:
Hi,
We have an application in our institute that will require recording of a digital signal via an optical cable. We have to be able to guarantee perfect bitwise reproduction of the signal (the odd bit error is not a problem). We're thinking of using SPDIF and ALSA to capture the signal (obviously we'll have to make sure the signal is properly encoded to begin with).
However, after some initial attempts, it's becoming clear that ALSA can't necessarily guarantee bitwise perfect capture. ALSA might change the format, or resample the signal after capture (although I've heard that can be turned off with "snd_pcm_hw_params_set_rate_resample (capture_handle, hw_params, 0)"). Also, the card that we've been playing with so far (SB Audigy2 ZS) apparently performs some low-pass digital filtering on the input stream anyway, and is therefore no use to us.
Getting raw S/PDIF stream for EMU chips is not so easy. They operates internally at 48kHz and everything is resampled to this frequency.
Jaroslav
----- Jaroslav Kysela perex@perex.cz Linux Kernel Sound Maintainer ALSA Project, Red Hat, Inc.
participants (3)
-
Clemens Ladisch
-
Donald Tournier
-
Jaroslav Kysela