The VHDR chunk describes the sound. It is required and comes before the
BODY chunk. The structure is called Voice8Header in the
specification.
Fields
Offsets are from the start of the chunk’s data. The chunk’s size is 20.
| Offset | Size | Type | Name | Description |
|---|---|---|---|---|
| 0 | 4 | u32 | oneShotHiSamples | the number of samples in the one-shot part of the highest octave |
| 4 | 4 | u32 | repeatHiSamples | the number of samples in the repeating part of the highest octave |
| 8 | 4 | u32 | samplesPerHiCycle | the average number of samples per cycle in the highest octave, or 0 if unknown |
| 12 | 2 | u16 | samplesPerSec | the sample rate in hertz |
| 14 | 1 | u8 | ctOctave | the number of octaves stored |
| 15 | 1 | u8 | sCompression | the compression of the whole BODY, below |
| 16 | 4 | Fixed | volume | playback volume from 0 to Unity |
Fixed is a signed 32-bit number with 16 fractional bits. Unity, the
maximum volume, is 0x00010000 (1.0).
Amiga audio hardware needs one-shot and repeat parts of even length, and some drivers
need samplesPerHiCycle to be a power of two. Neither is a rule of the file
format.
Compression
sCompression | Name | Meaning |
|---|---|---|
| 0 | sCmpNone | uncompressed signed 8-bit samples |
| 1 | sCmpFibDelta | Fibonacci-delta encoding |
| 2 | none | exponential-delta encoding: not in the specification, but read by FFmpeg |
The 1985 specification defines 0 and 1 and says other values may be defined later. Who introduced value 2 is not confirmed.
Example
The header of a one-shot sound of 8,000 samples at 8,363 Hz, in one octave, uncompressed and at full volume:
| Offset | Bytes | Field | Value |
|---|---|---|---|
| −8 | 56 48 44 52 | chunk ID | VHDR |
| −4 | 00 00 00 14 | chunk size | 20 |
| 0 | 00 00 1F 40 | oneShotHiSamples | 8,000 |
| 4 | 00 00 00 00 | repeatHiSamples | 0 |
| 8 | 00 00 00 00 | samplesPerHiCycle | unknown |
| 12 | 20 AB | samplesPerSec | 8,363 |
| 14 | 01 | ctOctave | 1 |
| 15 | 00 | sCompression | none |
| 16 | 00 01 00 00 | volume | 1.0 |