WAV2PRG
By Fabrizio Gennari and Janne Veli Kujala, 1999, 2000

This programs converts WAV files containing samples of Turbo Tape 64 files
to PC in emulator-readable format (.PRG, .P00 or .T64), so they can be
played with PC emulators. This is done in three steps.

1. CREATING THE FILE

1.1 WAV
For this you need:
- a sound card
- a tape player
- a cable connecting the output of your tape player (e.g., the headphone
  jack socket) to the input of your sound card (on a Sound Blaster, this
  is a jack socket marked as LINE IN)
- a sampling program (e.g. WaveStudio, bundled with any SoundBlaster,
  Goldwave or CoolEdit)

First of all, connect the tape player to the sound card. You should hear
the sounds emitted by the player from the speakers of your sound card. Set
the volume of your player to a reasonably high level (half the maximum
should be fine). Set the mixing options of your sound card so the
recording level of the external input is the highest, and the other
recording sources are disabled (this is done using Windows' Volume Control
application). Set the volume of your computer speakers low, so you will not
be made deaf by the grating sound coming from the tape. Now, run the
sampling program and set the recording options as it follows:
* Sampling frequency: 44100 Hz
* Sample size: 8 bits
* Format: PCM uncompressed, mono
WAV-PRG will not recognize files in a different format than this.
Now, sample the file and save it in WAV format.

1.2 TAP
This is more difficult. One way is to convert to WAV first, using the above
procedure, then converting the WAV to VOC and using 64VOCTAP
(http://cia.c64.org/tools/64util05.zip) to create a TAP. Or convert to WAV, then
to TAP with Tape64 (http://members.tripod.com/Andreas_Matthies/c64/).Another way
is to connect the datassette to your PC's parallel port and use mtap
(http://arnold.c64.org/~minstrel).

2. CONVERTING THE FILE
This is what WAV2PRG does.

The usage is:

wav2prg -h|-v
wav2prg [-i] [-p|-d|-t <T64 file name>[-n <internal T64 name>]] <input .WAV file>

By default, WAV2PRG will convert to .PRG. This can be changed with the -p
(convert to .P00) and -t (convert to .T64) options.

When converting to .PRG or .P00 files, wav2prg creates one .PRG or .P00 file
for each Turbo Tape file it detects in the .WAV. When converting to a .T64
file, wav2prg will convert all the files into a single .T64 file.

If you want to convert to a .T64 file, you will need to specify the name
of the .T64 file on the command line. Optionally, you can also specify the
tape image's name: if you don't, the default "GENERATED BY WAV2PRG" will be
used. Note that wav2prg cannot append files to an existing .T64 file: if the
filename you specify already exists, it will be overwritten.

The options are as follows:

-d
Obsolete: kept for backwards compatibility only
-h
Show a help message and exit successfully.
-i
Tell WAV2PRG that the .WAV file has an inverted waveform. Some soundcards
invert the signal when sampling, i.e. they turn positive impulses into
negative ones and vice versa. If the .WAV file was generated with such a
soundcard, WAV2PRG must be run with the -i option in order to detect the
files. If you get no results without the -i option, try enabling it.
-p
Convert to .P00 files. This option is obviously incompatible with -t
-t
Convert to a .T64 file. This option is obviously incompatible with -p
-v
Show version and copyright info and exit successfully

When WAV2PRG is started (without the -h and -v options), the conversion
process will start, and WAV2PRG will scan the .WAV file in
search of a Turbo Tape header. When it finds one, the message "Found!"
appears. You should see the C64 filename, and the start and end addresses.

At the end of the conversion, you will see one of these messages:
* "Checksum error!": this is the same as ?LOAD  ERROR. You could try
sampling the file again, adjusting the output volume of your tape player so
it is not too high nor too low. Disable all the recording sources to your
soundcard but the external one (LINE IN). You could also try "regenerating
the signal": don't worry, it is easier than it sounds. Just load the file
on your C64 and save it on a new tape. The freshly-saved file will be
easier to convert.
* "The WAV file ended unexpectedly": the final part of the file was not
sampled. Try sampling for a longer time.
* "Successful": everything went fine.

After this, WAV2PRG will search for another header, until the end of the
.WAV file. Then, it will exit.

What if WAV2PRG cannot find any header? There can be a number of reasons
behind this: a low-quality tape, too low or too high volume from the tape
player, but the main cause is a soundcard which inverts waveforms. If it
does, WAV2PRG will not be able to recognize them. Try again, this
time using the -i option: this will tell WAV2PRG that the file has an
inverted waveform. This will work in most cases.

In fact, another cause could be that the C64 file was not in Turbo Tape 64
format. The only safe way to check this is to try loading it using Turbo
Tape 64 (available at WAV-PRG's homepage). If Turbo Tape 64 can load it,
then WAV2PRG can convert it. If not, it can't.

3. PLAYING THE GAME
You need a C64 emulator for this.

All the most popular emulators recognize all or some of the .PRG, .P00 and
.T64 formats.

4.RULES FOR CHOOSING FILE NAMES
When converting to .PRG or .P00, the following rules are used to choose the
output file name.

4.1 P00
Automatic renaming is always enabled. The C64 name will be shrunk to 8
characters according to the PC64 rules. The extension .p00 will be added. If
the file does not exist, it will be created. It if exists, the extension
will be replaced with .p01 etc. If even the file with extension .p99 exists,
the file will be skipped.

4.2 PRG
Manual file anming will be used. WAV2PRG will interactively ask for a file name. .prg will be added. If a file with that name does not exist, it will be created. If it does, WAV2PRG will interactively ask "Overvrite, Rename, Skip [S]". O will
overwrite the file, R will allow the user to choose another name (if that
name exists too, the message "Overvrite, Rename, Skip [S]" will appear
again), S will skip the file.

5. LICENSE AND (NON)WARRANTY
This program is distributed under the GNU General Public License. See the
file LICENSE.TXT for details.

6. LATEST VERSION
The latest version of the program is available at
http://www.geocities.Com/SiliconValley/Platform/8224/wavprg.html .

7. CONTACTING THE AUTHORS
If you have suggestions, bug reports etc., you can send mail to the author
at:
fabrizio.ge@tiscalinet.it
jvkujala@cc.jyu.fi

Enjoy!