The wvpl list holds the samples of the collection as wave
lists. A wave list is an embedded wave file: the data of a normal RIFF WAVE file with the
first twelve bytes (RIFF, a size, WAVE) replaced by a
LIST header (LIST, a size, wave), and with an
optional dlid chunk first. Regions reach a wave through the
pool table. Sections 2.12 and 2.16
of Downloadable Sounds Level 2.2 and the Level 1 wave file appendix.
The wave list
<wave-list> → LIST( 'wave' // lower case
[<dlid-ck>]
<fmt-ck>
[<wsmp-ck>] [<fact-ck>] [<cue-ck>] [<playlist-ck>] [<assoc-data-list>]
[<INFO-list>]
<data-ck> )
Programs must expect and ignore unknown chunks. The fmt chunk must come
before the data chunk, and both are mandatory. The specification says DLS
does not require fact, cue , plst or the
associated data list, and that they are “intentionally left out”; see
Other chunks in a wave. A raw WAV file starts RIFF
size WAVE; a DLS wave starts LIST size
wave, and case matters.
fmt: the format chunk
| Offset | Size | Type | Name | Description |
|---|---|---|---|---|
| 0 | 2 | u16 | wFormatTag | 1 for WAVE_FORMAT_PCM; 0xFFFE for WAVE_FORMAT_EXTENSIBLE (Level 2.2). The MMA keeps a registry of format tags |
| 2 | 2 | u16 | wChannels | the number of channels; Level 1 supports only mono (1) |
| 4 | 4 | u32 | dwSamplesPerSec | the sample rate in samples a second |
| 8 | 4 | u32 | dwAvgBytesPerSec | the average number of bytes a second |
| 12 | 2 | u16 | wBlockAlign | the block alignment in bytes |
| 14 | 2 | u16 | wBitsPerSample | the bits used for each sample of each channel; 0 if not needed. Mobile DLS supports only 8 or 16 bits |
With wFormatTag 0xFFFE the chunk goes on:
| Offset | Size | Type | Name | Description |
|---|---|---|---|---|
| 16 | 2 | u16 | cbSize | the size in bytes of the extra information after this field; at least 22 |
| 18 | 2 | u16 | wValidBitsPerSample / wSamplesPerBlock / wReserved | a union: how many bits are used per sample (the data is then aligned left, the extra bits being the least significant), or the samples in one compressed block (0 if variable), or 0 |
| 20 | 4 | u32 | dwChannelMask | which channels are present in the stream |
| 24 | 16 | GUID | SubFormat | the GUID of the encoded data; the MMA keeps a registry of supported GUIDs |
Level 1 and Level 2 allow only WAVE_FORMAT_PCM, 8 or 16-bit, mono (section 3.2).
Level 2.2 adds other codecs through WAVE_FORMAT_EXTENSIBLE. The MMA’s
registry of SubFormat GUIDs is not public. The explorer reads a GUID of the form
<format code>-0000-0010-8000-00AA00389B71 as the Microsoft format
code, which is how the WAV
format chunk page describes it.
The explorer names the format of every wave and draws and plays waves that are 8 to 32-bit integer PCM, 32 or 64-bit IEEE float, A-law, µ-law, IMA ADPCM or Microsoft ADPCM, mono or with more channels, by format tag or by SubFormat. The two ADPCM codings are the block forms of WAV files: the WAV sample data page describes them, and the output matches FFmpeg’s sample for sample. It also plays GSM 6.10, MPEG audio (layers 1 to 3), G.726, G.722, G.723.1, G.729, TrueSpeech, iLBC and the OKI, Yamaha and Creative ADPCMs, through the decoders it shares with the WAV viewer; the format codes are those of the WAV format codes page. MPEG audio, G.726, G.722 and Yamaha ADPCM were checked against FFmpeg. A wave in any other format is named and its bytes shown.
data: the samples
The data chunk holds the waveform data in the format the fmt
chunk describes. For PCM, a single channel’s samples are stored one after another and
several channels are interleaved, channel 0 being left. Only channel 0 is supported for
Level 1 and 2. The two PCM forms of Level 1 and 2:
| Sample size | Data format | Maximum | Midpoint | Minimum |
|---|---|---|---|---|
| 8 bit | unsigned | 255 (0xFF) | 128 (0x80) | 0 |
| 16 bit | signed, little-endian | 32767 (0x7FFF) | 0 | −32768 (0x8000) |
To change 8-bit offset data to signed, XOR each byte with 0x80 (section 1.5.1).
The explorer’s waveform and Play read exactly these values, and a click on the
waveform selects the bytes of that sample frame in the hex view.
wsmp: the wave sample
The wsmp chunk holds the low-level parameters for playing a sample. It
normally sits in the wave list, and can also sit in a region to override the loop points
and other parameters (the rules
say which one wins). It is the same in Level 1 and Level 2 apart from the loop type.
| Offset | Size | Type | Name | Description |
|---|---|---|---|---|
| 0 | 4 | u32 | cbSize | the size of this structure in bytes, not counting the loop records (20); it says where the loops start |
| 4 | 2 | u16 | usUnityNote | the MIDI note that replays the sample at its original pitch, 0 to 127; 60 is middle C |
| 6 | 2 | i16 | sFineTune | the tuning offset from the unity note, “in 16 bit relative pitch”: in cents in practice. The specification gives no scale for the 16-bit form, but the values in Apple’s GS bank run from −100 to 80 and libInstPatch reads the field as cents like a SoundFont fine tune |
| 8 | 4 | i32 | lGain | the gain applied to the sample in 32-bit relative gain units, 1/655360 dB; used to balance multi-sample splits (lAttenuation in Level 1) |
| 12 | 4 | u32 | fulOptions | flags: bit 0 F_WSMP_NO_TRUNCATION (0x0001), bit 1 F_WSMP_NO_COMPRESSION (0x0002) |
| 16 | 4 | u32 | cSampleLoops | the number of loop records: 0 for a one-shot sound, 1 for a looped sound; larger values are not defined |
cbSize | 16 × cSampleLoops | records | loops | the loop records |
F_WSMP_NO_TRUNCATION forbids the synthesis engine to reduce the bit depth
of the sample if it cannot synthesise at it; F_WSMP_NO_COMPRESSION forbids
it to compress the sample in its engine. With either set, the wave may need more memory
and fail to download.
A loop record
| Offset | Size | Type | Name | Description |
|---|---|---|---|---|
| 0 | 4 | u32 | cbSize | the size of the record in bytes (16) |
| 4 | 4 | u32 | ulLoopType | WLOOP_TYPE_FORWARD 0 (forward loop); WLOOP_TYPE_RELEASE 1 (loop and release, Level 2) |
| 8 | 4 | u32 | ulLoopStart | the first sample of the loop, counted from the start of the data of the wave’s data chunk |
| 12 | 4 | u32 | ulLoopLength | the length of the loop in samples |
A forward loop plays from the start, returns to the loop start when it reaches the end of the loop, and goes on until the release of the envelope ends. A loop and release plays the same way, but at note-off it does not return to the loop start: it plays on from wherever it is to the end of the sample, never jumping to the release segment. Loop points have no fractional part.
Other chunks in a wave
The grammar lets a wave list carry fact, cue ,
plst and an associated data list (LIST adtl), the standard RIFF
WAVE chunks; the explorer reads them as the
WAV pages describe
them (cue ,
plst, labl, note, ltxt,
file). Wave editors that write DLS files also leave the sampler chunk
smpl and
the instrument chunk inst in the waves; the explorer reads these too. The
DLS specifications define none of them, and a DLS reader ignores them.