Expand description
MIDI — Standard MIDI File (SMF) parser + transport metadata + soft-synth.
smf— pure-Rust parser for the Standard MIDI File format (Type 0 / 1 / 2). Header (MThd) + tracks (MTrk) + every common channel-voice message, sysex (F0/F7), and meta event (tempo, time signature, key signature, text, marker, end-of-track, SMPTE offset, sequencer-specific). Running status is honoured; VLQs are bounded to 4 bytes per spec; chunk lengths are validated against remaining bytes; total events per file are capped atsmf::MAX_EVENTS_PER_FILE.paths— per-OS SoundFont/SFZ/DLS search paths plus theOXIDEAV_SOUNDFONT_PATHenvironment override.find_soundfontswalks them and returns every instrument-bank file present.instruments—instruments::Instrumenttrait. Three adapters:instruments::sf2— full SoundFont 2 RIFF reader + voice generator. Walks thesfbkform, cross-resolves the preset → instrument → zone → sample chain, and renders sm24-aware 24-bit PCM at the requested pitch via linear interpolation. Honours the volume + modulation DAHDSR envelopes, the initial low-pass biquad filter, mod-env → pitch / filter routing, exclusive-class drum cuts, and native stereo zones.instruments::sfz— text patch reader plus voice generator. Strips comments, walks<control>/<global>/<master>/<group>/<region>sections, flattens inheritance into one fully-resolved opcode map per region, and (viaSfzInstrument::open) reads every referenced sample off disk. Voice generation decodes the WAV sample bytes, picks the matching region by (key, velocity), shifts pitch offpitch_keycenter+tune+transpose, and runs a DAHDSR amplitude envelope (ampeg_*) + vibrato LFO (lfo01_*).instruments::dls— DLS (Downloadable Sounds) Level 1 + Level 2 RIFF reader plus voice generator. Walks theDLSform, parses thecolh/vers/ptblpool table /lins-listinstrument table /wvpl-listwave pool, and surfaces a fully-cross-resolvedDlsBankof instruments → regions → wave-pool samples with theirwsmploops,wlnkcue references, andart1/art2articulation connection blocks.make_voiceresolves the wlnk → ptbl → wave-pool entry, decodes the PCM, and plays the sample throughSamplePlayer.art1/art2connection-block evaluation is round 2.instruments::sample_voice— shared sample-playback voice (mono in, mono out) used by both SFZ and DLS. Covers DAHDSR amplitude envelope, four loop modes, pitch bend, and a vibrato LFO.instruments::wav_pcm— minimal RIFF/WAVE PCM decoder used by the SFZ and DLS sample loaders.instruments::tone— sine/triangle/saw/square fallback so the synth produces something even when no on-disk bank is present.
mixer— polyphonic voice pool (32 voices) with stereo mixdown, per-channel volume / pan / sustain pedal handling, and oldest-voice preemption when the pool is full. Round 75 adds the full RPN 1 / RPN 2 / RPN 5 control surface (channel fine + coarse tune + modulation-depth range), CC 1 (mod wheel) → per-voice depth, CC 74 (MPE “third dimension”) → per-voice timbre, theMpeZone/MpeRoletopology built from MCM messages, and universal-SysEx-driven master volume / master fine / master coarse tuning that sum with per-channel tuning into the effective pitch each voice receives.scheduler— SMF event scheduler. Merges every track into a single time-ordered stream, converts ticks → samples against the current tempo + division, and dispatches each event into the mixer at the right audio sample. Round 75 wires the Universal Real-Time / Non-Real-Time SysEx routing: GM 1 / GM 2 / GM Off reset, CA-25 Master Fine / Master Coarse Tuning, Master Volume, plus the CC 1 / CC 74 / MPE-MCM channel-CC paths.downloader— stub that names a planned default bank (TimGM6mb) but currently returnsError::Unsupported.
The decoder factory ([make_decoder]) is registered under codec id
CODEC_ID_STR = "midi". Round-3 wires SMF events end-to-end:
send_packet parses the SMF and primes the scheduler; receive_frame
pulls one chunk of stereo PCM (FRAME_SAMPLES samples per channel
at OUTPUT_SAMPLE_RATE) until both the event stream and the voice
pool have run dry, then returns Error::Eof.
Without an instrument bank the decoder uses
instruments::tone::ToneInstrument — the pure-tone fallback —
so a .mid file plays back as audible-but-not-musical sine /
triangle / square waves. To use a real bank, build the decoder by
hand and pass an Sf2Instrument
to MidiDecoder::with_instrument; the decoder factory wired into
the registry today does not yet plumb a bank-discovery hook.
Modules§
- downloader
- Default-SoundFont downloader.
- instruments
- External-instrument trait + per-format adapters + pure-tone fallback.
- mixer
- Polyphonic voice pool + mixdown into a stereo PCM buffer.
- paths
- Cross-platform search paths for soft-synth instrument banks.
- scheduler
- SMF event scheduler — converts a parsed
SmfFileinto an absolute-tick, time-ordered event stream and walks it sample-by-sample against the audio output rate. - smf
- Standard MIDI File (SMF) parser.
- tuning
- MIDI Tuning Standard (MTS) — microtuning state + Universal SysEx data-format decoders.
Structs§
- Midi
Decoder - Soft-synth decoder: SMF in, interleaved S16 stereo PCM out.
Enums§
- Instrument
Source - Source descriptor for an external instrument bank. Paired with
MidiDecoder::with_instrument_sourceso a caller that only knows “I have an SF2 file at this path” doesn’t have to type the fullArc::new(Sf2Instrument::open(...))chain.
Constants§
- CODEC_
ID_ STR - Public codec id string. Matches the aggregator feature name
midi. - FRAME_
SAMPLES - Number of per-channel samples emitted per
Decoder::receive_framecall. ~23 ms at 44.1 kHz — small enough for low playback latency, big enough that the per-call overhead is dwarfed by the inner mix loop. - OUTPUT_
CHANNELS - Channel count of the PCM output bus. Stereo. Same fixed assumption
as
OUTPUT_SAMPLE_RATE. - OUTPUT_
SAMPLE_ RATE - Round-3 audio output sample rate. Hard-coded to 44 100 Hz so the
decoder doesn’t need a parameter from the caller (the SMF container
itself doesn’t carry one). Round-4 may wire this through
CodecParameters::sample_rate.
Functions§
- register_
codecs - Register the MIDI codec. Round-3 produces interleaved S16 stereo
PCM at
OUTPUT_SAMPLE_RATE— the registry-built decoder uses the pure-tone fallback because we don’t yet have a bank-discovery hook in the factory signature. Callers who want SoundFont 2 playback should build the decoder by hand viaMidiDecoder::with_instrument.