pub struct Adsr { /* private fields */ }Expand description
ADSR Envelope Generator
A classic Attack-Decay-Sustain-Release envelope with gate and retrigger inputs. Outputs normal and inverted envelope signals, plus end-of-cycle trigger.
§Segment timing
The decay and release parameters denote the true duration of their
respective segments (peak→sustain and current-level→zero), not the time to
traverse the full 0..1 span. Per-sample rates are therefore scaled by the
span actually traversed: decay_rate = (1 - sustain) / (decay_time · fs) and
release_rate = release_start_level / (release_time · fs), where
release_start_level is captured at the instant the gate falls.
§Curve shape
The shape input selects the segment curve: 0V (default) gives classic
linear ramps; a high level (> GATE_THRESHOLD_V, e.g. 5V) selects an
exponential one-pole approach toward each stage’s target (attack→1, decay→
sustain, release→0) using env_coef with the stage time as the time
constant.
§Retrigger semantics
A retrigger (or a fresh gate) restarts the contour at the Attack stage but continues from the current level — it does not reset the level to zero. Retriggering during Sustain therefore ramps back up from the sustain level rather than restarting from silence.
Implementations§
Trait Implementations§
Source§impl GraphModule for Adsr
impl GraphModule for Adsr
Source§fn tick(&mut self, inputs: &PortValues, outputs: &mut PortValues)
fn tick(&mut self, inputs: &PortValues, outputs: &mut PortValues)
Source§fn set_sample_rate(&mut self, sample_rate: f64)
fn set_sample_rate(&mut self, sample_rate: f64)
Source§fn process_block(
&mut self,
inputs: &BlockPortValues,
outputs: &mut BlockPortValues,
frames: usize,
)
fn process_block( &mut self, inputs: &BlockPortValues, outputs: &mut BlockPortValues, frames: usize, )
Source§fn breaks_feedback_cycle(&self) -> bool
fn breaks_feedback_cycle(&self) -> bool
Source§fn serialize_state(&self) -> Option<Value>
fn serialize_state(&self) -> Option<Value>
alloc only.Source§fn deserialize_state(&mut self, _state: &Value) -> Result<(), String>
fn deserialize_state(&mut self, _state: &Value) -> Result<(), String>
alloc only.Source§fn introspect(&self) -> Option<&dyn ModuleIntrospection>
fn introspect(&self) -> Option<&dyn ModuleIntrospection>
alloc only.ModuleIntrospection view, if it exposes one. Read moreSource§fn introspect_mut(&mut self) -> Option<&mut dyn ModuleIntrospection>
fn introspect_mut(&mut self) -> Option<&mut dyn ModuleIntrospection>
alloc only.introspect, used to set internal parameters.Source§impl ModuleIntrospection for Adsr
Available on crate feature alloc only.
impl ModuleIntrospection for Adsr
alloc only.