TTA Lossless Audio Codec - Format Description

From Tau Projects
Jump to: navigation,
TTA Audio Codec Logo

Detailed description of the TTA multichannel audio data format

TTA is a simple and stable lossless audio data format for real-time compressing of digital music. Free and fully-functional for any use. It has a very simple structure. The TTA file header contains a unique format identifier, which is followed by meta-data block. Meta-data block contains minimal information which is needed for restoring the original stream (including number of channels, count of bits per sample, sample rate and overall number of samples in file, etc.) and ended by a 32-bit control sum. Following that header, we write one or more audio frames. Each frame is ended by a 32-bit control sum; a decoder may start decoding from any frame in the stream. The compressed samples of channels in a frame are located sequentially, as in a simple PCM data format.

TTA Header Structure

TTA1 header TTA2 headers (in development)
Byte number Value (format)

Stream header

00-03 Format signature with version number (ASCII, "TTA1")
04-05 Audio format (binary, Little Endian)
06-07 Number of channels (binary, Little Endian)
08-09 Bits per sample (binary, Little Endian)
10-13 Sample rate (binary, Little Endian)
14-17 Data length in samples (binary, Little Endian)
18-21 CRC32 block footer (binary, Little Endian)

Seek table1

22-25 Seek point 1 (binary, Little Endian)
26-X0 .. .. .. .. .. .. .. .. .. .. .. .. .. ..
X1-X4 Seek point N (binary, Little Endian)
X5-X8 CRC32 block footer (binary, Little Endian)

.. .. .. data .. .. ..

1 In TTA1 the Seek table is located at the start of the file, following the meta-data block.

 
Byte number Value (format)

Stream header

00-03 Format signature with version number (ASCII, "TTA2")
04-05 Number of channels (binary, Little Endian)
06-07 Bits per sample (binary, Little Endian)
08-11 Sample rate (binary, Little Endian)
12-15 Channel locations mask2 (binary, Little Endian)
16-23 Data length in samples (binary, Little Endian, may be zero)
24-31 Data size, bytes (binary, Little Endian, may be zero)
32-35 CRC32 block footer (binary, Little Endian)

.. .. .. data .. .. ..

Stream footer (Seek table)

00-02 End of stream signature (binary, "0xFFFFFF")
03-06 Seek point 1 (binary, Little Endian)
07-X0 .. .. .. .. .. .. .. .. .. .. .. .. .. ..
X1-X4 Seek point N (binary, Little Endian)
X5-X8 CRC32 block footer (binary, Little Endian)

2 Channels Location Bitmask

The quotient of overall count of samples and "frame length" defines the total number of frames in data stream. The seek table must have a number of seek-points equal to the number of frames in the stream. Each seek-point uses 4 bytes, contains the current frame data length in bytes and can be easily transformed into the Seek point value which specifies the location of the next frame. It is possible to decode TTA file with a corrupted seek table, but in "unseekable" mode only.

TTA Frame Structure

TTA1 frame TTA2 frame (in development)
Byte number Value (format)
00-X0 Frame data (bit stream)
X1-X4 CRC32 frame footer (binary, Little Endian)

The frame duration in the TTA1 format is fixed at about one second. Therefore, every frame in a stream has an equal count of samples, except for the last. The sample count in a TTA1 frame is a multiple to 576 (sound buffer granule). Based on this, the "frame time" is defined as a constant 1.04489795918367346939. Thus, the sample count in a regular TTA1 frame determined as:

regular TTA1 frame length = frame time * sample rate

 
Byte number Value (format)
00-X0 Frame data (bit stream)
X1~X3 End of frame signature (bit stream, "0xFFFFFE")
X4-X7 CRC32 frame footer (binary, Little Endian)

In theory, the frame duration in the TTA2 format can be any length, but for ease of use is defined equal to one second. Thus, the sample count in a standard TTA2 frame determined by sample rate.

The total number of frames in TTA data stream can be calculated as a quotient of overall count of samples and standard "frame length". TTA format supports both of ID3v1/v2 and APEv2 information tags.