Skip to main content

Module synth

Module synth 

Source
Expand description

Synth — voice allocator + ADSR + oscillator voices → audio. Re-exports only (AU-MIDI-SYNTH).

Polyphonic subtractive-lite synth: a fixed-capacity VoiceAllocator of OscillatorVoices (waveform × AdsrEnvelope × velocity), summed by render_block. The render path is zero-alloc, lock-free, and FS-free — all voice state is inline in a [Voice; N] array. Frequencies are supplied directly so a tuning table can drive pitch; VoiceAllocator::note_on_12tet is the equal-temperament default.

Structs§

AdsrEnvelope
A four-stage attack/decay/sustain/release amplitude envelope.
OscillatorVoice
A single monophonic voice: oscillator + envelope + velocity gain.
Voice
A pool voice: the sound generator plus allocator bookkeeping.
VoiceAllocator
Fixed pool of N voices. All state is inline; no allocation on any path.

Enums§

Waveform
Selectable oscillator waveform.

Constants§

MAX_VOICES
Default maximum simultaneous voices for a full-size pool.

Functions§

render_block
Render one audio block by summing every active voice into out (mono, one sample per element). Each element is fully mixed before advancing to the next, so voice phase/envelope stay sample-accurate. Returns Ok(()); reserved AudioError variants allow future validation without changing the signature.