TAK

(T)om's lossless (A)udio (K)ompressor.

Version: TAK 1.0.2, 2007-04-14

Copyright 2006 by Thomas Becker, D-49080 Osnabrück.
All rights reserved.

License

This software is provided as FREEWARE, but only for private, non-commercial use. It's also free for educational and scientific use and for use in charity and humanitarian organisations.

Disclaimer of warranty

The software is provided "as is" without warranty of any kind. To the maximum extent permitted by applicable law, the author further disclaims all warranties, including without limitation any implied warranties of merchantability, fitness for a particular purpose, and non-infringement. The entire risk arising out of the use or performance of the product and documentation remains with recipient.

To the maximum extent permitted by applicable law, in no event shall the author be liable for any consequential, incidental, direct, indirect, special, punitive, or other damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of this agreement or the use of or inability to use the product, even if the author has been advised of the possibility of such damages.

Distribution

The Software may be freely distributed provided that it is not modified and the original archive remains intact with all accompanying files, and provided that no fee is charged (except for any reasonable fees necessary to cover costs of distribution media).

Contact

I am frequently active in the Lossless Audio Compression forum at Hydrogen Audio; a good place to ask questions regarding TAK.

My homepage, www.thbeck.de, contains some information about TAK, but unfortunately only in German.

If you would like to contact me by email please be aware that I will not always have time to answer.

Thank you

Thank you to all the people who have supported the development of TAK, most of whom are members of Hydrogen Audio.

Firstly, they have provided encouragement to build yet another lossless audio compressor. Otherwise I would have dropped the whole project!

They helped to evaluate and optimize TAK. There have been 13 releases over a period of 8 months before the alpha version, and all of them have been evaluated by those testers!

About TAK

TAK is a lossless audio compressor, similar to FLAC, WavPack and Monkey's Audio. On average, lossless compression reduces the file size to about 50 percent of the original size; however the compression can vary between approximately 30 and 70 percent, depending on the file. Decompression restores a bit identical copy of the original audio data (that's why we call it lossless).

My goal was to develop a compressor which combines good compression with optimal decoding speeds. On average, the current implementation should match the compression efficiency of Monkey's Audio High, while achieving decompression speeds similar to FLAC.

Features

Missing features

Some important features are missing in this release. Please find below my current to-do list (in order of my current priority):

Supported file formats

Only Wave for now.

As the streaming format is only partially implemented, and because some less common formats need some more fine tuning and verification, only a subset of the possible audio formats are supported in this version: Sample rates from 8000 to 96000 Hz. Bit depths of 8, 16 or 24. Channels: Mono or Stereo.

The final implementation should support any sample rate from at least 8 to 192 KHz, 8 to 24 bits per sample, and up to 16 Channels.

Wave files may be up to 4 GB in size (to be exact: 4 GB minus 15 bytes for now). Unfortunately some applications partition the audio data in chunks of 2 GB size, if the source data is bigger than 2 GB. This is against the Wave file format standard and currently not supported by TAK.

Tagging

While TAK does not yet support tagging on its own, you may use external taggers to append tag data to the end of the compressed file. The decompressor will simply ignore the extra data. You are recommended to use APEv2, and this is likely the format that TAK will use when tagging is implemented.

Please note, the current decompressor will throw an error message if you have prepended tags to the beginning of the file. This may be fixed in later releases.

GUI and command line version

The archive contains two versions of TAK:

Compressing files with the GUI version

File management

Compression creates files with the same name as the source, but with the extension '.tak':

    Sample.wav -> Sample.tak

By default existing files will not be overwritten.

Quick tour

Warnings and errors

If there are any problems with a file you will see a short message following the file name:

Message Description
Meta data too big The non-audio wave file meta data was bigger than 1 MByte, and could not be stored in the file. The audio data itself is intact.
Audio format not supported The current encoder implementation cannot handle the source audio format.
Wave file not supported My wave file reader was not able to parse the wave container, or the source file structure is damaged.
Error reading source A source I/O error occurred.
Error writing destination A destination I/O error occurred.
Verify failed! This will only happen with Verify enabled. Possible reasons: A bug in the encoder, or instable hardware.
Already exists The destination file already exists, and you have not specified the Overwrite option.

Options

The Options dialog lets you choose encoder options like preset and evaluation level, which affect compression efficiency, encoding and decoding speed. Furthermore you may specify output options like for instance the destination directory.

Encoder options

Encoder options

Presets

The presets TURBO, FAST, NORMAL, HIGH and EXTRA have been carefully configured to achieve the best compromise between encoding speed and compression performance. Each higher preset should encode approximately 1.6 times slower than the preceding one, and provide the maximum compression performance that is possible at that speed.

The presets TURBO, FAST and NORMAL are called restricted hardware profiles.

Profiles may become important, if TAK should be supported by hardware players. Some hardware players may be limited in terms of CPU power or memory size, and not be able to play files which have been encoded by using more demanding encoder options. The manufacturer may specify the maximum hardware profile that can be used by the player. More powerful players may even support the unrestricted presets HIGH and EXTRA.

Additional evaluation

After selecting a preset you may select an additional evaluation level EXTRA or MAX. This will add internal encoder options to your preset which provide better compression but slow down encoding; however, importantly, they will not significantly affect decoding speed!

Their primary purpose is getting the most out of the hardware profiles: regardless of the evaluation level you will always stay within the set of allowed options for the selected profile.

Level Extra is most effective on presets TURBO and FAST. Here it can improve the compression by up to 0.30 percent while reducing the speed by only about 30 to 40 percent.

Level Max sets all possible options to the maximum. Encoding can be 2 to 3 times slower, depending on the preset.

If you want higher compression and fast encoding, and are able to accept some decrease in decoding speed, it is usually preferable to select a higher preset instead of increasing the evaluation level.

The comparison table

is intended to give you an idea of the effect of presets and evaluation levels on compression efficiency, encoding and decoding speed. It is based upon data from my primary test file set. Depending on your files and system you may get quite different results!

Each row contains the results for one particular preset-evaluation level combination. Your current choice is beeing highlighted. The data in the first three columns is always relative to your choice:

Compression difference tells you, how much better (positive values) or worse (negative values) the other settings performed. Example: if NORMAL is selected (Default), you can see, that EXTRA+MAX achieved 0.75 percent better compression on my file set. Percentage values always refer to the original, uncompressed file size.

Encoding/Decoding speed: How much faster / slower are the other settings on encoding / decoding.

Command line: The corresponding command line parameters for TAKC.

Verify

With Verify enabled, any compressed frame is subsequently decompressed and then compared to the original data. This reduces encoding speed, but is useful for the more paranoid among us!

Output

Output options

Destination

Where should the compressed files be stored:

!!! Overwrite existing TAK files !!!

Enable this option to overwrite already existing TAK files; otherwise they will be skipped. You will not be asked for a confirmation!

Save wave file meta data

When decompressing TAK always generates a bit identical copy of the audio data of the original wave file. Nevertheless, the resulting wave file may be different from the original!

This is because a wave file contains not only raw audio data, but also some header structures describing the audio format, and sometimes additional data which is not needed for the playback - for instance meta information created by the application that created the original wave.

Even if there is no additional (dropped) information besides the wave header, the wave file created by the decoder can be different from the original. This is because there are several different ways to create a valid wave header describing the same audio format. TAK may use an alternative to the creator of the original wave.

All this does not affect the validity of the audio data itself. It will always be bit identical to the original!

However, if you want to have a bit identical reproduction of the whole wave file, including the non-audio data, you may enable the "Save wave file meta data" option (enabled by default). TAK will store up to 1 MByte of non-audio data into the compressed file. If you enable the corresponding option of the decoder, you will obtain a bit identical copy of the whole wave file.

Protocol

TAK can save information about the compression process in the protocol file "Tak_Enco_Proto.txt", which will be created in the output directory.

Level

What should be stored into the protocol file:

Append

Append new protocol data to an existing protocol file, instead of overwriting it.

Use MMX

Uses MMX-assembler instead of pure Pascal on the most time consuming functions. Increases speed performance.

This option affects the Decoder too! It should really be in a new General Options dialog...

Decompressing files with the GUI version

File management

Decompression creates files with the same name as the source and the extension '.wav':

    Sample.tak -> Sample.wav

By default existing files will not be overwritten.

Quick tour

Warnings and errors

If there are any problems with a file you will see a short message following the file name:

Message Description
Invalid Stream-ID The Stream-ID (indicating that this is a TAK file) at the beginning of the file is damaged, but everything else is intact.
Stream info damaged The stream info meta data is damaged, but everything else is intact.
Meta data damaged One or more of the meta data structures are damaged, but the audio data is intact.
Stream structure damaged The stream part containing the audio data had errors, but the audio data itself is intact.
Frame(s) damaged At least one audio data frame is damaged.
Undecodable Too many errors. The file cannot be decoded (it possibly isn't a TAK-file). Occasionally it is worth trying again, with the Restore wave file meta data-option disabled.
Audio format not supported The file has been created with a newer encoder, which is able to handle more audio formats than the decoder you are using.
Incompatible version The file has been created with a newer encoder, which uses compression methods not supported by the decoder you are using.
Error reading source A source I/O error occurred.
Error writing destination A destination I/O error occurred.
Already exists The destination file already exists and you have not specified the Overwrite option.

Options

The Options dialog gives you access to a few decoder options.

Decoder options

Destination

Where should the decompressed files be stored:

!!! Overwrite existing wave files !!!

Enable this option to overwrite already existing wave files; otherwise they will be skipped. You will not be asked for a confirmation!

Restore wave file meta data

Enable this option to write the non-audio meta data of the original wave file into the decompressed file.

This only works if the compressed file has been created with the encoder option "Save wave file meta data" enabled, and the meta data was not larger than 1 MByte.

Error handling

How should errors caused by damaged files be handled?

Important: You will often have to disable the "Restore wave file meta data" option to decode a damaged file!

Files

Select Skip, if you don't want to decompress damaged files. If you select Recover TAK will attempt to recover as much of the audio data as possible.

Frames

Specify what should be done if the decompressor finds a damaged block of audio data within the file:

Save error log

If enabled, an error log is saved to the file "Tak_Deco_Error.txt".

Protocol

TAK can save information about the decompression process in the protocol file "Tak_Deco_Proto.txt", which will be created in the output directory.

Level

What should be stored into the protocol file:

Decompressor error log file

This section describes the content of the Decompressor error log file "Tak_Deco_Error.txt".

An entry is created for each damaged file:

--- 41_30sec.tak ---

Result: Frame(s) damaged

Header frames:       241
Valid  frames:       238
Skipped blocks:        3
Skipped end:           0

Skipped data blocks

No       Source pos  Size        Sample pos  Count
       1     1069674       30665      429936        5512
       2     2014491       34040      804752        5512
       3     2567479       27182     1014208        5512

It contains:

Skipped data blocks contains a list of the defective data blocks:

Because the current decoder implementation has been designed for speed its analysis and correctional capabilities are limited. It will not always be able to report the correct sample count of a damaged block. If the decoder encounters a damaged block within the compressed file it cannot know, without deeper analysis, if this block contains only 1 or more audio frames.

Viewing file info with the GUI version

This command will show you some useful information about compressed TAK files, which can optionally be written to a protocol file. Operation is nearly identical to decompressing files.

Example output for one file:

=== 41_30sec.tak ==============================================

  File size:                     3.25 MB
  Header size:                   0.26 KB
  Compression:                  64.36 %
  Samples per channel:        1323001
  File duration:                30.00 sec
  Frame duration:                  94 ms
  Seek point interval:            937 ms
  Audio format:            PCM, 44100 Hz, 16 Bits, 2 Channels
  Encoder:                 V 1.0.1, Turbo + Standard
  Wave file meta data:     Header 46, Footer 0 Bytes
  APEv2-Tag:               Yes / 6 Items / 0.18 KB
  Status:                  Ok

Items:

Options

The Options dialog lets you choose the information to show:

If you check the Save protocol option, any output will be saved to a protocol file named "Tak_Info_Proto.txt" located in the source file directory.

Command line version TAKC

Helpscreen

TAKC -mode [-p# -wm# -v -overwrite -fim# -l# -w] infile [outfile]

-mode      -e encode, -d decode, -t test decode, -te test encode,
           -fi file information
-p#        select encoder preset #
             T/F/N/H/E or 0-4 for Turbo/Fast/Normal(default)/High/Extra
             Append E/M (-p2m) to increase the evaluation level to Extra/Max.
-wm#       1/0 to enable(default)/disable saving(encode)/restoring(decode) of
           non-audio wave file meta data
-v         verify encoded frames (when encoding)
-overwrite overwrite existing output files (without confirmation!)
-fim#      select file information mode #
             0 = any information (default)
             1 = encoder
             2 = wave meta data
-l#        select log file level #
             0 = no log file (default)
             1 = log results
             2 = log results and diagnostics
             Append A (-l1a) to append new results to an existing file.
-w         wait for enter key when finished
infile     specify file or directory (Dir\*) to be processed
outfile    specify output file or directory (Dir\*)

-mode

What should the program do:

-p#

Select an encoder preset. Default is NORMAL. Append "e" or "m" to increase the evaluation level to extra or max. For more information, please read the description for the GUI version.

-wm#

Specify 1/0 to enable(default)/disable saving(encode)/restoring(decode) of non-audio wave file meta data. Please read the description of the GUI version for the options Save wave file meta data and Restore wave file meta data.

-v

Enables Verify: Any compressed frame is subsequently decompressed and then compared to the original data. This reduces encoding speed, but is useful for the more paranoid among us!

-overwrite

By default already existing output files will not be overwritten. Specify this option to enable overwriting. You will not be asked for a confirmation!

-fim#

Select the file information to show.

-l#

Specify the log (protocol) file level. Please read the description of the GUI version for more details.

infile

Depending on the selected mode the program automatically appends the proper extension to the file spec: ".wav" when encoding, ".tak" when decoding.

Examples for encoding:

d:\VocComp_Data\Sample

Compress file "Sample.wav" in the directory "d:\VocComp_Data".

d:\VocComp_Data\*

Compress any file with the extension ".wav" in the directory "d:\VocComp_Data".

*

Compress any file with the extension ".wav" in the current directory.

outfile

The optional outfile specification works the same way as infile.

Not every in-/outfile spec combination is valid: if you are using wildcards for the infile, you cannot specify an individual filename as outfile.

Exit codes

The following exit codes may be returned:

0 = Success

No errors.

1 = Invalid parameter(s)

One or more of the command line parameters are invalid.

2 = Operation error

The requested operation failed. Currently nearly any failure is beeing reported as error including the detection of damaged audio data when decoding, even if the file could be partially decoded.

Only exception: If a file is beeing compressed and the wave meta data is too big to be copied into TAK's meta data, the resulting warning is not beeing reported as error.

Probably later program versions will differentiate warnings (code 2) and errors (code 3).

History

V1.0 / 7-01-23

Fixed:

Both bugs affected only the decoder, therefore there is no need to re-encode TAK files created with beta 2.

V1.0.1 / 7-04-14

Features:

Fixed: