ADL field reference
File page · Format catalogue · Schema source
This page is generated from the Kaitai schema ADL.ksy each time the site is built. The schema is the authoritative description; statements are established unless marked inferred or unknown, and the evidence is listed on the file page (see the reading guide).
- Schema: Eye of the Beholder II DOS AdLib sound file (ADL)
- Byte order: little-endian
- File extension:
adl - Schema license:
MIT
Description
Music and sound effects for the AdLib sound driver (driver 1). The game loads one file at a time: the sound file named by the current level, or INTRO and FINALE1/FINALE2 for the introduction and the ending.
The first 120 bytes are the sound-effect table, which the game keeps for itself; the rest of the file is copied to the driver unchanged. It starts with two tables of 250 pointers each, to programs and to instruments. A program is a command stream for one of the ten driver channels; a sound is started by queueing a program number. Instrument data is last. All pointers count from byte 120, the end of the sound-effect table; 0 means that the entry is absent.
In the original files the program data starts right after the pointer tables, at pointer value 1000 (byte 1120), and the last instrument ends on the last byte of the file. The driver accepts at most 15,120 bytes after the sound-effect table. See the format overview.
File structure
| Field | Type | Size, repetition and constraints |
|---|---|---|
sound_effect_table | u1 | repeated 120 times |
program_offsets | u2 | repeated 250 times |
instrument_offsets | u2 | repeated 250 times |
sound_effect_table
Program number to start for each game sound number 0-119; 255 means that the sound plays nothing. Game sound n reads entry n. See the sound-effect table.
program_offsets
Offset of each program from byte 120 of the file; 0 when the program is absent. Several numbers may share one program. In the original files the numbers used run from 0 without gaps, up to between 10 (FINALE2.ADL) and 210 (AZURE.ADL).
instrument_offsets
Offset of each instrument from byte 120 of the file; 0 when the instrument is absent. Every instrument selected by a program of the original files is present.
Derived values and positioned data:
| Field | Type | Size, repetition and constraints |
|---|---|---|
programs | program_slot(_index) | repeated 250 times |
instruments | instrument_slot(_index) | repeated 250 times |
programs
The 250 program entries, in number order.
instruments
The 250 instrument entries, in number order.
Type program_slot
Parameters: index (u1)
Derived values and positioned data:
| Field | Type | Size, repetition and constraints |
|---|---|---|
offset | computed: _root.program_offsets[index] | — |
body | program | only if offset != 0; at position 120 + offset; in stream _root._io |
body
The program, absent when the offset is 0.
Type instrument_slot
Parameters: index (u1)
Derived values and positioned data:
| Field | Type | Size, repetition and constraints |
|---|---|---|
offset | computed: _root.instrument_offsets[index] | — |
body | instrument | only if offset != 0; at position 120 + offset; in stream _root._io |
body
The instrument, absent when the offset is 0.
Type program
A command stream for one channel. When a program is started, it replaces the program running on its channel only if its priority is at least that of the running one; the channel is then reset and runs its first commands on the next driver tick.
Commands run until one sets a non-zero duration; the channel then waits that many steps before running the next ones. A channel takes a step each time its tempo, added to an 8-bit counter on every driver tick (about 72.8 per second), carries past 255.
This schema reads commands in sequence up to the first stop, jump or return. In the original files every program ends with a stop and contains no jump, call or return; repeat loops jump backwards inside the program.
| Field | Type | Size, repetition and constraints |
|---|---|---|
channel | u1 | — |
priority | u1 | — |
commands | command | repeated until _.is_end |
channel
Channel 0-9. Channels 0-8 are the nine AdLib voices; channel 9 has no voice. In the original files, channel-9 programs start the other channels of a tune, fade them out or silence them.
priority
Priority against the program already running on the channel. In the original files 0-55; tunes are started by a channel-9 program of priority 4.
Type command
A note (first byte 0x00-0x7f) or a command (0x80-0xc9). Bytes 0xca-0xff are not valid commands: 0xf1-0xff stop the channel, and the driver does not handle 0xca-0xf0; no original file contains one.
| Field | Type | Size, repetition and constraints |
|---|---|---|
code | u1 | — |
args | switch on code: 128 → op_byte, 129 → op_rel_jump, 130 → op_byte, 131 → op_byte, 132 → op_rel_jump, 133 → op_call, 135 → op_byte, 137 → op_byte, 138 → op_byte_pair, 139 → op_byte_pair, 140 → op_byte, 141 → op_secondary_effect, 142 → op_byte, 144 → op_byte, 145 → op_slide, 147 → op_byte, 149 → op_vibrato, 154 → op_byte, 156 → op_byte, 157 → op_byte, 158 → op_byte, 160 → op_byte, 161 → op_byte, 164 → op_byte, 166 → op_byte, 169 → op_byte, 171 → op_byte, 172 → op_byte_pair, 173 → op_byte_pair, 174 → op_byte, 175 → op_byte, 176 → op_byte, 179 → op_byte, 181 → op_word_be, 185 → op_byte, 188 → op_byte, 189 → op_byte, 191 → op_byte_pair, 193 → op_rhythm_setup, 194 → op_byte, 196 → op_byte_pair, 197 → op_byte_pair, 198 → op_byte_pair, 199 → op_byte, 200 → op_byte, 201 → op_byte_pair, _ → op_note_or_none(code < 0x80) | — |
code
For a note: low 4 bits the note within the octave, 0-11, added to the channel's base note; bits 4-6 the octave, added to the channel's base octave. For a command: the opcode.
args
Operands; their number depends on the opcode. A note is followed by its duration. See the opcode enum for each command.
Derived values and positioned data:
| Field | Type | Size, repetition and constraints |
|---|---|---|
opcode | computed: code | only if code >= 0x80; values: opcode |
is_end | computed: code == 0x84 or code == 0x86 or code == 0x88 or code == 0x8f or code == 0x94 or (code >= 0x96 and code <= 0x99) or code == 0x9b or code == 0x9f or code == 0xa2 or code == 0xa3 or code == 0xa5 or code == 0xa8 or code == 0xaa or code == 0xb1 or code == 0xb2 or code == 0xb4 or code == 0xb7 or code == 0xb8 or code == 0xbe or code >= 0xca | — |
opcode
The command, for codes 0x80 and above.
is_end
True for a stop, an unconditional jump or a return.
Type op_note_or_none
Parameters: is_note (bool)
| Field | Type | Size, repetition and constraints |
|---|---|---|
duration | u1 | only if is_note |
duration
Note duration in channel steps; 0 runs the next command at once. A note takes a third byte, a velocity that adjusts the operator levels, while the channel's velocity shifts set by 0xc9, or the last velocity read, are non-zero; no original file uses 0xc9, so every note of these files is two bytes.
Type op_byte
| Field | Type | Size, repetition and constraints |
|---|---|---|
value | u1 | — |
Type op_byte_pair
| Field | Type | Size, repetition and constraints |
|---|---|---|
first | u1 | — |
second | u1 | — |
Type op_word_be
| Field | Type | Size, repetition and constraints |
|---|---|---|
value | u2be | — |
Type op_rel_jump
| Field | Type | Size, repetition and constraints |
|---|---|---|
displacement | s2 | — |
displacement
Signed distance from the byte after this command.
Type op_call
| Field | Type | Size, repetition and constraints |
|---|---|---|
target | u2 | — |
target
Absolute address in the driver's memory: the file byte at 120 + target - 710. Not used in the original files.
Type op_secondary_effect
| Field | Type | Size, repetition and constraints |
|---|---|---|
rate | u1 | — |
last_index | u1 | — |
register | u1 | — |
table | u2 | — |
rate
Added to an 8-bit counter every tick; each carry advances the effect by one value.
last_index
The values used are entries last_index - 1 down to 0 of the table, then last_index, and so on.
register
AdLib register written, added to the channel's first operator offset (32 is the register of tremolo, vibrato, envelope type and frequency multiplier).
table
Absolute address of the value table in the driver's memory, like the call target: the file byte at 120 + table - 710. In the original files (rate 47, last_index 3, register 32) it points into the bytes of a program, which serve as the values.
Type op_slide
| Field | Type | Size, repetition and constraints |
|---|---|---|
rate | u1 | — |
step | s2be | — |
rate
Added to an 8-bit counter every tick; each carry applies one step.
step
Signed change of the 10-bit frequency number per step, high byte first. Above 733 (rising) the number is halved and the octave raised; at 388 or below (falling) it is doubled and the octave lowered.
Type op_vibrato
| Field | Type | Size, repetition and constraints |
|---|---|---|
rate | u1 | — |
depth | u1 | — |
half_period | u1 | — |
delay | u1 | — |
rate
Added to an 8-bit counter every tick; each carry moves the frequency by one step.
depth
The step is the note's 10-bit frequency number shifted right by 9 - depth; above 9 the step is 0 and nothing moves.
half_period
The direction reverses after half_period + 1 steps, then every 2 * half_period steps.
delay
Ticks after each note before the vibrato starts.
Type op_rhythm_setup
| Field | Type | Size, repetition and constraints |
|---|---|---|
instruments | u1 | repeated 3 times |
frequencies | u1 | repeated 6 times |
instruments
Instruments for channels 6, 7 and 8.
frequencies
For channels 6, 7 and 8 in turn, the block and frequency-high byte (masked with 0x2f) and the frequency-low byte.
Type instrument
Eleven AdLib register values, written to the channel's two operators (operator 1, operator 2) when a program selects the instrument.
| Field | Type | Size, repetition and constraints |
|---|---|---|
op1_characteristic | u1 | — |
op2_characteristic | u1 | — |
feedback_connection | u1 | — |
op1_waveform | u1 | — |
op2_waveform | u1 | — |
op1_level | u1 | — |
op2_level | u1 | — |
op1_attack_decay | u1 | — |
op2_attack_decay | u1 | — |
op1_sustain_release | u1 | — |
op2_sustain_release | u1 | — |
op1_characteristic
Register 0x20 of operator 1 (tremolo, vibrato, sustain, scaling, multiplier).
op2_characteristic
Register 0x20 of operator 2.
feedback_connection
Register 0xc0 of the channel (feedback, connection in bit 0).
op1_waveform
Register 0xe0 of operator 1.
op2_waveform
Register 0xe0 of operator 2.
op1_level
Register 0x40 of operator 1 (key scale level, output level). The driver adds the channel's level offsets to the output level when operator 1 is audible (connection bit 1).
op2_level
Register 0x40 of operator 2. The driver adds the channel's level offsets to the output level.
op1_attack_decay
Register 0x60 of operator 1.
op2_attack_decay
Register 0x60 of operator 2.
op1_sustain_release
Register 0x80 of operator 1.
op2_sustain_release
Register 0x80 of operator 2.
Enumerations
Enumeration opcode
| Value | Name | Meaning |
|---|---|---|
128 | set_repeat | Set the repeat counter (1 byte). |
129 | repeat_jump | Decrement the repeat counter; while it is not 0, jump by the signed displacement. |
130 | start_program | Start a program now, with the same priority rule as a queued one; 255 starts nothing. |
131 | set_note_spacing | Remaining steps of a note at which it is released. |
132 | jump | Jump by the signed displacement. |
133 | call | Call commands at an absolute driver address; not used. |
134 | return_from_call | Return from a call; not used. |
135 | set_base_octave | Octave added to every note. |
136 | stop | Stop the channel and release its note. Every original program ends with it. |
137 | rest | Wait the given number of steps. |
138 | write_register | Write an AdLib register (register, value). |
139 | note_with_duration | Play a note (note byte, duration). |
140 | set_base_note | Semitones added to every note. |
141 | secondary_effect | Start the channel's second effect, which writes values from a table into one AdLib register of the channel. |
142 | stop_channel | Stop another channel. |
143 | stop_8f | Same as stop. |
144 | set_instrument | Load an instrument into the channel. |
145 | slide | Start a frequency slide; replaces a vibrato. |
146 | end_primary_effect | End the slide or vibrato. |
147 | set_base_frequency | Value added to every note frequency. |
148 | stop_94 | Same as stop. |
149 | vibrato | Start a vibrato; replaces a slide. |
150 | stop_96 | Same as stop. |
151 | stop_97 | Same as stop. |
152 | stop_98 | Same as stop. |
153 | stop_99 | Same as stop. |
154 | set_priority | Change the channel's priority. |
155 | stop_9b | Same as stop. |
156 | set_beat | Start the shared beat counter: it counts one beat every (operand / 2) carries of a counter that adds the global tempo every tick (256 carries when operand / 2 is 0). Not used by the original files. |
157 | wait_for_beat | Wait, one step at a time, until the bits of the beat counter selected by the operand change from all clear to not all clear; if they are set when the wait begins, it first waits for them to clear. Not used by the original files. |
158 | set_level_offset | Level offset of the channel, added to its output levels. |
159 | stop_9f | Same as stop. |
160 | wait | Wait the given number of steps without a new note. |
161 | note_on_with_duration | Wait the given number of steps after the note-on routine; not used. |
162 | stop_a2 | Same as stop. |
163 | stop_a3 | Same as stop. |
164 | set_fractional_spacing | Release notes when their remaining steps equal this many eighths of their duration, 0-7; not used. |
165 | stop_a5 | Same as stop. |
166 | set_global_tempo | Tempo followed by every channel that has tempo reset set. |
167 | end_secondary_effect | End the second effect. |
168 | stop_a8 | Same as stop. |
169 | set_channel_tempo | Tempo of this channel. |
170 | stop_aa | Same as stop. |
171 | set_level_offset_3 | Third level offset of the channel. Most sound effects start with this command, and the game rewrites its operand for a sound played from a block; see a sound at a distance. |
172 | set_channel_level_offset | Set the level offset of another channel (channel, value). |
173 | change_channel_level_offset | Add to the level offset of another channel (channel, value). |
174 | set_tremolo_depth | AdLib deep-tremolo bit (0 or 1). |
175 | set_vibrato_depth | AdLib deep-vibrato bit (0 or 1). |
176 | change_level_offset | Add to the channel's level offset. |
177 | stop_b1 | Same as stop. |
178 | stop_b2 | Same as stop. |
179 | clear_channel | Stop a channel and silence its voice. |
180 | stop_b4 | Same as stop. |
181 | random_frequency | Add a random amount, masked by the word (high byte first), to the note's block and frequency number; only the sound registers change, not the stored frequency. The random sequence restarts at the same value every time the driver starts and is shared by all channels; see how a note sounds. In the original files only programs 3-6 of INTRO.ADL use it, with the mask 0x03ff. |
182 | end_primary_effect_b6 | Same as 0x92. |
183 | stop_b7 | Same as stop. |
184 | stop_b8 | Same as stop. |
185 | pitch_bend | Signed pitch bend applied to later notes. |
186 | reset_to_global_tempo | Set the channel tempo to the global tempo. |
187 | nop | Nothing. |
188 | set_duration_randomness | Mask of a random amount added to every later duration; while it is non-zero, the note-off fraction set by 0xa4 is not applied. In the original files only programs 165 and 198 of AZURE.ADL (values 4 and 3) and 146 and 159 of CATACOMB.ADL (values 2 to 6) use it. |
189 | change_channel_tempo | Add a signed amount to the channel tempo, kept within 1-255. |
190 | stop_be | Same as stop. |
191 | command_bf | Start switching channel 0's note on and off from the system timer. The first operand enables it when non-zero; the second selects a pair of driver tables (rate and frequency); with a first operand of 2, channel 0 at once takes the first rate and frequency of the pair. Not used by the original files. |
192 | command_c0 | Stops the switching started by 0xbf; not used. |
193 | rhythm_setup | Prepare the percussion voices on channels 6-8. |
194 | rhythm_play | Strike percussion instruments (bit mask). |
195 | rhythm_off | Leave percussion mode. |
196 | rhythm_set_level | Operands: instrument mask, value. Each percussion level is the sum of three bytes, added in one byte and kept within 0-63; this command sets the third byte of every instrument in the mask and writes the new level. Mask bits: 0 hi-hat, 1 cymbal, 2 tom-tom, 3 snare drum, 4 bass drum, the order of the percussion bits of AdLib register 0xbd. Not used by the original files. |
197 | rhythm_change_level | Operands: instrument mask, value. Adds the value to the level of each instrument in the mask, keeps it within 0-63, writes it and stores it as the second of the three bytes. Not used by the original files. |
198 | rhythm_set_level_2 | Operands: instrument mask, value. Sets the second of the three bytes of each instrument in the mask and writes the new level. Not used by the original files. |
199 | set_music_marker | Set the music marker that the introduction and the ending wait for. Used only in INTRO.ADL (markers 0-8) and FINALE1.ADL (0-5). |
200 | set_tempo_reset | When non-zero, the channel follows the global tempo on every tick. |
201 | set_velocity_shifts | Velocity shifts for operators 1 and 2; non-zero values add a velocity byte to each note. Not used. |