TTA — Описание формата

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, using the lossless True Audio algorithm. Free and fully-functional for any use. The TTA has a very simple structure. The file header of TTA file 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 TTA 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
Byte numberValue (format)
Stream header
00-03Format signature with version number (ASCII, "TTA1")
04-05Audio format (binary, Little Endian)
06-07Number of channels (binary, Little Endian)
08-09Bits per sample (binary, Little Endian)
10-13Sample rate (binary, Little Endian)
14-17Data length in samples (binary, Little Endian)
18-21CRC32 block footer (binary, Little Endian)
Таблица поиска1
22-25Seek point 1 (binary, Little Endian)
26-X0.. .. .. .. .. .. .. .. .. .. .. .. .. ..
X1-X4Seek point N (binary, Little Endian)
X5-X8CRC32 block footer (binary, Little Endian)
.. .. .. data .. .. ..
1 In the format TTA1 the Seek table is located at the start of the file, following the meta-data block.
TTA2 headers (in development)
Byte numberValue (format)
Stream header
00-03Format signature with version number (ASCII, "TTA2")
04-05Number of channels (binary, Little Endian)
06-07Bits per sample (binary, Little Endian)
08-11Sample rate (binary, Little Endian)
12-15Channel locations mask2 (binary, Little Endian)
16-23Data length in samples (binary, Little Endian, may be zero)
24-31Data size, bytes (binary, Little Endian, may be zero)
32-35CRC32 block footer (binary, Little Endian)
.. .. .. data .. .. ..
Stream footer (Seek table)
00-02End of stream signature (binary, "0xFFFFFF")
03-06Seek point 1 (binary, Little Endian)
07-X0.. .. .. .. .. .. .. .. .. .. .. .. .. ..
X1-X4Seek point N (binary, Little Endian)
X5-X8CRC32 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
Byte numberValue (format)
00-X0Frame data (bit stream)
X1-X4CRC32 block 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 frame length of TTA1 = frame time * sample rate.
TTA2 frame (in development)
Byte numberValue (format)
00-X0Frame data (bit stream)
X1-X3End of frame signature (bit stream, "0xFFFFFE")
X4-X7CRC32 block footer (binary, Little Endian)
The frame duration in the TTA2 формате теоретически может быть любой, но из соображения удобства использования выбрана равной одной секунде. Таким образом, количество сэмплов с стндартном TTA2 фрейме определяется частотой дискретизации.

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