Synth

synth plugin

16-voice polyphonic synthesizer with oscillator, filter, and ADSR envelope.

Source: examples/truce-example-synth/.

#What it demonstrates

  • Instrument plugin with MIDI input (stereo output, no audio input)
  • Sample-accurate MIDI event handling (NoteOn/NoteOff)
  • Per-voice ADSR envelope and one-pole low-pass filter
  • Enum parameter (EnumParam<Waveform>) with dropdown widget
  • Voice stealing (oldest-first) and tail mode
  • Section-based grid layout (FILTER, ENVELOPE)
  • f64 audio path via use truce::prelude64::*param.read() returns f64, &mut AudioBuffer is the defaulted alias for AudioBuffer<f64>, and the format wrapper widens host f32 → plugin f64 at the block boundary (voice phase accumulators want the precision headroom over long-running sessions).

#Parameters

Name Range Unit Description
Waveform Sine/Saw/Square/Triangle -- Oscillator shape
Volume -60 to 0 dB Master output level
Cutoff 20 to 20000 Hz Low-pass filter cutoff
Resonance 0 to 1 -- Filter resonance
Attack 0.001 to 5 s Envelope attack time
Decay 0.001 to 5 s Envelope decay time
Sustain 0 to 1 -- Envelope sustain level
Release 0.01 to 10 s Envelope release time

#Files

  • src/lib.rs — plugin logic, MIDI dispatch, GUI layout
  • src/voice.rsVoice, Envelope, OnePoleFilter

#Build and test

cargo build -p truce-example-synth
cargo test -p truce-example-synth
cargo run -p truce-example-synth --features standalone