# Rumpl
Sample-free General MIDI player and renderer. Every voice is generated
algorithmically — no SoundFont, no sample library, no FluidSynth.
Expect a chiptune / analog-synth aesthetic.
## Install
```sh
cargo install rumpl
```
Or from a local checkout:
```sh
cargo install --path .
```
## Usage
```sh
rumpl play file.mid # real-time playback
rumpl render file.mid # render to file.wav alongside the input
rumpl render file.mid out.wav # offline render to 44.1 kHz / 16-bit stereo WAV
```
Flags:
- `--gain <f32>` — master gain (default `0.8`)
- `--sample-rate <u32>` — render sample rate (default `44100`)
- `--tail <f32>` — render seconds of release tail after last note-off (default `3.0`)
## Library
`rumpl` can also be used as a library.
Disable the default features to skip the CLI dependencies:
```toml
rumpl = { version = "0.2", default-features = false, features = ["play"] }
```
```rust
use std::path::Path;
let seq = rumpl::midi::load(Path::new("song.mid"))?;
rumpl::output::play::play(seq, 0.8, 3.0)?; // gain, tail seconds; blocks until done
```
To render to a file instead:
`rumpl::output::render::render_to_wav(&seq, Path::new("song.wav"), 44_100, 0.8, 3.0)?`.
`play` needs the `play` feature, which uses `cpal`
(on Linux this requires the ALSA headers, e.g. `libasound2-dev`).
`render_to_wav` is always available.
See [docs.rs/rumpl](https://docs.rs/rumpl) for the API.
## How it works
- `midly` parses the SMF; events are merged across tracks and stamped with
absolute sample indices via the tempo map.
- A 64-voice synth maps each MIDI program to a static `Patch` (oscillator stack,
ADSR, filter, LFO). Channel 10 uses a separate per-key drum patch table.
Acoustic instruments are physical models instead: plucked strings
(Karplus-Strong: guitars, basses, harp, sitar, …), struck strings (pianos),
struck bars, tubes and membranes (mallets, bells, timpani, drums), bowed
strings and wind instruments (self-oscillating digital waveguides driven by
a bow, a reed, the lips or an air jet).
- Every channel feeds a shared stereo room reverb (8-line feedback delay
network, RT60 ≈ 1.9 s). The send level is MIDI CC91 (default 40, as in
GM2/GS); a file can set CC91 to 0 for a dry channel.
- Output goes to `cpal` for `play` or `hound` for `render`.