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; written by Wilhelm Noeker’s wavepak (1996), read by FFmpeg |
| 3 | none | ADPCM2: 2-bit adaptive codes; not in the specification; written by Lorence Lombardo’s 8svx_comp |
| 4 | none | ADPCM3: 3-bit adaptive codes; not in the specification; written by 8svx_comp |
The 1985 specification defines 0 and 1 and says other values may be defined later. Value 2
was introduced in 1996 by Wilhelm Noeker’s wavepak, which says it is unofficial; some players
treat every non-zero value as Fibonacci and so play such a file as noise. Lorence Lombardo’s
8svx_comp (2006 to 2010) adds 3 and 4.
What a valid header looks like
| Field | Rule | In real files |
|---|---|---|
oneShotHiSamples, repeatHiSamples | either may be 0, in every octave at once; the Amiga needs even numbers | 67 of 400 have a repeat part |
samplesPerHiCycle | 0 for unknown; repeatHiSamples ÷ it should be a whole number | 57 have 0; 52 break the whole-number rule, so their repeat part would click |
samplesPerSec | the rate; a program that plays an instrument ignores it | 740 to 37,286 Hz |
ctOctave | 1 or more; (2n − 1) × (one-shot + repeat) samples must be in the body | 390 have 1, 2 have 2, 1 has 3, 6 have 5, 1 has 7; 26 files have a body that does not match the header |
sCompression | 0 or 1 in the specification; 2 is wavepak’s exponential-delta | 399 are 0, one is 1, none is 2 |
volume | 0 to Unity, 0x00010000 | all 400 are Unity |
The chunk’s size is 20. FFmpeg also accepts a header of 14 bytes (it reads only as far as the sampling rate) or 16 bytes (to the compression). The viewer reads the fields that fit in a short header, shows the rest as missing and flags the size. An all-zero header, or a missing one, leaves the body to be shown as one waveform at a default 8,000 Hz.
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 |
Source: Steve Hayes and Jerry Morrison, Electronic Arts, 8SVX IFF 8-Bit Sampled Voice (7 February 1985; AmigaOS Documentation Wiki copy), section Required Property VHDR (the Voice8Header structure, Fixed, Unity 0x10000, sCmpNone and sCmpFibDelta) and Appendix A. The field table was compared with the structure by script. Compression value 2 is not in that text; it comes from the documentation and source of Wilhelm Noeker’s wavepak 1.3 (Aminet mus/misc/wavepak), and FFmpeg’s 8svx.c reads it too. The counts of real files are from the survey this page states.