Hi cdrom drive users,

This README describes the installation of cdda2wav, the sampling utility.

Some cdrom drives are capable of sending audio data in digital form to the
host (cdda). The first drive used to implement this was the toshiba 3401
scsi cdrom drive. Maybe others will follow.

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

As of date of releasing only toshiba 3401 scsi drives (with an
ultrastor 34f controller) have been tested and work.

Checking kernel
===============

WARNING:
Necessary requirement is a kernel which has a certain bug removed. Please
ensure that scsi_ioctl.diff has been applied to your kernel. Kernels upto 
1.1.8 at least had this bug. It causes ugly host timeouts (locking the 
system for some time). The file scsi_ioctl.diff should be included in your
cdda2wav tar archive.

Rebuilding a patched kernel
===========================
If you have to patch the kernel do

	cd /usr/src/linux/drivers/scsi

then copy or move the file scsi_ioctl.diff to this directory and

	patch <scsi_ioctl.diff

and on success do

	cd ../..; make zImage; 

should create the new kernel. Install it as usual and reboot.


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

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

DEVICE:	The default cdrom device is set in DEF_DEVICE.

SOUND 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 audio file to be used.

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

One other experimental parameter is SECTORS, which describes how much sectors
are read in one request from cdrom drive before writing to the sound file.

Here are some results from 'time':

recording 16 seconds mono with 16 bits @ 22050 Hz ->'audio.wav'
NSECTORS = 1	1.59user 0.78system 0:17.79elapsed 13%CPU
NSECTORS = 2	1.71user 0.55system 0:39.74elapsed 5%CPU
NSECTORS = 3	1.55user 0.54system 1:43.81elapsed 2%CPU

Note the increase in total elapsed time with higher NSECTORS, although the
CPU busy percentage drop down.

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

Nothing special, except that a math lib is currently needed. This
requirement will be removed sooner or later.

type
	make
and 
	make install

This will compile cdda2wav and copy the man page to /usr/local/man/man1.


Select device
=============
By default cdda2wav uses /dev/sr0 (or whatelse DEF_DEVICE is set to in the 
Makefile) as the cdrom drive device.
This can be overridden by specifying '-D cdromdevice'.

Of course you know that in order to use the device as non root the device 
permissions have to be set accordingly.

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 control-C at anytime. The wav header will
be written correctly before terminating.

If disk space is exhausted, sampling will be finished and the correct wav 
header will be written to file.


Further possibilities
=====================
Other sound formats could be implemented. Raw data without a header does
not make sense, since after some time nobody knows the format of the sampled 
data anymore. Determining the format with od or hexdump is for real experts
only :-).

Non scsi drive support could be added by people having such drives
(and specs).


(Tested patches are welcome to heiko@colossus.escape.de).

More drives?
============
Drives that should be capable of doing cdda:
Toshiba		XM3401B
		XM4401B

Panasonic 	CR-562B	according to Yeng-Chee Su yenchee@csie.nctu.edu.tw
	  	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

others?

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

