From: BrianW@SoundS.WA.com (Brian Willoughby)
Newsgroups: comp.sys.next.programmer
Subject: Re: (failing to) read Audio Data from CDROM
Date: 11 Nov 92 18:14:17 GMT
Article-I.D.: sounds.BxKDBu.AA
Reply-To: BrianW@SoundS.WA.com
Organization: SoundSoftware, Bellevue, WA, USA

Sean T. Lamont writes
| In article <1992Nov2.172257.14250@anarch.do.open.de> erik@amg.de writes:
| >constantly failed working when I inserted audio CDs. However, it works fine  
| >with data CDs although the "music" isn't too enjoyable...
| 
| There is a fundamental problem with your entire strategy.  CD disks are
| built with an encoding written onto the disk which specifies whether you
| can read data off the disk in digital format or not.  on CD-rom disks are
| obviously set to "true", with audio CDs having the bit set to "false"
| 
| The implementor of the drive, of course, is free to ignore this
| specification.  However, the only one I've heard of that does is the one
| shipped by SGI.

The differences between audio and data CDs are a little more complicated than  
that.  The simplest way I can think of explaining it is that audio CDs are like  
"unformatted" disks and CD-ROM is like "formatted" disks.

An audio Block on a CD contains 2352 bytes of audio data.  The exact same block  
only provides 2048 bytes of computer data on a CD-ROM; the additional 304 bytes  
are "wasted" as sync, header and aux data.  So, when you read a "block" from an  
audio CD, you are missing 13% of the data.  The manufacturers aren't really  
going out of their way to prevent reading of audio data, they're actually just  
using off-the-shelf chips which either interpret CD audio or CD-ROM data.  Most  
manufacturers connect the output of the CD audio chip to the audio circuitry  
and connect the output of CD-ROM chip to the computer interface.  SGI (or the  
maker of their drive) has taken special measures to make the CD audio data  
available on the computer interface as well.  They probably have some  
proprietary way of sending the entire 2352 bytes instead of only 2048.

There are 6 stereo 16-bit samples (24 bytes) in a Frame on a CD.  Each Frame  
has an extra byte for subcode.  It takes 98 Frames to make a Block (which has  
the time in seconds encoded into the 98 subcode bytes).  You can't really seek  
on a CD except to a block address because you are technically seeking to a  
specific second (there are 75 Blocks per second).  CD audio was designed first,  
and then CD-ROM came around as an afterthought.  Since there were already Block  
limitations in the audio design, I guess they thought it would make sense to  
throw away 288 auxiliary bytes with every block to keep things aligned.

There are subcode bits in each Block which indicate whether the data is audio  
or computer and whether it is copy protected or not.  But, you can see that it  
doesn't do much good to enable a computer to read audio blocks unless all 2352  
bytes are sent across the interface instead of just 2048.
-- 
Brian Willoughby	Software Design Engineer, BSEE NCSU
BrianW@SoundS.WA.com	Sound Consulting and Signal Processing Software
NeXTmail welcome	- NO EMAIL SOLICITATION without prior permission
Newsgroups: comp.sys.next.programmer