soundlab
A Rust library for building synthesizers: envelopes, voices, and polyphony.
Components
| Component | Description |
|---|---|
Envelope |
Trait for envelope generators. LinearAdsr included, more to come. |
Voice |
Combines an oscillator and envelope into a playable voice with MIDI support. |
Polyphony |
Manages multiple voices for chords with configurable voice stealing. |
Usage
Envelope
use ;
let mut env = new;
env.gate_on; // Note pressed
for _ in 0..44100
env.gate_off; // Note released
Presets for common sounds:
let pad = pad; // Slow attack, long release
let pluck = pluck; // Instant attack, no sustain
let perc = percussion; // Instant attack, fast decay
Voice
A voice combines an oscillator with an amplitude envelope:
use Voice;
use LinearAdsr;
use ;
let osc = new;
let env = pad;
let mut voice = new;
// MIDI note on (C4, velocity 0.8)
voice.note_on;
for _ in 0..44100
voice.note_off;
Polyphony
Manage multiple voices for playing chords:
use ;
use Voice;
use LinearAdsr;
use ;
// Create 8-voice polyphony
let mut poly = from_factory;
// Play a chord
poly.note_on; // C4
poly.note_on; // E4
poly.note_on; // G4
for _ in 0..44100
// Release
poly.note_off;
poly.note_off;
poly.note_off;
With nih-plug
License
MIT License - see LICENSE for details.