Cdrdao - Write audio CD-Rs in disk-at-once mode
===============================================================================

This file contains some additional information. See the manual page for usage
of the tool.

Please use the write simulation mode (command 'simulate') when trying this
program the first time on your system. This will detect problems or
incompatibilities without wasting a CD-recordable. Note that you may have to
eject and reinsert the CD-R after simulation before a real write can start.


Drivers
-------
The following driver IDs may be used with option '--driver':
  plextor
     Supports CD structure analysis (command 'read-toc') for Plextor CD-ROM
     readers. Pre-gaps and index marks are detected by performing a binary
     search over the Q sub-channel for each track. This method is fast and
     gives very exact results on Plextor drives. The driver uses generic
     SCSI commands (PLAY AUDIO and READ SUB-CHANNEL) so it may work on other
     models, too, but result and speed is directly correlated to the digital
     audio extraction capabilities.

  plextor-scan
     This is an alternate driver for CD structure analysis with Plextor
     drives. It scans the Q sub-channels of a track linearly like the 
     'generic-mmc' driver but is faster on Plextor drives.

  cdd2600
     This is a native driver for the Philips CDD2000/CDD2600 drive family.
     'read-toc' is implemented like in the 'plextor' driver but it is slow
     and not very exact due to poor digital audio extraction capabilities of
     these drives. Anyway, I don't recommend doing CD structure analysis with
     the CDD2x00 because it stresses the mechanism too much. 

  generic-mmc
     This is a driver for SCSI-3/mmc compatible CD-recorders that support
     session-at-once (cue sheet based) writing. Most of the recent drives
     should be compatible with this or with the 'generic-mmc-raw' driver
     described below. Data track support is also available.
     'read-toc' scans linearly the Q sub-channel of each track to retrieve
     the pre-gap length and index marks. This method is very accurate but
     takes the same time like digital audio extraction. It should also work
     with recent CD-ROM readers.
	  
  generic-mmc-raw
     This is an alternate driver for SCSI-3/mmc compatible CD-recorders.
     It uses the raw writing interface where the driver has to provide the
     PQ sub-channel data in addition to the audio data. This writing mode
     allows using part of the lead-out area for audio data since the drive's
     firmware has no chance to prevent this. Of course, you will get some
     error message at the end of writing when the CD-R capacity is exhausted.
     CD structure analysis is done like in the 'generic-mmc' driver. 

  ricoh-mp6200
     Supports writing with the Ricoh MP6200S CD recorder. It cannot write
     the Catalog Number, yet.
     CD structure analysis is done like in the 'generic-mmc' driver.

  taiyo-yuden
     This is an adapted 'cdd2600' driver for Taiyo-Yuden recorders.
     'read-toc' is done with 'plextor' method.

  teac-cdr55
     Driver for the Teac CD-R55 recorder. Audio and data tracks are supported.
      'read-toc' uses the Q sub-channel scanning method.

  yamaha-cdr10x
     Driver for the Yamaha CDR10X recorder series that supports audio and
     data tracks. 'read-toc' uses the Q sub-channel scanning method.


SCSI Device
-------------------
Cdrdao uses Joerg Schilling's SCSI library. Thus the same SCSI device
addressing scheme applies as for 'cdrecord'. A SCSI device is addressed
by a bus/id/lun triple, e.g. '--device 0,2,0' for a device with SCSI ID 2 on 
SCSI bus 0. On some systems it is also possible (sometimes required) to
specify a device node directly, e.g. '--device /dev/sg0' can be used on
Linux systems instead of the bus/id/lun triple.

On Linux systems the generic SCSI device ('/dev/sg?') is required to access
the CD writer. Try 'cat /proc/devices' to check out if your kernel supports
the character device 'sg'.
If not insert the corresponding module ('insmod sg.o') or reconfigure and
compile the kernel. Cdrdao opens '/dev/cdrecorder' by default which should
be a link to the appropriate generic SCSI device.


Read-Toc With Mixed Mode CDs
----------------------------
For copying mixed mode CDs it is very important to extract the position
of transition areas between tracks of different mode. This means for a
usual mixed mode CD to find the point where the mode 1 track (1st track)
ends and the audio tracks starts (pre-gap of the first audio track). This
information is required to calculate the amount of data that can be read
from a track and must be recorded when writing the disk.

The transition point is not stored in the central toc of the CD so that it
must be located by inspecting the Q sub-channel data of each sector.
Unfortunately it is not possible to read the sub-channel data in a 100%
reliable way which may lead to small deviations of the extracted transition
position. This is no problem for pure audio CDs because it will only result
in shifting some sectors from one track another. But for a mixed mode CD the
extracted toc-file may not match the amount of data that can be read from
the mode 1 track and the resulting disc would be unusable.

The Q sub-channel of a sector contains the actual track and index number
and the absolute and track relative time. The transition point can be
located by finding two consecutive sectors where track n/index m changes
to track n+1/index 0. All sectors of a track with index 0 in the Q sub-channel
data build the pre-gap of the track. The track relative time decrements to 0
in the pre-gap. The CD toc contains only pointers to the first sector with 
index 1 of a track.
The following figure should illustrate the track structure. Each '#' character
represents a sector and its Q sub-channel data. 


   start of               start of    start of
   track n                pre-gap of  track n+1
   from TOC               track n+1   from TOC
     |                      |           |
     v                      v<-pre-gap->v
...########################################################... <- sectors
     ^       ^              ^           ^
     |       |              |           |
  track n,   track n,     track n+1,  track n+1,
  index 1    index m      index 0     index 1


If the sub-channel data of the first sector(s) of a pre-gap cannot be read
successfully the extraction algorithm will detect the pre-gap start some
sectors later. This will implicitly increase the length of the previous
track. An attempt to read this amount of data from the track may result
in read errors at the end if the following track has a different mode because
it reads into the pre-gap of the following track.

To avoid this problem manual correction of the extracted toc-file may be
necessary. Usually the pre-gap length of track should be 2 seconds if the
track mode changes. Thus a toc-file should look like this:

	TRACK MODE1 // data track 
	DATAFILE "data" 40:0:0 (length: (40 * 60 + 0) * 75 + 0 sectors)

	TRACK AUDIO // audio track
	SILENCE 0:2:0 // pre-gap contains zero data
	FILE "data.wav" 0 X:Y:Z
	START 0:2:0   // length of pre-gap: 2 seconds
	...

If the pre-gap start is detected 2 sectors later the result would be slightly
different:

	TRACK MODE1 // data track 
	DATAFILE "data" 40:0:2 (length: (40 * 60 + 0) * 75 + 2 sectors)

	TRACK AUDIO // audio track
	SILENCE 0:1:73 // pre-gap contains zero data
	FILE "data.wav" 0 X:Y:Z
	START 0:1:73   // length of pre-gap: 1 + 73/75 seconds
	...

Since it is not possible to decide if the pre-gap length is really just
0:1:73 sectors or if this number is caused be read problems I would suggest
the following method:

  1. Read the data track with 'dd if=/dev/sr0 of=data bs=2048'. As said above
     you may get read errors at the end which can be ignored.

  2. Divide the length of the extracted data file by 2048 to get the
     length in sectors and compare it to the length written in the toc-file.
  
  3. If there is a difference adjust the data file length, the 'SILENCE'
     and the 'START' statement in the toc-file. In the extreme case where
     no pre-gap was detected for the audio track you will have to add the
     'SILENCE' and 'START' statements.


I'm planning to add a 'read-cd' command that will read all data tracks and
create a correct toc-file at the same time.


Drives Known to Work
--------------------
Recorders:

  Model                Firmware Rev.  Driver
  ------------------------------------------
  BTC BCE621E          2.0            generic-mmc-raw
  HP CD-Writer 6020    1.07           cdd2600
  HP CD-Writer+ 8100   1.0g           generic-mmc
  IMS CDD2000          1.25, 1.26     cdd2600
  MATSHITA CW-7502     X.14           generic-mmc
  MATSHITA CW-7582     1.05           generic-mmc
  MEMOREX CR-622       D4.0           generic-mmc-raw
  MEMOREX CRW-1662     D4.0           generic-mmc-raw
  MITSUMI CR-4801TE    2.02           generic-mmc
  MITSUMI CR-4802TE    1.2B           generic-mmc-raw
  PHILIPS CDD2000      1.25           cdd2600 
  PHILIPS CDD2600      1.07           cdd2600
  PHILIPS CDD3600      2.00           generic-mmc-raw
  PHILIPS CDD3610      2.02, 3.01     generic-mmc-raw
  PHILIPS OMNIWRITER26 1.20           ricoh-mp6200
  PLEXTOR PX-R412      1.04           generic-mmc
  PLEXTOR PX-R820      ?              generic-mmc
  RICOH MP6200S        2.03           ricoh-mp6200
  RICOH MP6201S        ?              ricoh-mp6200
  T.YUDEN CD-WO EW-50  2.15, 2.16     taiyo-yuden
  TEAC CD-R55S         1.0K, 1.0L     teac-cdr55
  TEAC CD-R56S         ?              generic-mmc
  TRAXDATA CDRW2260+   3.01           generic-mmc-raw
  TRAXDATA CRW2260 Pro 2.0            generic-mmc-raw
  TRAXDATA CDRW4260    1.0f           generic-mmc
  YAMAHA CDR100        ?              yamaha-cdr10x
  YAMAHA CDR102        1.00, 1.01     yamaha-cdr10x
  YAMAHA CDR200t       1.0k, 1.0n     generic-mmc
  YAMAHA CDR400t       1.0k           generic-mmc
  YAMAHA CRW2260       1.0f           generic-mmc
  YAMAHA CRW4260       1.0h           generic-mmc
  YAMAHA CRW4416       1.0b           generic-mmc

Notes:
  - MATSHITA CW-7502: see notes about required firmware at the end of this file
  - MEMOREX CR-622: See note about firmware at the end of this file.
  - MITSUMI CR-4802TE: The 'generic-mmc' driver works, too, but the firmware
                       seems to create wrong sub-channel data in some cases.
  - RICOH MP6200S: Cannot write Catalog Number, yet.
  - Yamaha Models: Writing does not work with firmware revision 1.0i. See also
                   note at the end of this file.

Readers (command 'read-toc'):

  Model                Firmware Rev.  Driver
  -----------------------------------------
  LITEON CD-ROM LTN244 KL49           generic-mmc
  LITEON CD-ROM LTN341 ML35           generic-mmc
  MATSHITA CR-588      LS15           generic-mmc
  NAKAMICHI MJ-5.16S   1.07           plextor
  MEMOREX CD-233E      U10A           generic-mmc
  PIONEER DR-U06S      1.05           plextor
  PIONEER DR-U12X      1.06           plextor
  PIONEER DR-U16S                     plextor
  PLEXTOR CD-ROM                      plextor, plextor-scan
  SONY CDU415          1.1i           plextor
  TEAC CD-532E         1.0A           generic-mmc
  TEAC CD-ROM CD-532S  1.0A           plextor-scan
  TOSHIBA XM-5701TA    0167           plextor
  TOSHIBA XM-6201TA                   plextor

Notes:
  - MEMOREX CD-233E: This drive seems to ignore ISRC Codes and Catalog Number.


Pre-compiled Binaries
--------------------
The pre-compiled binaries should work with 2.0.x and 2.1.x kernels (tested
with kernel 2.0.33 and 2.1.111). Older kernels may require recompilation
because of a different maximum message size of the generic SCSI device.


Example for copying an audio CD:
--------------------------------
1. Create a toc-file for the source CD:

        cdrdao read-toc cd.toc

2. Read out the audio data to a single file:

        cdda2wav -t 1 -d 6000 data.wav
   or
        cdparanoia 1- data.wav

3. Write the CD:

        cdrdao write cd.toc


Example for copying a mixed mode CD:
------------------------------------

The following steps are only valid for the usual case that the first track
of the source CD is a data track followed by several audio tracks.
The process is currently somehow complicated but I'm already working
on a 'read-cd' command.

1. Extract the toc-file for the source CD.
   All data tracks will be referenced with the name given as argument to
   option '--datafile' stripped from the extension and extended by the actual
   track number (in this case it will be "cddata_1"). A continues range of
   audio tracks is referenced by inserting the track range before the
   extension, e.g "cdddata_2-6.wav". If only one continues range of audio
   tracks exists the name will be used as specified on the command line.

        cdrdao read-toc --datafile cddata.wav cd.toc

2. Copy the data track:

        dd if=/dev/sr0 of=cddata_1 bs=2048

3. Copy the audio tracks starting at track 2. Since we have only one
   continues range of audio tracks the toc-file will reference "cddata.wav":

        cdda2wav -t 2 -d 6000 cddata.wav
   or
        cdparanoia 2- cddata.wav

4. Write the CD:

        cdrdao write cd.toc


Example for composing an audio CD:
----------------------------------
Assume three existing audio files 'audio1.wav', 'audio2.wav' and 'audio3.wav'
that go in three tracks. We do not want a pause between track 1 and 2 (no
pre-gap). The first 10 seconds of 'audio1.wav' should be used as pre-gap for
track 3. Here is the toc-file:


// Track 1
TRACK AUDIO
FILE "audio1.wav" 0  // take all audio data from 'audio1.wav', length is taken
                     // from file

// Track 2
TRACK AUDIO
FILE "audio2.wav" 0  // take all audio data from 'audio2.wav', length is taken
                     // from file, no pre-gap

// Track 3
TRACK AUDIO
FILE "audio1.wav" 0 0:10:0 // take first 10 seconds from 'audio1.wav'
START                      // everything before this line goes into the pre-gap
FILE "audio3.wav" 0  // take all audio data from 'audio3.wav', length is taken
                     // from file


Type 'cdrdao show-toc example.toc' to check for the correct syntax of the
toc-file. Note that even for the command 'show-toc' the audio files must exist
if the length of the audio files is not specified like in the example.

Type 'cdrdao read-test example.toc' to check if all audio files can be read
without error (optional).

Type 'cdrdao simulate example.toc' to perform a write simulation (optional).

Type 'cdrdao write example.toc' to create the audio CD.


On-The-Fly Copying:
-------------------

Starting with cdrdao version 1.010 copying of audio CDs via a pipe is
supported. A fast and reliable source CD-ROM drive is required to
avoid buffer under runs. It is also not worth to try on-the-fly
copying with scratched source CDs.

The standard generic SCSI interface of the Linux kernel cannot handle
multiple commands in parallel. Since cdda2wav/cdparanoia and cdrdao
both use the generic SCSI interface mutual blocking will occur. This
results in low fill rates of cdrdao's ring buffer and very likely
produces buffer under runs.

To avoid these problems you should apply Heiko Eissfeldt's sg-buffer
patch which can be downloaded from:
	ftp://ftp.fokus.gmd.de/pub/unix/cdrecord/alpha/
It is available for 2.0.x and 2.1.x kernels. For 2.2.x kernels the
"SG-2.2.tar.gz" patch should be used.
      
I strongly recommend to perform some simulation runs before trying a
real write.
      
Here is the command sequence:

1. Extract a toc-file for on-the-fly copying. The option '--datafile -'
   indicates that the special STDIN file "-" should be used for each
   FILE statement in "cd.toc".
	  
	cdrdao read-toc --datafile - cd.toc

2. Copy the CD with:

        cdda2wav -q -t 1 -d 5000 -O cdr -E big - | cdrdao write --buffers 64 cd.toc

   or 

	cdparanoia -q -R 1- - | cdrdao write --buffers 64 cd.toc
	 
   The option '--buffers' is used to adjust the ring buffer size. Each
   buffer holds 1 second audio data. Dividing the specified number of
   buffers by the writing speed gives the approx. time for which data
   input my be stalled, e.g. 64 buffers and writing at 4x speed results
   in 16 seconds.
	  
   Note that cdparanoia needs a fast machine for performing audio ripping
   on-the-fly. I have to disable all paranoia checking with option '-Z'
   on my Pentium-166. Otherwise it is too slow and a buffer under run
   occurs just after the write process started.


Contact
-------
Please report bugs and suggestions to 
Andreas Mueller <mueller@daneb.ping.de>

Cdrdao Homepage: http://www.ping.de/sites/daneb/cdrdao.html
                 http://cdrdao.netspring.net/

Download:        ftp://ftp.netspring.net/pub/people/andreas-mueller


Notes about some CD recorder models:
------------------------------------
MATSHITA/PANASONIC CW-7502

    This drive will only produce useful disks with the recent firmware
    revision X.14. The X depends on the drive hardware revision. 

    Thanks to Jeroen Steenblik <jeroens@esrac.ele.tue.nl> for adapting
    the generic-mmc driver to the CW-7502 recorder. He spend a lot of time
    and wasted many CD-Rs until it was obvious that the pre-X.14
    firmware does not completely comply with the SCSI-3/mmc standard. 

    Here are Jeroen's notes for upgrading the firmware:
    The update can be found at the Plasmon technical website,
    http://tech.plasmon.co.uk/, choose 'Download Files' and obtain the
    X.14 firmware for the CDR480. This includes all instructions.
    One thing I might add, when downloading the two files in the sequence
    described in their document, my drive refused the second file. I had
    to reboot after downloading the first file and only then I could download
    the second. Quite scary stuff. Swapping the download sequence should
    prevent this (so I've read). 

MEMOREX CR-622
    Submitted by Bryan E. Chafy <bchafy@ccs.neu.edu>:

    The drive as shipped comes with firmware that does not support DAO.
    The firmware lives on a PROM, it is not flashable.
    You need an EPROM burner, a 27c020 PLCC EPROM, and the
    D4.0 ROM image for the CRW-1622 (can download it from Memorex web site,
    the name of the image is d39e.dat).

    The ROM is socketed at the rear of the drive, you will see it when you
    remove the top cover.  Mine had a sticker on it with the numbers E07/885B.

    Note, this is for the CR-622 (and its sister the CDR-622 wearnes drive),
    NOT the CRW-1622.  The CRW-1622 drive is flash-upgradeable).

    IMHO, Wearnes/Memorex should be sending us new ROM's free of charge because
    the box clearly states the CR-622 supports DAO.

    The new firmware does not turn the CR-622 into a cd-rw capable drive.
    You can still only burn cd-r media.


YAMAHA CDR400, CRW4260
    These drives sometimes have problems with writing at 4x speed. The
    resulting disk is hard read for some reason. Disks written at 1x or
    2x speed are fine. Yamaha's support is aware of this problem. It might
    be related to the actual firmware revision.
    I successfully wrote CD-Rs at 4x speed with a CDR400t and firmware
    revision 1.0k.
