- Rust 100%
|
All checks were successful
Keep IntelliJ config in git but out of the published crate via Cargo.toml exclude. Update the gen_golden usage comment now that the crate is standalone (no workspace -p needed). |
||
|---|---|---|
| .forgejo/workflows | ||
| .idea | ||
| examples | ||
| src | ||
| .gitignore | ||
| Cargo.lock | ||
| Cargo.toml | ||
| deny.toml | ||
| LICENSE-APACHE | ||
| LICENSE-MIT | ||
| README.md | ||
sms-audio
Pure-Rust SoundMusicSys (SMS / Halestorm) song renderer.
Renders a Standard MIDI File against a bank of decoded Sound Manager samples to
mono PCM. The crate is engine-agnostic: it knows MIDI and sampled-instrument
synthesis — not resource forks or any specific game. Callers decode their
'SONG' / 'INST' / 'snd ' resources themselves and hand in an
[InstrumentBank] of ready-to-play samples.
#![forbid(unsafe_code)]- Single dependency:
thiserror - Synthesis follows the documented SoundMusicSys behaviour; original code, not
derived from any GPL source — cleanly licensable under
MIT OR Apache-2.0.
What it does
- Parses a Standard MIDI File and drives a sampled-instrument voice pool.
- Per-instrument sustain loops, one-shots, velocity/CC7 amplitude scaling (opt-in per instrument), and linear or nearest-neighbour interpolation (preserving the original non-interpolated aliasing when asked).
- SMS
'SONG'playback parameters are exposed on [RenderOpts] — post-note-off release ticks, voice-count-to-full-scale mapping, music voice cap, and releasing-voice stealing — all with engine-neutral defaults for callers that have no SONG record. - A [
diag] module and a [fingerprint] module for render diagnostics and audio-similarity checks.
Usage
use sms_audio::{Instrument, InstrumentBank, RenderOpts};
let mut bank = InstrumentBank::new();
bank.insert(0, my_instrument); // an Instrument you decoded from a 'snd ' resource
// `smf` is raw Standard MIDI File bytes.
let pcm = sms_audio::render(&smf, &bank, RenderOpts::default())?;
// pcm.samples: Vec<f32> in [-1.0, 1.0] at pcm.sample_rate (22254 Hz by default)
See examples/render_song.rs for a complete,
data-free example that builds a minimal SMF and a synthesized instrument
in code:
cargo run --example render_song
Provenance
Extracted from the dm2-tools Dungeon Master II toolchain, where it renders the game's Macintosh soundtrack. The per-crate commit history is preserved from that monorepo.
License
Licensed under either of Apache License, Version 2.0 or MIT license at your option.