Skip to main content

ModuleGraphAdapter

Struct ModuleGraphAdapter 

Source
pub struct ModuleGraphAdapter<M> { /* private fields */ }
Expand description

Adapts a single-in / single-out combinator Module into a GraphModule, so a combinator chain (e.g. a.then(b).then(c)) can be added to a Patch via patch.add(...).

The generated PortSpec has exactly one input port (id 0) and one output port (id 10), both SignalKind::Audio, following the crate’s input-ids-from-0 / output-ids-from-10 convention.

Implementations§

Source§

impl<M> ModuleGraphAdapter<M>
where M: Module<In = f64, Out = f64>,

Source

pub fn new(module: M) -> Self

Wrap module with a one-in ("in", id 0) / one-out ("out", id 10) audio port spec.

Source

pub fn with_ports( module: M, input_name: impl Into<String>, output_name: impl Into<String>, ) -> Self

Wrap module, naming its single input (id 0) and output (id 10) ports.

Trait Implementations§

Source§

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

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
Source§

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

Get module type identifier for serialization
Source§

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

Process a block of samples (optional optimization). Read more
Source§

fn breaks_feedback_cycle(&self) -> bool

Whether this module breaks a feedback cycle in the patch graph. Read more
Source§

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

Get parameter definitions for UI binding. Read more
Source§

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

Get a parameter value. Read more
Source§

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

Set a parameter value. Read more
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. Read more
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.

Auto Trait Implementations§

§

impl<M> Freeze for ModuleGraphAdapter<M>
where M: Freeze,

§

impl<M> RefUnwindSafe for ModuleGraphAdapter<M>
where M: RefUnwindSafe,

§

impl<M> Send for ModuleGraphAdapter<M>
where M: Send,

§

impl<M> Sync for ModuleGraphAdapter<M>
where M: Sync,

§

impl<M> Unpin for ModuleGraphAdapter<M>
where M: Unpin,

§

impl<M> UnsafeUnpin for ModuleGraphAdapter<M>
where M: UnsafeUnpin,

§

impl<M> UnwindSafe for ModuleGraphAdapter<M>
where M: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.