This is the reference implementation for reading and writing ton data. Ton is a simple data format for working with digital audio- its layout is as follows.
The first 20 bytes of ton data are a header, the layout of which is as follows:
The first four bytes are an identifier, consisting of the ASCII characters "TONF".
The next 8 bytes represent an IEEE 754 double precision float, stored in big endian. This holds the sample rate, and should be a positive number.
The final 8 bytes represent a unsigned interger, stored in big endian. This holds the number of channels.
The remainder of the data are IEEE 754 single precision floats, each representing a sample, stored sequentially in big endian. Samples are stored in an interleaved format. For example, if channel indicies are represented as numbers and sample indicies are represented as letter (in English alphabetical order), the indicies of 4 channel data are:
0a, 1a, 2a, 3a, 0b, 1b, 2b, 3b,...
but not:
0a, 0b,... 1a, 1b,... 2a, 2b,... 3a, 3b...
In addition this crate provides a pair of utilities for converting to and from wav files- ton2wav and wav2ton respectively.