Audio is held in the sampleblocks table of the
database, one row per block
of one channel. A waveblock
in the project document refers to a row by blockid. Blocks hold no time
information; their position comes from the document.
Columns
| Column | Meaning |
|---|---|
blockid | The block’s number. New blocks are numbered by SQLite’s AUTOINCREMENT. |
sampleformat | The format of samples; see below |
summin | Smallest sample in the whole block |
summax | Largest sample in the whole block |
sumrms | RMS level of the whole block: sqrt(totalSquares / sampleCount) |
summary256 | A summary of the samples in groups of 256 |
summary64k | A summary in groups of 65,536 |
samples | The raw samples |
samples holds the block’s samples, in the host’s byte order, so
little-endian on the platforms Audacity ships for. Its length divided by the sample size
gives the number of samples in the block.
Sample formats
sampleformat stores Audacity’s sampleFormat value. The value’s
top 16 bits are the sample size in bytes (SAMPLE_SIZE).
| Value (hex) | Value (decimal) | Name | Sample size | Meaning |
|---|---|---|---|---|
0x00020001 | 131,073 | int16Sample | 2 | 16-bit integers |
0x00040001 | 262,145 | int24Sample | 4 | 24-bit integers, in 4 bytes |
0x0004000F | 262,159 | floatSample | 4 | 32-bit floating point |
0 | 0 | undefinedSample | 0 | Undefined |
Summaries
Each summary is a run of frames. A frame is three 32-bit floats, 12 bytes: minimum, maximum, then RMS, in the host’s byte order.
frames64k = (sampleCount + 65535) / 65536, rounded down.frames256 = frames64k × 256.summary256isframes256 × 12bytes, andsummary64kisframes64k × 12bytes.
summary256 covers the samples 256 at a time, and summary64k
combines each 256 entries of it. A block is shorter than the summary’s size, so the
last frames of summary256 are padding: minimum FLT_MAX,
maximum -FLT_MAX and RMS 0, values that do not affect the results. The last
frame in use can also cover fewer than 256 samples. The summaries are computed from the
samples as floats, even when the samples are stored as integers.
Block sizes
By default a block may hold at most 1,048,576 bytes of samples. With that limit:
- The minimum block size, in samples, is 1,048,576 ÷ sample size ÷ 2.
- The maximum block size is twice the minimum.
Editing can leave a block shorter than the minimum, which is allowed. A block longer than the maximum fails the consistency check.
Silent blocks
Silence takes no room. A block’s blockid of zero or less means a silent
block of that many samples: the value is the negative of the length, and no row of
sampleblocks exists. Silent blocks read as zero samples and zero summaries.