A DLS file is one RIFF form of type DLS (with a trailing space). Its chunks
and lists can come in any order, and a reader must skip the ones it does not know. This
page gives the grammar the specifications define, the objects it describes and the
rules for reading and writing it. Every statement here is from the MMA documents
Downloadable Sounds Level 2.2 (version 1.0, April 2006, sections 2.1 to 2.3,
2.17, 2.18 and chapter 3) and Downloadable Sounds Level 1 (version 1.1b,
file format chapter).
The RIFF form
DLS instruments are stored in a RIFF form of type DLS . Its subchunks are
cdl , vers, dlid, colh and
ptbl chunks and LIST chunks. There are three top-level lists:
lins, the instrument list, which holds the ins lists;
wvpl, the wave pool, which holds the wave lists; and an
optional INFO list with information about the collection.
| Offset | Size | Type | Name | Description |
|---|---|---|---|---|
| 0 | 4 | char[4] | ckID | RIFF |
| 4 | 4 | u32 | ckSize | the number of bytes after this field: the form type and every chunk |
| 8 | 4 | char[4] | form type | DLS |
| 12 | … | chunks | the chunks and lists of the collection |
The explorer reports a size that reaches past the end of the file (the file has been cut short) and bytes after the end of the form, and shows both.
LIST chunks
A LIST chunk holds a list, an ordered sequence, of subchunks:
LIST( <list-type> [<chunk>]... ). The list type is a
four-character code that says what the list holds. A program that does not know a list
type can still walk through its subchunks. As with chunk IDs, list types must be
registered, and an all-lower-case list type has a meaning relative to the form that
holds it.
| Offset | Size | Type | Name | Description |
|---|---|---|---|---|
| 0 | 4 | char[4] | ckID | LIST |
| 4 | 4 | u32 | ckSize | the bytes after this field: the list type and the chunks |
| 8 | 4 | char[4] | list type | one of the types below |
| 12 | … | chunks | the list’s chunks |
All numbers are little-endian. As in every RIFF file, a chunk whose size is odd is followed by one pad byte that the size does not count; the RIFF chunks page of the WAV section describes it.
| List type | Holds | Level |
|---|---|---|
lins | the instruments: ins lists | 1 |
ins | one instrument: dlid, insh, lrgn, lart, lar2, INFO | 1 |
lrgn | the regions of an instrument: rgn and rgn2 lists | 1 |
rgn | a Level 1 region | 1 |
rgn2 | a Level 2 region | 2 |
lart | Level 1 articulators: art1 chunks | 1 |
lar2 | Level 2 articulators: art2 chunks | 2 |
wvpl | the wave pool: wave lists | 1 |
wave | one wave, like a WAV file with a LIST header in place of RIFF | 1 |
INFO | text about the collection, an instrument, a region or a wave | 1 |
The grammar
Table 7 of the Level 2.2 document gives this RIFF grammar (square brackets mean the chunk is optional). The same grammar is in the Level 1 document, without the parts marked Level 2 below.
<DLS-form> → RIFF( 'DLS '
[<cdl-ck>] // Level 2
[<vers-ck>]
[<dlid-ck>]
<colh-ck>
<lins-list>
<ptbl-ck>
<wvpl-list>
[<INFO-list>] )
<wvpl-list> → LIST( 'wvpl' <wave-list>... )
<wave-list> → LIST( 'wave' [<dlid-ck>] <fmt-ck> <data-ck> [<wsmp-ck>] [<INFO-list>] )
<lins-list> → LIST( 'lins' <ins-list>... )
<ins-list> → LIST( 'ins ' [<dlid-ck>] <insh-ck> <lrgn-list>
[<lart-list>] [<lar2-list>] [<INFO-list>] ) // lar2: Level 2
<lrgn-list> → LIST( 'lrgn' <rgn-list> | <rgn2-list>... ) // rgn2: Level 2
<rgn-list> → LIST( 'rgn ' [<cdl-ck>] <rgnh-ck> <wsmp-ck> [<wlnk-ck>]
[<lart-list>] [<lar2-list>] [<INFO-list>] ) // Level 1 region
<rgn2-list> → LIST( 'rgn2' [<cdl-ck>] <rgnh-ck> <wsmp-ck> [<wlnk-ck>]
[<lar2-list>] [<INFO-list>] ) // Level 2 region
<lart-list> → LIST( 'lart' [<cdl-ck>] <art1-ck>... )
<lar2-list> → LIST( 'lar2' [<cdl-ck>] <art2-ck>... )
<INFO-list> → LIST( 'INFO' <info_text-ck>... )
The Level 2.2 grammar lists wsmp as required and wlnk as
optional in a region; the Level 1 grammar has wsmp optional and
wlnk required. The explorer holds a file to neither: a region with no
wsmp uses the one in its wave (see the rules below), and a region with no
wlnk shows “none” in the Regions table. It does report a missing
colh, lins, ptbl or wvpl in the
form, a missing insh or lrgn in an instrument, a missing
rgnh in a region and a missing fmt or data in a
wave, and a fmt chunk that comes after the data chunk (the
specification says it must come first).
The Level 2.2 document adds that it is safe for Level 1 devices to meet a
cdl chunk in an lart list, a rgn list or an
lrgn list, because a Level 1 device ignores chunks it does not support
(section 2.6.1); see Conditional chunks.
The object hierarchy
Section 2.17 of the Level 2.2 document shows how the objects of a DLS instrument correspond to chunks.
| Object | Chunks |
|---|---|
| Instrument | ins list: insh instrument header, INFO list |
| Global articulation | lart and lar2 lists of the instrument, holding art1 and art2 chunks (connection blocks) |
| Region (1 to n) | lrgn list holding rgn and rgn2 lists |
| Wave link | wlnk chunk of the region |
| Wave sample | wsmp chunk of the region, optionally overriding the wave’s |
| Wave file | wave list in the wave pool: fmt , data and optionally wsmp |
| Region articulation | lart and lar2 lists of the region |
In Level 1 a melodic instrument has up to 16 regions and one set of global articulation data, and a drum instrument up to 128 regions, each with its own articulation and no global one. Level 2 has no such limits.
Rules for readers and writers
Chapter 3 of the Level 2.2 document (and the coding requirements of Level 1):
- A parser must ignore and skip chunks it does not know; manufacturers embed proprietary chunks this way.
- The order of the chunks in a list must not be assumed:
rgnh,wsmp,wlnkand the articulator lists may come in any order. - If a region has no
wsmp, the one in its wave is used; if the region has one, it is used instead of the wave’s. If neither has one, the defaults are a one-shot sound with unity note 60 (middle C), no attenuation and no fine tune. - Connections that the device architecture implies must not be written to the file. For Level 2 these are MIDI Note to Key, RPN2 to Key, MIDI controller 7 to Gain, MIDI controller 11 to Gain, MIDI controller 10 to Pan, EG1 to Attenuation and Pitch Wheel RPN0 to Pitch. Level 1 lists EG1 to Attenuation, Velocity to Attenuation, Pitch Wheel/RPN0 to Pitch, Key Number to Pitch, MIDI controller to Attenuation, MIDI controller 10 to Pan, MIDI controller 11 to Attenuation, RPN1 to Pitch and RPN2 to Pitch. The explorer’s Articulation table flags them.
- To tell a drum instrument from a melodic one, check bit 31 of
ulBankin the instrument header: 1 is a drum instrument. The specification says the distinction will cease to exist in a future revision. - The chunks and lists written inside one list may come in any order, but a
dlidchunk is best placed first in its list, and acdlchunk first in the list it guards, so a reader can decide early.
What belongs to which level
The file does not say which level it is written for. These features tell a reader what it needs:
| Feature | Needs |
|---|---|
vers, dlid, colh, lins, ins , rgn , lart, art1, wvpl, wave, ptbl, INFO | Level 1 |
cdl , rgn2, lar2, art2, the usLayer field of rgnh, the loop and release loop type, the channel and phase fields of wlnk beyond the left channel | Level 2 |
a fmt chunk with format tag 0xFFFE (WAVE_FORMAT_EXTENSIBLE), a wave that is not 8 or 16-bit PCM | Level 2.2 |
The Level 2.2 summary of changes says the RIFF structure did not change: parsers written before Level 2.2 can read Level 2.2 files. Level 1 devices accept only mono 8 or 16-bit PCM waves, key groups 0 to 15, regions that do not overlap in key range, and velocity ranges of 0 to 127.