Fri Oct 11 2002

I suck at writing online documentation, but I'll try to give a brief
rundown on the basic operation.  This program is still VERY "alpha" at
this time.  Any feedback is greatly appreciated.

Where can I find the latest version?

http://www.hoxnet.com/dat-tools/wdat_0.01.tar.gz

What is it?

Wdat is a program for reading and writing Digital Audio Tape (DAT)
compliant tapes with a SCSI drive designed for this purpose.  Note that
this only works with drives designed to do this.  The vast majority
of DDS drives will NOT work with this program.  Silicon Graphics
Inc. (SGI) wanted this capability with their multimedia workstations and
commissioned (at the time) Conner peripherals with the task of building
a audio capable DDS drive.  Conner already made DDS drives badged as
"Archive" and all they really had to do was design a firmware upgrade
for them that would allow read/write of audio tapes.  SGI continues to
ship audio capable drives with their workstations and servers, but the
mantle has fallen to Sony.  For more information, see the DATFAQ at:
<http://www.ncf.carleton.ca/~aa571/datfaq.htm>

How does it work?

Wdat uses the linux "generic SCSI" interface to access the device.  This
has several advantages over the standard tape driver included with
linux as it allows many of the specific commands related only to audio
processing to be used by the program without the need to patch the
linux kernel.  In read mode, the program reads from the tape and writes
to a WAV file.  In write mode, one or several wave (or raw PCM) files
are read from the harddisk and written to the tape.  There are options
to add a lead-in, lead-out, end-id, and silence gaps between files.

How do I build it?

The program is written in ANSI C and should compile without problems
on any modern linux system.  It has been tested on Slackware 8.1,
gentoo 1.2, and RedHat 7.  If you are reading this, then you should
have already unpacked the TAR file, so at this point, all you need to
do is type: "make install".  This will build the program, and install
the executable into /usr/local/bin.  There are currently no man pages
or any other files to litter up your harddisk, so if you want to get
rid of it, then just nuke the directory you un-tarred it to and remove
/usr/local/bin/wdat and it will be like it never existed.

How do I run it?

Once compiled and installed, type "wdat -h" to see a list of options.
This is what you'll see:

    Usage: wdat [options] [[input file] [input file] ...] }
    Options:
            -h      This help menu.
            -d dev  Set the SCSI generic device (default is /dev/sga).
            -w      Write Mode (default is "read" from tape).
            -o fn   Specify the output file, fn, in read mode (default is STDOUT).
            -l n    Specify the length, n, in seconds for a "lead-in".
            -r n    Specify the sample rate, n, for writing (44100 or 48000)
            -g n    Specify a length, n, in seconds for track gaps.
            -e      Write an END-ID at end of tape.

    Obviously, different options apply for read and write operations.
    RIFF (wave) files, or RAW little-endian files are expected for input.
    Output file is written as RIFF (wave).

If you just want to read a tape, then all you should need to do is type:

  wdat -o myfile.wav

and hit enter.  By default, it will look for an audio capable drive
on /dev/sga (the first SCSI device found when the kernel boots) This
was chosen since most DATHeads wanting to do this probably just bought
the drive and a cheap SCSI card and it is the only SCSI device in the
computer.  If this is not the case, then you will have to specify
another device.  You can figure out which one to use by typing:

  cat /proc/scsi/scsi

You will get a list that looks something like this:

    Attached devices: 
    Host: scsi0 Channel: 00 Id: 00 Lun: 00
      Vendor: SEAGATE  Model: ST39102LW        Rev: 8320
      Type:   Direct-Access                    ANSI SCSI revision: 02
    Host: scsi0 Channel: 00 Id: 01 Lun: 00
      Vendor: SEAGATE  Model: ST39140W         Rev: 1444
      Type:   Direct-Access                    ANSI SCSI revision: 02
    Host: scsi0 Channel: 00 Id: 02 Lun: 00
      Vendor: ARCHIVE  Model: Python 01931-XXX Rev: 5.63
      Type:   Sequential-Access                ANSI SCSI revision: 02
    Host: scsi0 Channel: 00 Id: 04 Lun: 00
      Vendor: HP       Model: C1537A           Rev: L708
      Type:   Sequential-Access                ANSI SCSI revision: 02

In this case, the drive we want is the third in the chain so we need to
use /dev/sgc (the third generic scsi device).  You can specify this on
the command line as:

  wdat -d /dev/sgc -o myfile.wav

and you're on your way.  The program will keep trying to read from the
tape until a limit of 2 gigs is reached (about the length of a 90M
tape).  It is unlikely that audio data will fill the whole tape, but
I haven't come up with a good idea for figuring out when the end is
reached.  You can break out of the read at anytime by hitting CTRL-C.
This will stop the read and flush any remaining data to the wave file,
and fix-up the wavefile header to reflect the total size of the file.
What you do with the wave file from this point on is up to you.  You
will need to split it up or resample it (or whatever) using your
favorite editing software.

While reading the file, a running report of what is going on is
displayed.  This includes A-Time, sample rate, sub-id, main-id, error
counts, and other information.  After a typical read, your screen will
look like this:

Reading from tape.  CTRL-C to exit and save file.
44K ATIME: 00:00:02 SUBID: 60AA0200 MAINID: 0004 ERR A:00 B:00
 Sample rate changed from 44K to 48K
48K ATIME: 01:10:32 SUBID: 20AA0200 MAINID: 0000 ERR A:00 B:00
 Read error detected on head A at (01:10:32 Fr:66) file position: 812928252
48K ATIME: 01:13:31 SUBID: 60AA0200 MAINID: 0000 ERR A:01 B:00
Done.  Writing RIFF/WAV header

In this case, an unrecoverable error occurred during the read.  This may
result in a spike in the wave file and may need to be corrected.  DAT
decks do this automatically, but this functionality is lacking in the
firmware of the audio capable drives.  Perhaps I will come up with a
software implementation if I can figure out an appropriate algorithm.

Writing audio files to a tape is a bit more complicated.  Here's a
typical example:

  wdat -w -l 60 -g 5 -e GratefulDead_1972-08-27_set1.wav GratefulDead_1972-08-27_set2.wav

In this case, we have two wave files, each being a entire set of a show.
The options are:

  -w       Enable "write mode"
  -l 60    Write a 60 second lead-in before writing any data to the tape.
  -g 5     Write a 5 second gap between set 1 and set 2.
  -e       Write an end-id after everything is done.

You can put any number of wave files on the command line after the
options.  Suppose you rip tracks from a cd.  In this case you don't want
any gap between the tracks.  If the files are all alphabetically named,
then you can use a wildcard specification to save on typing.  Example:

(rip a cd with your favorite software.  You have a directory of files):

    ls -l
    total 529793
    -rw-r--r--    1 root     root     50142332 Jun 12 13:40 track_01.wav
    -rw-r--r--    1 root     root     44062412 Jun 12 13:31 track_02.wav
    -rw-r--r--    1 root     root     44332892 Jun 12 13:42 track_03.wav
    -rw-r--r--    1 root     root      5068604 Jun 12 13:43 track_04.wav
    -rw-r--r--    1 root     root     47708012 Jun 12 13:34 track_05.wav
    
    wdat -w -l 60 -e *.wav

This will write the files in order of their directory listing (sorted
alphabetically by default in linux) to the tape.  Since CD frames are
2352 bytes and DAT frames are 5822 bytes, there will no doubt be some
overlap.  The program automatically corrects this by taking the last
data read from a previous wave file and adding it to the beginning of
the current wave file.  No data is lost and the tracks are seamlessly
concatenated (unlike most CD software).

wdat automatically adds a START-ID at the beginning of each new wave
file and increments the track number.  There currently are no options
available to manipulate the start-id's or track numbers.

Here is what you'll see on the screen from the above command:

    Writing 5 files with 60 sec. lead-in and 0 second gaps.
    Format:  48K 00:00:00 00BB0080 0004
    Lead-in: 48K 00:00:59 00AA0400 0000
    track_01.wav is a RIFF (wave) file.  Rate=44100 00:04:44
    Writing: 44K 00:05:44 00AA0400 0004
    partial read: 588 bytes

    track_02.wav is a RIFF (wave) file.  Rate=44100 00:04:09

    tacked on 588 bytes to make 5292 total
    Writing: 44K 00:09:53 00AA0400 0004
    partial read: 1764 bytes

    track_03.wav is a RIFF (wave) file.  Rate=44100 00:04:11

    tacked on 1764 bytes to make 5292 total
    Writing: 44K 00:14:05 00AA0400 0004
    partial read: 3528 bytes

    track_04.wav is a RIFF (wave) file.  Rate=44100 00:00:28

    tacked on 3528 bytes to make 5292 total
    Writing: 44K 00:14:34 00AA0400 0004
    partial read: 2352 bytes

    track_05.wav is a RIFF (wave) file.  Rate=44100 00:04:30

    tacked on 2352 bytes to make 5292 total
    Writing: 44K 00:19:04 00AA0400 0004
    partial read: 2940 bytes

    tacking on 2940 bytes from partial read
    Lead-out:44K 00:19:14 00EE04C0 0004



That's about all I feel like writing at this time.  Please give me your
comments on areas for improvement.  I can be reached by email at:

<wayne@hoxnet.com>


Acknowledgements:

Shane Calhoon, the first guy I knew who had his own DAT deck and got me
     started in the whole mess.

Marcus Meissner, The author of DATLib.  His work was my inspiration and
     much of my information was gleened from his source.

Joseph Gray, The Author of a freeware VB program for windows from which
     I was able to gain some information that was rather hard to find.

Ade Rixon, A guy who compiled a lot of useful information on DAT audio
     drives and yet another source of useful information for my project.
