Skip to content

TZX Tape

TZX is the standard format for preserving ZX Spectrum tape recordings. Unlike TAP, TZX encodes the timing of pulses on the tape, making it suitable for non-standard loaders, copy-protected software, and archive metadata. TZX files contain a sequence of typed blocks, each with its own structure.

Details about the TZX format can be found at https://worldofspectrum.net/TZXformat.html.

API

Class Description
TzxFormat Singleton format for reading and writing TZX files.
TzxFile Represents a TZX file with a header and a list of blocks.
TzxBlock Base class for all TZX blocks.

Reading and Writing

// Read
using var stream = File.OpenRead("tape.tzx");
TzxFile tzx = TzxFormat.Instance.Read(stream);

// Write
using var output = File.Create("output.tzx");
TzxFormat.Instance.Write(tzx, output);

Blocks

A TzxFile contains a list of TzxBlock objects. Each block is a strongly-typed subclass:

Block Type Description
StandardSpeedDataBlock Standard ROM timing (most common).
TurboSpeedDataBlock Custom timing for turbo loaders.
PureToneBlock A repeating tone pulse.
PulseSequenceBlock An arbitrary sequence of pulse lengths.
PureDataBlock Data without leader/sync pulses.
PauseBlock A pause or stop signal.
GroupStartBlock / GroupEndBlock Named group of blocks.
LoopStartBlock / LoopEndBlock Repeated block sequence.
TextDescriptionBlock Inline text comment.
StopTheTapeIf48KBlock Conditional stop for 48K machines.
ArchiveInfoBlock Archive metadata (title, author, publisher, etc.).
foreach (TzxBlock block in tzx.Blocks)
{
    switch (block)
    {
        case StandardSpeedDataBlock data:
            Console.WriteLine($"Data: {data.Header.BlockLength} bytes, pause {data.Header.PauseAfterBlockMs} ms");
            break;
        case ArchiveInfoBlock info:
            foreach (var entry in info.Entries)
                Console.WriteLine($"{entry.Type}: {entry.Text}");
            break;
    }
}

Conversions

TZX files can be converted to TAP, PZX, and WAV.

When converting to TAP, only StandardSpeedDataBlock blocks are converted. Metadata and structural blocks (text descriptions, archive info, groups, pauses, and stop signals) are skipped. If the TZX file contains block types that cannot be represented in TAP (turbo speed data, pure data, pure tone, pulse sequences, or loops), the conversion will fail with an error message.

See Reading, Writing and Converting.