Skip to main content

GraphModule

Trait GraphModule 

Source
pub trait GraphModule: Send + Sync {
Show 14 methods // Required methods fn port_spec(&self) -> &PortSpec; fn tick(&mut self, inputs: &PortValues, outputs: &mut PortValues); fn reset(&mut self); fn set_sample_rate(&mut self, sample_rate: f64); // Provided methods fn process_block( &mut self, inputs: &BlockPortValues, outputs: &mut BlockPortValues, frames: usize, ) { ... } fn breaks_feedback_cycle(&self) -> bool { ... } fn params(&self) -> &[ParamDef] { ... } fn get_param(&self, _id: ParamId) -> Option<f64> { ... } fn set_param(&mut self, _id: ParamId, _value: f64) { ... } fn type_id(&self) -> &'static str { ... } fn serialize_state(&self) -> Option<Value> { ... } fn deserialize_state(&mut self, _state: &Value) -> Result<(), String> { ... } fn introspect(&self) -> Option<&dyn ModuleIntrospection> { ... } fn introspect_mut(&mut self) -> Option<&mut dyn ModuleIntrospection> { ... }
}
Expand description

Type-erased module interface for graph-based patching

Required Methods§

Source

fn port_spec(&self) -> &PortSpec

Returns the module’s port specification

Source

fn tick(&mut self, inputs: &PortValues, outputs: &mut PortValues)

Process one sample given port values

Source

fn reset(&mut self)

Reset internal state

Source

fn set_sample_rate(&mut self, sample_rate: f64)

Set sample rate

Provided Methods§

Source

fn process_block( &mut self, inputs: &BlockPortValues, outputs: &mut BlockPortValues, frames: usize, )

Process a block of samples (optional optimization).

The default drives tick frame-by-frame. It reuses a single input and output PortValues across the whole block (via BlockPortValues::frame_into/set_frame_ref), so it does not allocate per frame — only once per call to warm the reused buffers.

For the graph engine, prefer Patch::tick_block, which is fully allocation-free after compile.

Source

fn breaks_feedback_cycle(&self) -> bool

Whether this module breaks a feedback cycle in the patch graph.

The graph normally rejects any cable cycle with PatchError::CycleDetected. A module that returns true (delay-style modules such as UnitDelay and DelayLine) is treated as a one-sample delay boundary: Patch::compile excludes the edges feeding into it from the topological sort, so a loop routed through it compiles. At runtime such a module reads its inputs from the previous tick’s output buffers, giving the classic single-sample feedback delay. Cycles that contain no cycle-breaker still fail to compile.

Source

fn params(&self) -> &[ParamDef]

Get parameter definitions for UI binding.

Most built-in modules do not use this API. Nearly all of them expose their controllable quantities as input ports (see port_spec) — e.g. a VCO’s frequency, an SVF’s cutoff, or an ADSR’s stage times are all input ports driven by cables or their default values — and leave this method at its empty default. The authoritative way to discover and drive parameters for GUIs is the ModuleIntrospection API (available with the alloc feature), not this trait-default no-op. It remains here only for the handful of modules whose parameters are genuinely not ports.

Source

fn get_param(&self, _id: ParamId) -> Option<f64>

Get a parameter value.

Defaults to None. See params: most modules surface their state through input ports and ModuleIntrospection, not through this method.

Source

fn set_param(&mut self, _id: ParamId, _value: f64)

Set a parameter value.

Defaults to a no-op. See params: most modules surface their state through input ports and ModuleIntrospection, not through this method.

Source

fn type_id(&self) -> &'static str

Get module type identifier for serialization

Source

fn serialize_state(&self) -> Option<Value>

Available on crate feature alloc only.

Serialize module state (alloc feature only)

Source

fn deserialize_state(&mut self, _state: &Value) -> Result<(), String>

Available on crate feature alloc only.

Deserialize module state (alloc feature only)

Source

fn introspect(&self) -> Option<&dyn ModuleIntrospection>

Available on crate feature alloc only.

Downcast this module to its ModuleIntrospection view, if it exposes one.

A Box<dyn GraphModule> (as stored inside a Patch) cannot otherwise reach the module’s ModuleIntrospection impl, so this hook bridges the two trait objects. It returns None by default; modules with genuine internal (non-port) parameters override it — typically via impl_introspect! — to return Some(self). Parameters that are input ports are discovered and driven through the port system instead (see Patch::param_infos), so most modules leave this at the default.

Gated on alloc because ModuleIntrospection (and its Vec/String payloads) live in the alloc tier; pure no_std builds never see this method.

Source

fn introspect_mut(&mut self) -> Option<&mut dyn ModuleIntrospection>

Available on crate feature alloc only.

Mutable companion to introspect, used to set internal parameters.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl GraphModule for Adsr

Source§

impl GraphModule for AnalogVco

Source§

impl GraphModule for Arpeggiator

Source§

impl GraphModule for Attenuverter

Source§

impl GraphModule for BernoulliGate

Source§

impl GraphModule for Bitcrusher

Source§

impl GraphModule for ChordMemory

Source§

impl GraphModule for Chorus

Source§

impl GraphModule for Clock

Source§

impl GraphModule for Comparator

Source§

impl GraphModule for Compressor

Source§

impl GraphModule for Crossfader

Source§

impl GraphModule for Crosstalk

Source§

impl GraphModule for DelayLine

Source§

impl GraphModule for DiodeLadderFilter

Source§

impl GraphModule for Distortion

Source§

impl GraphModule for Ducker

Source§

impl GraphModule for EnvelopeFollower

Source§

impl GraphModule for Euclidean

Source§

impl GraphModule for ExternalInput

Available on crate feature alloc only.
Source§

impl GraphModule for ExternalOutput

Available on crate feature alloc only.
Source§

impl GraphModule for Flanger

Source§

impl GraphModule for FormantOsc

Source§

impl GraphModule for Granular

Source§

impl GraphModule for GroundLoop

Source§

impl GraphModule for KarplusStrong

Source§

impl GraphModule for Lfo

Source§

impl GraphModule for Limiter

Source§

impl GraphModule for LogicAnd

Source§

impl GraphModule for LogicNot

Source§

impl GraphModule for LogicOr

Source§

impl GraphModule for LogicXor

Source§

impl GraphModule for Max

Source§

impl GraphModule for MidSideDecode

Source§

impl GraphModule for MidSideEncode

Source§

impl GraphModule for Min

Source§

impl GraphModule for Mixer

Source§

impl GraphModule for Multiple

Source§

impl GraphModule for NoiseGate

Source§

impl GraphModule for NoiseGenerator

Source§

impl GraphModule for Offset

Source§

impl GraphModule for OscInput

Available on crate feature std only.
Source§

impl GraphModule for ParametricEq

Source§

impl GraphModule for Phaser

Source§

impl GraphModule for PitchShifter

Source§

impl GraphModule for PrecisionAdder

Source§

impl GraphModule for Quantizer

Source§

impl GraphModule for Rectifier

Source§

impl GraphModule for Reverb

Source§

impl GraphModule for RingModulator

Source§

impl GraphModule for SampleAndHold

Source§

impl GraphModule for SamplePlayer

Source§

impl GraphModule for Saturator

Source§

impl GraphModule for ScaleQuantizer

Source§

impl GraphModule for SlewLimiter

Source§

impl GraphModule for StepSequencer

Source§

impl GraphModule for StereoOutput

Source§

impl GraphModule for Supersaw

Source§

impl GraphModule for Svf

Source§

impl GraphModule for Tremolo

Source§

impl GraphModule for UnitDelay

Source§

impl GraphModule for VcSwitch

Source§

impl GraphModule for Vca

Source§

impl GraphModule for Vco

Source§

impl GraphModule for Vibrato

Source§

impl GraphModule for Vocoder

Source§

impl GraphModule for VoiceInput

Source§

impl GraphModule for VoiceMixer

Source§

impl GraphModule for Wavefolder

Source§

impl GraphModule for Wavetable

Source§

impl<M> GraphModule for ModuleGraphAdapter<M>
where M: Module<In = f64, Out = f64> + Sync,