TapeFix: ZX Spectrum Tape Recovery Tools


Revive Your Memories!!!

Written by Arsen Torbarina in 1998, updated in 2012

Do you still have some dusty ZX Spectrum tapes with all those good old games, or perhaps there are some programs of yours that you were proud of some decades ago? And now you are keen to load them again, but they just don't seem to be readable anymore! If you think that those recordings are lost for good - you are awfully wrong! A DOS program called TapeFix comes to the rescue to help all those desperately trying to recover their long forgotten Spectrum programs, including the speed-locked ones...

Main Screen

On the Road Again...

TapeFix is a DOS utility that will recover almost any old recording that due to damages or signal loss caused by aging, became impossible to load. Version 1.0 requires a 16-bit WAV or a RAW sample input file. After filtering, the data will be read and written to a TAP file. The generated file (in case you don't own the "Z80" Emulator) can be transformed back to a WAV sample and then played back to a tape.

To run the program you should have a PC supplied with a sound card and some wave editing software, such as CoolEdit or any free alternative.

How Does the Spectrum Store Data To a Tape?

For saving data to a tape, Spectrum uses a very simple method called frequency modulation. Each byte is saved to tape bit by bit, where the most significant bit comes first, and the least significant one comes last. Bit "0" is coded with a 2044 Hz impulse and bit "1" with a 1022 Hz impulse. Statistically, it results in 1500 bits per second (1500 baud) in the case of similar number of appearances of "ones" and "zeros".

In order to ease the search for a block start, a leader tone of 808 Hz lasting for 3 or 5 seconds precedes the data. It is followed by a short impulse (about 2500 Hz) called the synchro-impulse, specifying the start of the data block. The synchro-impulse has a positive half-period that is a bit longer than the negative one, which results in a slight elevation of the signal on the very beginning of the block. That is probably made to emphasize the impulse, or to determine the signal polarization.

The very first byte written after the synchro-impulse is so called flag-byte specifying a block type. Usually 0 stands for a header, and 255 specifies a data block. It is followed by bytes representing the actual data. The last byte written is the checksum-parity byte. A loading routine ends as soon as it gets the last of N+2 bytes it has been expecting, where N is the number of payload data bytes.

Frequency Modulation
Frequency Modulation

Common Recording Deviations

When the signal is saved to a tape, all the sharp edges are smoothed, since the recording hardware cuts off high frequency harmonics. It results in a smooth, sine-like wave. On high-frequency performance tapes, such as metal and chromium-dioxide tapes, the signal is often found with sharp peaks on the front edge. Those peaks usually make problems during the loading and have to be eliminated by a selective filter.

Another, more common cause of loading errors, is the loss of the signal intensity, often followed by the impulse merging, caused by aging of the tape. This means that the impulse for a "zero" (which due to its shorter duration has a lower amplitude) merges with the first following signal. TapeFix easily solves this problem by using its specially developed methods of digital filtering.

Short gaps and peaks caused by the tape deformations, impossible to cirmumvent by using regular loading tricks - will be successfully smoothed.

Frequency deviation is also one of the most common deviations caused by using a bad tape recorder. The standard loading routine is very non-tolerant to frequency variations, but TapeFix can be set to accept any frequency range you want!

High-noise level, a very common cause of the "Tape loading error" found on cheap tapes or cheap tape recorders, will also be easily handled.

How Does the TapeFix Work?

There are several mechanisms that the TapeFix uses to decipher the recordings. The simplest one is the frequency tolerance boundaries, that can be set to almost any value. The frequencies can be given in two ways: either by specifying the values given in Hz, or by specifying the period length given in samples.

There are also two digital filters, specially modified for this purpose; A filter called deriving filter eliminates low frequency noise and separates merged signals. It is meant to be used only once - usually in the first pass of the processing.

A modified version of the Butterworth 1st order low-pass filter solves all the problems caused by noise and signals shape deformations. It will also smooth up all the shorter gaps and peaks in the signal.

The parameter of the Butterworth filter is the LOWPASS cutoff frequency. By default, it is set to 2100 Hz and it should do for most of the cases. In case of a sharp, edgy signal, even 2 or 3 passes of the low-pass filter should be performed!

Here is an example that illustrates how TapeFix copes with one very damaged recording (the bit sequence shown is 010001011110000000001).

Damaged recording
Original, damaged recording: A) Peak-noise, B) Merged impulses, C) Low signal level
After filtering
After the filtering: Noise removed, impulses separated, signal amplified
Generated WAV
Generated WAV sample
Recovered sample
Recovered sample after being saved back to tape

Let's Start...

Now, after you saw what the program does and how it works, it is time to learn how to use it. The usage is basically very simple - first digitize the recording you want to recover, save it as a WAV PCM file and run the TapeFix with or without several switches. Someone will say that the user interface is a bit clumsy since it uses a Unix-like command line to pass all the parameters to the program, but the program itself is designed to be more like a tool oriented to the experienced users, rather then a user-friendly product for rookies. In fact, I've gotten to know quite a lot of ingrained Unix-users that get offensive if a program does not require at least a dozen of switches - and the TapeFix in most of the cases won't need any.

After the sample is filtered, the loading begins block by block. For each loaded block, an info-box is displayed, containing some basic information such as block type, length, flag byte and its position in the sample. When the block is successfully loaded, its header-info box appears on the screen, containing all the basic information related to that block. If the checksum is valid, the box appears in blue and if not, the box appears in red.

Finally, a TAP file that is created, can be either loaded to the "Z80" emulator, or can be converted to a WAV or RAW sample using the included TAP2WAV utility and then played back to a tape. When playing the sample back to a tape, set TREBLE on your sound card to zero, to reduce the peaks on the first edge that will appear, due to the characteristics of the card.

Digitizing a Recording

Version 1.0 requires a WAV or RAW sample file for input. Using a good wave editor, record the whole program you would like to recover. The important thing is that it does not produce clicks and pauses on longer samples!

The recording has to be 16-bit due to the wider dynamic range, and stereo mode should be used only if the recording is very damaged and there is no other way of gaining a satisfying result, since the processing of a stereo recording lasts twice as longer.

For the standard recordings, made at normal speed, sampling frequency of 11025 Hz should do just fine. Higher sampling frequency should be the last resort!

Speed-locked recordings should be sampled on higher frequencies, depending of the used speed (e.g., for 3000 bd use 22050 Hz sampling).

And there's one thing you should be aware of. When digitizing a recording, be sure not to put the volume level too high to avoid signal clipping, which will corrupt the recording even more.

The Command Line Syntax

The allowed syntax is as follows:

TAPEFIX < sample > [TAPfile] [< INIfiles >] [LOGfile] [< params >] > outfile

When starting the program, the name of the sample has to be specified in the command-line. E.g.:

tapefix sample.wav

This way, the processing will be done using the default parameter setting stored in the program itself, and those stored in TAPEFIX.INI file (if there is one). In the example above, the results will be stored in the SAMPLE.TAP file. This can be changed by giving another TAP file name in the command-line. E.g.:

tapefix sample.wav tape.tap

If there is an existing TAP file, it will be overwritten, unless you want to append the new data to its end, using the /APPEND switch. When /APPEND is set, a "+" sign appears to the right of the TAP file-name in the status-window. /NEW switch cancels this option.

In order to have a better view on the processing you can create a LOG file where all the details, such as position of each byte and leader tracing will be written to. The first number in each line specifies the position of the current event, given in samples. This number, when referring to a byte or a synchro-impulse, specifies its END, not the beginning!

All In All...

There is a lot of switches used to set the filter parameters, so an average user could get confused on first glance! The good thing is that the default parameters will do in most of the cases, so you won't have to change any of them. And if something goes wrong, the program itself will suggest you what to do and which parameters you might consider changing.

As said before, the program is not aimed towards beginners, but to the more experienced users. If you started with the Speccy (and it's been long, long, time ago), it means that you are definitely not a rookie and that the TapeFix is just what you always needed to have in your collection, far before you even knew what a PC computer was!...