Skip to main content

Module midi

Module midi 

Source
Expand description

MIDI music: Standard MIDI Files with Apogee’s EMIDI extensions, played with the FM voices in crate::fm and Blood’s AdLib timbre bank (GMTIMBRE.TMB in SOUNDS.RFF). Used for a level’s Song= (BLOOD.INI) when no CD audio track was ripped.

EMIDI controllers handled (as publicly documented for Apogee’s sound system):

  • 110 / 111 at the start of a track: include / exclude the track for a device (OpenBlood plays the FM variants, devices FM_DEVICES, or “all” = 127);
  • 112 / 113: device-specific program change and volume;
  • 116 / 117: song loop start / end; 118 / 119: track loop start / end.

Without loop markers a song restarts from the beginning when every track has ended.

Structs§

ChannelState 🔒
Player
Renders a song to 16-bit stereo, looping forever.
Playing 🔒
Song
Track
TrackPos 🔒

Enums§

Msg

Constants§

BANK_SIZE
Melodic timbres 0-127, then one percussion timbre per key (128 + key).
BLOCK 🔒
Events are applied between blocks of this many samples (about 1.5 ms at 44.1 kHz).
EMIDI_ALL 🔒
FM_DEVICES
EMIDI device numbers treated as “this player”: Sound Blaster and AdLib (both OPL FM).
MAX_VOICES 🔒
Voices sounding at once (the OPL3 has 18 two-operator channels).
MIX_GAIN 🔒
Output gain applied to the sum of all voices.
PERCUSSION_CHANNEL 🔒

Functions§

parse_bank
Reads the 256 timbres of an AdLib timbre bank (.TMB).
read_varlen 🔒
stream
Streams a song as interleaved 16-bit stereo 44.1 kHz chunks (half a second each) from a background thread, in the same form as crate::cdaudio::stream_wav. The thread exits when the receiver is dropped.
track_plays_on_fm
EMIDI track designation: whether a track plays on an FM device. Tracks without designation controllers always play.