How to read audio CDs using CD-ROM
Written by Tomi Engdahl
Originally written at 1996 and revised at February 1998.
The audio information in CD audio disks is in digital (red book) format. It is basically just data stored in rotating disk read by laser beam. Normal CD players are nice when you want to listen to the music stored to the disk, but if you are interrested in further processing the sound taken from CD disk.
You can do it by playing the sound and digitizing the data to you computer for further processing. This works well, but adds unnecesserily noise and other errors to the sound. CD player Digital to Analogue converters are not ideal and many sound cards are far from ideal Analogue to Digital converter.
There must be better way to do this you think. How about leaving out the unnecessaty A/D and D/A conversion and transfer the data directly. You migh remember thet you CD player migh have digital outputs. Maybe your computer has CDROM and you might wonder is it possible to read the audio information in the same way as you read the data disks.
An audio CD can be read by reading raw sectors of audio data. Not every cdrom player supports this way of reading data. All of them read cooked data (cdrom), but not all can read audio sectors. Even if a cdrom drive can read raw sectors, not all software drivers will allow this. Even if raw reading is supported by the hard- and software, raw reading can be troublesome: everytime a raw sector is read, the data comes in slightly shifted. Should you just dump the raw sectors into a WAV file, then it will be full of strange sample jumps, and it will sound terrible. Synchronizing algorithm impelemented in in better CD audio raeding programs will slide all these raw sectors over each other so that they fit perfectly, creating a 100% perfect copy of the digital audio that is stored on the CD.
Digital interfaces in normal CD-players
There are three types of digital interfaces for CD-players: AES/EBU, S/PDIF and TOS. AES/EBU is the interface stanrdard used in broadcasting studios and professional CD players only. P/PDIF and TOS are the interfaces used in commercial CD players and they both use the same data format (S/PDIF). S/PDIF used RCA connectors and 75 ohm coaxial cable for transferrign digital data and TOS used optical fiber.
Those digital interfaces are commonly used when sound is needed to transfer from CD disk to digital audio recorder (most commonly DAT). Unfortunately they are not very useful when transferring data to computers unless you have a suitable interface card which has those digital interfaces. Because this kind of S/PDIF cards are quite expensive you might want a cheaper alternative. If you happen to have a professional soundcard with S/PDIF input then you might also want to check if your CDROM drive has S/PDIF output (more on this at http://members.tripod.com/~Psych/md-cdrom.html).
Reading audio CDs using CDROM
Nearly all CD-ROMs can playback audio CDs, but only few can transfer the audio data directly from disk to computer in digital format. Many new CD-ROMs can do this, but with older ones it was not possible.
The CD-ROM drives which support reading of audio CDs have usually two reading modes: block read and syncronous read. Block read works so that program reads one small block of data from CD at one time. This mode is usually slow, it takes longer to read the CD data than to play same data as audio. Syncronoucs mode works so that the CDROM starts to play the audio track of the CD and forwards all sound data to computer bus. When this mode is used, the program must be fast enough to store the data at the same speed as the CDROM gives it. If the program is not fast enough, some data is lost.
Nowadays there are two commonly used CDROM interfaces used in PCs: IDE and SCSI. IDE CD-ROMs are the most common in normal PCs. SCSI CD-ROMs are commonly used in high-end PCs and workstations. Specifications for SCSI and AT Attachment Packet Interface (ATAPI) CD drives have long been established, but little testing has been done to ensure that drives conform to these standards. Both AT Attachment Packet Interface (ATAPI) and SCSI drive command set for reading audio CDs (for more information see "ATA Packet Interface for CD-ROMs" (SFF-8020i) and "SCSI-3 Multimedia Commands" (X3T10 1048D)).
Audio data can be read from a CD-ROM drive by sending it a Read CD command and the address of a sector known to contain digital audio. The drive then returns a block of 2352 bytes of raw audio data (normal data reads return 2048 bytes). These data reads reflect an extra layer of error correction not available to sectors containing digital audio. Data tracks also contain "formatted Q-subcode data" that confirm to the drive exactly which sector is currently being read. Without this extra information, accurate positioning of the read head and error-free transmission of audio data is difficult. Many newer CD-ROM drives have no problems accurately reading CD-DA tracks; however, many older drives exhibit problems that make them unsuitable for reading audio CDs. The main problem in audio CD reading is in accurately seeking the desired location on a disk. Some drives are not capable of accurately positioning read heads within a short amount of time and some others will drop data.
Some CDROMs support audio data reading (more or less good) and some don't. Sometimes the problem is that the CD-ROM drivers don't support audio reading even if the CD-ROM hardware supports it. There is a list of CDROMs found to support this feature at ftp://ftp.cs.su.oz.au/bruce/cdda/readers. It is expected that reliable CD-ROM audio reading capabilities are becoming more and more important because Microsoft has plans to use CD-ROM audio CD capabilities in future Windows soudn system models.
IDE CDROMs
IDE CD-ROM drives use standard ATAPI command set for controlling, but there are some differences in CDROM drives made by various manufacturers. That's why you need special driver for each different CD-ROM (this driver comes in CDROM package). In DOS the driver provides the inteface to MSCDEX program for accessing CDROM hardware. If you want to read CD audio data directly, CDROM drive, MSCDEX program and the CDROM driver must all support audio data reading. New versions of MSCEX should support that function.
Some ATAPI CDROMs supporting audio data reading feature:
- Toshiba XM-5302B (4x)
- Sony CDU-55E (2x)
- Panasonic CR-581B (4x)
- OTI-Hermes (8x)
SCSI CDROMs
Many SCSI CDROMs support audio data reading, for example new Toshiba models. If you need that function, make sure that the drive can do it before you buy it. Installing the drivers depends on SCSI controller, check the manuals for more informations. Some controllers need more drivers for DOS, some don't need. If you are using DOS, you need only the standard MSCDEX program loaded in the memory. There can be driver problems so that you can't read audio data even that your hardware supports it.
I have Toshiba 3401 CDROM connected to Adaptec 1540 SCSI-2 controller. I had major problems in trying to read CD audio tracs under DOS using ez-scsi drivers for dos version 3.03, but when I updated to version 4.0 everything went just fine. My working setup is EZSCSI 4.0 drivers, MSCDEX version 2.93 and CDDA2WAV software.
For other operating systems, no special drivers are needed, because SCSI CDROMs use standard SCSI devices. They can be controlled same way as any other SCSI device. There are some videly available sources for CD audio reading.
CD audio reading software
To be able to directly read the digital audio data directly from the CDROM drive, you need some software to do it. I have used CDDA2WAV software, but there are many others. Check also X2 Support Group Game Development Archives for some useful audio file conversion tools and source code. For more information about prograaming your own CDROM software, get CD-ROM Programming FAQ. Check also link Software to read direct CD-DA for pointers to more programs. For more technical info on ATAPI CD-ROM audio redicn capabilities check Technical CD-ROM dumps from CDROMINF and ATAINF page and the reading programs at the same site.
Tomi Engdahl <[email protected]>