Skip to content

TZX ​

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 ​

ClassDescription
TzxFormatSingleton format for reading and writing TZX files.
TzxFileRepresents a TZX file with a header and a list of blocks.
TzxBlockBase class for all TZX blocks.

Reading and Writing ​

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

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

Blocks ​

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

Block TypeDescription
StandardSpeedDataBlockStandard ROM timing (most common).
TurboSpeedDataBlockCustom timing for turbo loaders.
PureToneBlockA repeating tone pulse.
PulseSequenceBlockAn arbitrary sequence of pulse lengths.
PureDataBlockData without leader/sync pulses.
PauseBlockA pause or stop signal.
GroupStartBlock / GroupEndBlockNamed group of blocks.
LoopStartBlock / LoopEndBlockRepeated block sequence.
TextDescriptionBlockInline text comment.
StopTheTapeIf48KBlockConditional stop for 48K machines.
ArchiveInfoBlockArchive metadata (including title, author and publisher).
c#
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.