A DLS file only makes sense for a playback device that behaves as the specification says: the numbers in the file are the controls of a defined synthesiser. This page summarises that device, from chapter 1 of Downloadable Sounds Level 2.2 (the Level 1 document describes the smaller device of Level 1). The explorer reads and shows the file, and plays a note of each instrument with a simplified version of the device. The device is “a purely symbolic system that can be mapped onto many different designs”, not a recipe for one.
The device
The Level 1 voice has a sampled sound source with loop points, two 4-segment envelope generators (attack, decay, sustain, release), one LFO and a standard response to MIDI controllers. The Level 2 voice has a sampled source with loop and release, two 6-segment envelope generators (delay, attack, hold, decay, sustain, release), two LFOs, a low-pass filter with resonance and dynamic cutoff, and the same controllers. It has three parts: the control logic (choosing the instrument, region and articulation for a note), the digital audio engine (oscillator, filter, amplifier) and the articulation modules and their connections.
Minimum for a Level 2 device (section 1.3): 32 oscillators, each with its own filter, two LFOs and two envelope generators; a sample playback rate of at least 22.05 kHz; 1,048,576 16-bit words of sample memory; 512 waves, 256 instruments, 1,024 regions and 8,192 explicit connections (the defaults not counted) stored at once; if the device also supports General MIDI it must support both together. Level 1 asks for 256K words of sample memory (240K available), 128 instruments, 128 sets of articulation data, 128 regions and 128 samples, 24 voices and 22.05 kHz.
Control logic
The device selects the instrument on a channel by MIDI bank select and program change (the bank), and plays notes on note-on and note-off. A region chosen by key and velocity names a sample indirectly, with a preset gain and tuning. Layers are overlapping regions, one oscillator each, so polyphony counts oscillators and not notes.
Voice allocation
By default the device uses static MIDI channel priority: channel 10 first, then channels 1 to 9 and 11 to 16 in order. A new note first takes a free oscillator; otherwise it steals one from a lower-priority channel (channel 16 before 15 and so on), and never from a higher one, even a note in its release. The implementer may add rules inside a channel. The DLS system exclusive messages below turn the priority off and on.
Note exclusivity
A note-on shuts down the oscillators already playing the same note on the same channel
(the volume envelope goes to release at once, using EG1_SHUTDOWNTIME
instead of EG1_RELEASETIME), unless the region has the non-self-exclusive
option. The second kind, for drums and sound effects, shuts down the oscillators of
regions in the same key group on any channel.
Phase-locked samples
A Level 2 device must support phase-locked two-channel samples, which keep sample lock to within half a sample at the output rate (wave links).
Digital oscillator
It plays 8-bit (offset binary) or 16-bit PCM, interpolating from the recorded rate to the output rate with the pitch of the articulation, and supports one loop given by a start sample and a length, with no fractional part. A forward loop returns to the loop start at the loop end until the release ends; a loop and release plays straight on to the end of the sample after note-off. Its pitch can be shifted up two octaves and down four, the sum of every tuning including the sample’s fine tune and pitch bend. The sample structure gives the note, fine tune and rate that the oscillator needs to pitch the sample.
Digital filter
The Level 2 filter is a two-pole low-pass filter with a 12 dB/octave slope:
H(z) = K / (1 + b1·z−1 + b2·z−2) with
b1 = −2r·cos θ, b2 = r² and K = g(1 + b1 + b2), a
complex pole pair at radius r and angle θ. The gain factor g keeps the perceived loudness
constant as the resonance rises: g = 10−resonance/40, that is
gdB = −resonance/2; a 20 dB resonance gives −10 dB. It may be
applied after the filter with the other gains. The resonance is a 32-bit gain value
(dB/655360) for the ratio of the gain at DC to the gain at the top of the peak; 0 is no
peak, a negative value is illegal, the default is 0. The cutoff is a 32-bit absolute
pitch. It is where the DC gain line meets the asymptote of −12 dB/octave drawn through the
point one octave below the Nyquist frequency, a definition less sensitive to the peak than
the −3 dB point. With the sample rate Fs:
h(−12 dB) = A·f^−2 A = Fs² · h_filter(Fs/4) / 16
Fc = (Fs/4) · sqrt(1 − 2r·cosθ + r²) / fourthroot(1 + 2r²·cos(2θ) + r⁴)
θ = arccos( ( −Fs⁴(r²+1) + 16·Fc²·sqrt( 2·Fs⁴(r⁴+1) − 256·Fc⁴(r²−1)² ) ) / ( 2r(256·Fc⁴ − Fs⁴) ) )
resonance = 20·log10( (1 − 2r·cosθ + r²) / ((1 − r²)·sinθ) ) in dB
r = ( cosθ + sinθ·sqrt(10^(resonance/10) − 1) ) / ( 10^(resonance/20)·sinθ + 1 )
The equations measure an implementation against the file: they do not require this
topology or this trajectory of the pole radius and angle, and “more musical” filters are
allowed. The maximum cutoff value 0x7FFFFFFF asks for no low-pass filter.
Cutoffs are required from Fs/240 to Fs/6; higher ones may be
supported, with no disturbing artefacts when the cutoff sweeps beyond Fs/6,
and above the Nyquist frequency the passband is flat whatever the resonance. A filter
must take at least 16 discrete resonance values from 0 to 22.5 dB (1.5 dB steps, error up
to 1.5 dB), keep the height of the resonant peak within 3 dB per octave of cutoff sweep
(specified at 1 kHz, within 1.5 dB), have DC gain within ±0.75 dB and other gain within
±1.5 dB of the ideal, a cutoff within one semitone, at least 2,048 cutoff steps an octave
with no step wider than 0.01 semitone, and THD+N of at most 0.005% of full scale.
Digital amplifier
It scales the filter’s output. Its maximum output is 0 dB (unity), all its changes are in dB of amplitude from that point, and a sound designer who exceeds 0 dB is clipped to 0 dB. The pan signal is split into left and right gains. It needs a resolution of 1 dB (±0.25 dB) from unity down to −85 dB, and smoothing: its controls feed an internal ramp generator of at least 0.0025 dB resolution so that there is no zipper noise.
LFOs and envelopes
LFO. A sine or triangle wave; the frequency is set from 0.1 Hz to 20 Hz in absolute pitch, the start delay from 10 ms to 10 s in time cents. A delayed LFO must make no artefacts; if the device cannot align the phase to the end of the delay it should ramp the output up over one cycle. Frequency accuracy is 1% (averaged over 100 cycles) with jitter of at most 10 ms, delays ±10 ms. In Level 2 there are the modulator LFO and the vibrato LFO.
Envelope. Six segments. The output is zero in the delay phase, rises linearly
to full scale in the attack phase (zero attack time goes to peak at once, so transients
of the sample are kept), holds at full scale for the hold time, falls exponentially to
the sustain level in the decay phase, stays at it until note-off, and then falls
exponentially in the release phase to the zero level (usually −96 dB). Decay and release
times are the time to fall from full scale to −96 dB. For the volume envelope applied to
gain the attack is linear in amplitude; applied to anything else every segment is linear
in the destination’s units (pitch cents, for example). The sustain level is in 0.1% steps
of the envelope peak, in the destination’s units through lScale. Velocity
lengthens or shortens the attack and note number the decay (and hold):
Attack_time(tc) = Nominal_attack(tc) + (Velocity / 128) × Attack_scalar(tc)
Decay_time(tc) = Nominal_decay(tc) + (Note_number / 128) × Decay_scalar(tc)
The scalars are the lScale values of the velocity to attack and key to decay
connections. The shutdown time acts like the release time but only when a note exclusive
or key exclusive event shuts the oscillator down. Envelope accuracy: 0.5 dB, timing ±10 ms.
Key number generator. It changes region selection. Its single input is
DST_KEYNUMBER and its single output SRC_KEYNUMBER. By default
the MIDI note number and RPN 2 go to its input, and its output goes to pitch; the
connection to pitch may be local or global, but inputs to the generator are valid only
at the global level of an instrument, and should not appear in a Level 1 or Level 2 file
except in a proprietary conditional chunk.
MIDI controllers
- Note number sets the playback frequency, one equal-tempered semitone a key; an
lScaleof 0 on the note number to pitch connection stops the pitch following the keyboard, other values retune (quarter tones). - Volume (controller 7), expression (11) and velocity go to
DST_GAINthrough the concave transform. The velocity connection is −96 dB by default, which matches a typical General MIDI curve, or 0 dB for no response to velocity (organs, harpsichords). - Pan (controller 10) goes to
DST_PAN, in percent from −50% to 50%, limited to that range after all inputs are summed. The channel gains are20·log10(cos(π/2 × (DST_PAN + 50%)))for left and20·log10(sin(π/2 × (DST_PAN + 50%)))for right. The default controller 10 connection is 50.8% because a 7-bit controller cannot reach full right otherwise: 64 is the centre, 0 and 1 silence the right channel, 127 the left. Level 1 used different equations with the same equal-power result; Level 1 devices may keep them. - Modulation (controller 1) and channel pressure set the depth of an LFO for pitch, volume or filter cutoff, each with its own level.
- Pitch bend goes to the pitch sum scaled by RPN 0. Sustain (64) goes to the control logic, which holds notes.
- Controllers 91 and 93 go by default to the reverb and chorus sends, in percent of amplitude and not dB.
- RPN 0, pitch bend range, up to at least ±12 semitones. RPN 1, fine tuning, in 1/8192 semitone steps from −8192/8192 to +8191/8192, resolution at least 1 cent, accuracy ±½ cent. RPN 2, coarse tuning, in semitones, changes the note number before the articulation, region and sample are chosen, so multisampled instruments do not change timbre; it goes through the key number generator. Data entry MSB and LSB (controllers 6 and 38) are required; increment and decrement (96, 97) are not. The way to set an RPN is controller 101 (MSB), 100 (LSB), 6 and 38, then 101 and 100 set to 127 to select no parameter.
Channel mode messages, defaults and system exclusive
Reset All Controllers (controller 121) with data 0 resets all controllers to their defaults except volume (7) and pan (10); with data 127 it resets everything, RPNs included, to the power-on values. All Notes Off (123) turns off the notes of the channel, but a held sustain pedal keeps them sounding until released. All Sound Off (120) silences the channel as fast as possible (envelopes may be ramped to avoid clicks): a panic message. Omni off, omni on, mono on and poly on (124 to 127) need not be supported and should then act as All Notes Off. Active Sensing (0xFE) is required: when messages stop for the timeout, all voices are turned off as by All Sound Off.
Power-on defaults (and the values after Reset All Controllers with 127 and after a DLS On message): volume 100, pan 64, pitch bend 0, expression 127, modulation 0, sustain 0, reverb send (91) 40, chorus send (93) 0, channel pressure 0, RPN 0 pitch bend range 2, RPN 1 fine tuning 0, RPN 2 coarse tuning 0, RPN LSB (100) and MSB (101) 127.
DLS system exclusive messages, all Universal Non-Real Time with the device ID (7F addresses every device), sub-ID 1 = 0A (DLS) and sub-ID 2 as listed:
| Message | Bytes |
|---|---|
| DLS On | F0 7E <device ID> 0A 01 F7 |
| DLS Off | F0 7E <device ID> 0A 02 F7 |
| Static voice allocation off | F0 7E <device ID> 0A 03 F7 |
| Static voice allocation on | F0 7E <device ID> 0A 04 F7 |
The allocation messages have no effect on a device that is not in DLS mode. Programs that change the voice allocation must return it to the default on exit.
The instrument the explorer plays
The Instruments tab has a Show button for each instrument. It plays one note: the key at
the unity note of the first region (or the middle of its range), velocity 100, held for
1.5 s and released, 2 s in all, at 44,100 Hz. Every region that answers the key and the
velocity is a voice. The pitch is (key − unity note) × 100 + fine tune + tuning cents
plus the pitch connections of the envelope and the two LFOs; the volume is the sample’s
gain, the volume envelope, and the velocity, controller 7 (100) and controller 11 (127)
through scale × (5/12) × log10(127 / input); the pan is the equal-power pair of section
1.8.5. The envelopes use the connection values and the velocity and key scaling above, and a
region’s articulation replaces the instrument’s as a whole. Not played: pitch bend,
modulation and channel pressure (all 0), key groups, note exclusivity, the sends, phase locks
and multichannel steering; the filter is a plain two-pole low-pass at the cutoff and
resonance of the file.
Checked against Apple’s own DLS synthesiser (AVAudioUnitSampler, run offline on the same
gs_instruments.dls): for nine instruments (piano, electric piano, guitar, violin,
strings, trumpet, flute, square wave and a pad) the pitch is the same and the level in each
tenth of a second of the held note agrees to within 0.2 dB (the guitar and the square wave
differ by up to 3.4 dB in a tenth that holds the release, and by 15 dB in one where a 5 ms
release falls to silence).
Mod LFO to gain
The Level 1 text left the connection ambiguous. Most Level 1 devices made it bipolar and
not inverted; Level 2.0 asked for unipolar and inverted; Level 2.1 and 2.2 follow the
Level 1 devices, so with a positive lScale the signal grows in the first
phase of the LFO.