Hi cdrom drive users,

This README describes hardware related matter as well as the installation of 
cdda2wav, the sampling utility.

Some cdrom drives are capable of sending audio data in digital form to the
host (cdda). One of the first drives with this capability was the toshiba 3401
scsi cdrom drive.

cdda2wav reads audio data given by the cdrom drive and dumps it into 
a wav sound file. The sampling format can be controlled by options.
See cdda2wav.1 or cdda2wav.doc for details.

Supported drives
================

Matsushita Panasonic cdrom drives (driven by sbpcd):
	Eberhard Moenkeberg adapted his sbpcd driver to read cdda (since 
	kernel version 1.1.2x). 

Sony CDU31A drives:
	Corey Minyard upgraded the driver for the Sony CDU31a (since kernel 
	version 1.1.60).

SCSI:
	Toshiba 3401, 4101, 5201:
	Sony CDU-8003
	NEC MultiSpin 2Xi (CDR-201)

These drives have been tested successfully.

Early code exists for other scsi drives (which i don't have):
Other nec drives should work. 
Apple cdrom drives are compatible to Sony CDU-8003.
Hitachi and Plextor 4X drives may work.

(Feedback on these or other scsi drives is welcome).

Supported interfaces
====================

Non scsi drives:
	These drives are supported only, if the kernel driver allows 
	reading cdda audio data via ioctl(). Currently only Eberhard 
	Moenkebergs sbpcd and Corey Minyards cdu31a driver do allow 
	this. Regard this as early alpha...

Scsi drives:
	For toshiba and NEC drives there are two possible interfaces 
	available.
	The first one utilizes the ioctl(IOCTL_SEND_SCSI_COMMAND) system call.
	The second method accesses the cdrom drives via the generic scsi 
	driver (which must be compiled into the kernel). Each has its
        strengths and weaknesses.
        The generic interface allows multi sector transfers which lowers
	cpu load considerably. Furthermore support for all vendor specific
        commands is build in. Unfortunately pressing ^C (the interrupt key)
	may hang the process. Please use ^\ (the quit key) instead.
        Otherwise it has to be killed then.
        The ioctl interface is not designed as an application interface and
	has a transfer limit of 4096 bytes, so just one sector fits in.
	Pressing ^C causes no problem here. Slow, but stable.
	SONY, Plextor and Hitachi users have to take the generic scsi 
	interface because of the required vendor specific commands.


Notes on kernel scsi drivers
============================

Note for ultrastor users
========================

When using the scsi ioctl interface: kernels upto version 1.1.19 had a bug 
which causes ugly host timeouts (locking the system for some time). The file 
scsi_ioctl.diff should be included in your cdda2wav tar archive. It contains 
the "official" patch from V. 1.1.20. See Kernel Patching below.


Note for aha152x users
======================

These drivers seem not to work correctly with the generic interface (yet)
(at least those for sound blaster scsi). Please use the scsi ioctl interface 
instead. This information may be outdated (feedback is welcome).


Drive specific notes
====================

Note for hitachi, sony and plextor users (scsi drives)
======================================================

The commands required to read cdda audio data don't have the 'right' length
to be accepted by the kernel scsi ioctl interface (12 instead of 10). 
Instead you have to use the generic interface. Since kernel version 1.1.68
the generic interface supports variable length in one group (thanks to Eric
and Drew!). Cdda2wav version 0.2 had a patch to change the kernel default
length. This is no longer encouraged, since possible conflicts with other 
vendor specific commands for ie photo CD handling are likely.
 

Configuration
=============

There are some adjustable parameters in the beginning of the Makefile:

INTERFACE: How is the cdrom accessed.
DEVICE:	The default cdrom device is set in DEF_DEVICE.

WAV SOUND FILE FORMAT DEFAULTS:
The default format of the wav output file is determined by the following
macros:

RATE: the default rate is given by setting DEF_UNDERSAMPLING to the divisor
for the audio cd sampling frequency (44100 Hz). The following divisors are
valid:

divisor		   1,    2,   3,     4,   6,   7,    12,   14,    28,  49
sample rate	44.1 22.05 14.7 11.025 7.35  6.3  3.675  3.15  1.575  0.9 KHz

(see cdda2wav.1 or cdda2wav.doc for the reason of those specific divisors).

DYNAMIC: The default dynamic range of one sample in one channel is defined in 
DEF_BITS which can be one of 8, 12 or 16.

CHANNELS: set DEF_CHANNELS to 1 for mono and 2 for stereo.

RECORDING TIME: set DEF_TIME to the amount of seconds to record.

AUDIO FILENAME: set DEF_FILE to the name of the wav audio file to be used.

SOUND DEVICE: set SOUND_DEVICE to the device name of your dsp (compatible)
		sound device. The line containing HAVESOUND should be 
		uncommented also, if you want to monitoring.

All of those values can be overridden by command line parameters.

There are directories for the binary and the man page also.


Compiling cdda2wav
==================

Nothing special. Configure the Makefile for your cdrom interface 
and device setting first.

Then type
	make
and as root
	make install

This will compile cdda2wav and copy the binary to /usr/local/bin and the
man page to /usr/local/man/man1 (defaults).


Priviledges
===========

cdda2wav uses ioctls, which are allowed with root priviledges only,
regardless of your permission setting of the cdrom device. The 
'make install' sets cdda2wav to setuid root. The output file will have
to your real uid/gid.


Select device
=============

By default cdda2wav uses the scsi ioctl interface and a corresponding
device /dev/sr0. If you need to use another interface, check the device
setting also as they need to fit together.
This setting can be overridden by specifying '-D cdromdevice'.


Features
========

When recording in mono, both channels are summed with halved amplitude.

Undersampling is done by summing several samples with reduced amplitude to
prevent overflows. This damps higher freqencies as well.

Sampling can be aborted by pressing the Interrupt-Key (eg control-C)
at anytime (but see next section). The wav header will be updated to
contain the actual length of the sample. The same will happen, if disk
space becomes exhausted.

Known problems
==============

1. Interrupting the sample process while using the generic scsi interface
may leave the process in a passive state. This is due to bugs/flaws in 
the generic scsi driver (will be investigated).

2. The index scanner can lead to timeouts due to fast random accesses.
Problems herewith are very dependent on

a) the TIMEOUT constants in the kernel
b) the cdrom (scsi) controller
c) the driver handling of abort and reset
d) the speed/load of your machine

May be you have to adjust some usleep values in function binary_search...
This will be investigated, but take some time. At some time usleeps 
should not be necessary anymore.

3. Sound quality

Hesitations:

When recording the same audio track twice, recordings can slightly differ.
In this case some overlap (or even underlap?) betweeen successive accesses 
is introduced from the cdrom drive.
|----------------------|   first read
                     |------------------------| second read
                     |-|   extra bytes

This is due to synchronisation problems between sectors inside the cdrom 
drive.
When the drive has been forced to wait, problems arise to continue exactly
at the right spot. Audio cds are lacking sector headers, so it's a difficult
job to do it right. (The plextor 4plex drive is rumored to get it done 
correctly.)

4. Periodic short noises
This occurs under the NEC Multispin 2X.


Audio Format Conversion
=======================

The sound converter 'sox' can be used to obtain other sound formats.


Further possibilities
=====================
To reduce the above mentioned stop and go of the cdrom drive, nonblocking
(asynchronous) I/O would help. A double buffer, double process scheme 
might be a substitute. Don't expect this too soon...

Further non scsi drive support could be added (to the kernel) by people 
having such drives (and specs).

Tested patches, any hardware information regarding drives as well as success/
failure reports are always welcome to heiko@colossus.escape.de.


known cdda capable drives
=========================
From the cdrom-FAQ of rtfm.mit.edu:
  The following drives can do digital audio extraction over the SCSI bus:

  Apple 300, 300i (Sony CDU-8003, CDU-8003A)
  Apple's "New" CD (Matsushita CR-8004)
  Chinon CDS-535 (note: needs v2.0 firmware "Q20" or "R20")
  NEC CDR 500, CDR 510, CDR 600 (MultiSpin 3x series)
  NEC CDR 400 (MultiSpin 3xp portable)
  NEC CDR 900 (MultiSpin 4x Pro quadruple speed)
  NEC CDR 84-1 (74-1) only with special new firmware upgrade from NEC
  Sony CDU-561
  Toshiba XM 3301TE (Silicon Graphics version)
  Toshiba XM 3401TA, XM 3401B
  Toshiba XM 3401TE (Silicon Graphics, and Sun versions)
  Toshiba XM 4101TA, XM 4101B
  Toshiba XM 3501B
  Toshiba XM 5201B


 
Panasonic 	CR-562B
(Matsushita)  	CR-563B

Aztech 		CDA 268-01A according to german magazine  c't  6/94 p. 172

Sony 		CDU33A	    according to german magazine  c't  6/94 p. 172
		CDU8002 (Apple CD-150)

Plextor		4Plex PX-43CH

others?


known cdda uncapable drives
===========================
Mitsumi		FX001D(E)
		LU00x
Pioneer		DRM-602X, DRM-604X
Teac		CD-55A		(panasonic bus)
Philips		CM206/10	serial RS-422
		CM207
		CM226/10	serial RS-422
		CDD462/01	serial RS-422
Orchid		CDS3110


totally unknown (may be)
========================
Aztech		CDA268-031 SE
Chinon		CDS-525S
Mitsumi		FX300
Pioneer		DR-U104X
Elitegroup	Vertos 100, 300
Wearnes		CDD-120A


Additions to the tables above are welcome.


How to find out whether your FOOBAR drive is capable of cdda reading
====================================================================
If feasible, contact your cdrom manufacturer. Supply firmware
release and version as well as manufacturing date on your request.
This is the most reliable way to determine.

If you have msloss cdrom drivers and a mscdex.exe, you could try
a german shareware program named 'dac' to find out. It needs raw mode
support from the cdrom and driver and will tell you what it found.
This is useful for nonscsi drives. Unfortunately there are german
docs only.

It is available via mailserver from

	archive-server@joker.ruhr.de

Put 'get cd/dac.arj' in the body.


and now catch your sounds,
Heiko 		heiko@colossus.escape.de

