Expand description
Two-operator FM voices in the style of the Yamaha OPL2/OPL3 chips, used to play Blood’s MIDI music with its AdLib timbre bank when no CD audio was ripped.
Written from the chips’ publicly documented behaviour, not from any emulator’s code and not cycle-exact: each operator has a phase generator (frequency multiplier, vibrato), an envelope (attack / decay / sustain / release rates in the OPL’s 4-step-per-octave rate scale, key-scale rate), total level and key-scale level attenuation, tremolo and one of eight OPL3 waveforms. The modulator can feed back into itself and either phase-modulates the carrier (FM) or is mixed with it (additive).
Structs§
- Operator 🔒
- Timbre
- One instrument from a 13-byte timbre record: the register values an AdLib driver writes to registers 0x20, 0x40, 0x60, 0x80 and 0xE0 for the modulator and carrier, register 0xC0 (feedback and connection), a transpose and a velocity sensitivity.
- Voice
- One sounding note: a modulator and a carrier.
Enums§
- Stage 🔒
Constants§
- ATTACK_
RATE1 🔒 - Time for a full attack (silence to full level) at rate 1, in seconds.
- DECAY_
RATE1 🔒 - Time for a full decay or release (0 to -96 dB) at rate 1, in seconds.
- MULT 🔒
- Frequency multipliers for register values 0-15.
- SILENT_
DB 🔒 - Envelope floor: below this the operator is silent.
- TREMOLO_
DB 🔒 - TREMOLO_
HZ 🔒 - VIBRATO_
DEPTH 🔒 - Vibrato depth as a frequency ratio (about 7 cents).
- VIBRATO_
HZ 🔒
Functions§
- stage_
time 🔒 - Seconds a stage of rate
rate(0-15) takes, with the key-scale rate offsetrof(0-15). Rate 0 never advances; every four effective-rate steps halve the time. - wave 🔒
- Waveform
wat phasep(cycles, 0..1).