Skip to main content

GraphModuleAdapter

Struct GraphModuleAdapter 

Source
pub struct GraphModuleAdapter<G: GraphModule> { /* private fields */ }
Expand description

Adapts a GraphModule (the engine’s multi-port, type-erased module trait) into a single-in / single-out combinator Module, so real DSP modules such as Vco or Svf can be composed with .then, .parallel, and .fanout.

One input port and one output port of the wrapped module are chosen at construction (by id, via new, or automatically from the first audio ports, via from_audio_ports). Every other input port keeps its PortDef default; the wrapped module still reads those on each tick, so pulse-width, cutoff, etc. behave as if unpatched in a graph.

Implementations§

Source§

impl<G: GraphModule> GraphModuleAdapter<G>

Source

pub fn new(module: G, input_port: PortId, output_port: PortId) -> Self

Wrap module, driving input port input_port and reading output port output_port on every tick.

Source

pub fn from_audio_ports(module: G) -> Option<Self>

Wrap module, automatically choosing its first SignalKind::Audio input and first SignalKind::Audio output port.

Returns None if the module exposes no audio input or no audio output (e.g. a Vco, whose only inputs are CV/pitch — use new with an explicit port id for those).

Source

pub fn inner(&self) -> &G

Borrow the wrapped GraphModule.

Source

pub fn into_inner(self) -> G

Consume the adapter, returning the wrapped GraphModule.

Trait Implementations§

Source§

impl<G: GraphModule> Module for GraphModuleAdapter<G>

Source§

type In = f64

Input signal type (e.g., f64 for mono, (f64, f64) for stereo)
Source§

type Out = f64

Output signal type
Source§

fn tick(&mut self, input: Self::In) -> Self::Out

Process a single sample, advancing internal state by one time step. Read more
Source§

fn reset(&mut self)

Reset internal state to initial conditions. Read more
Source§

fn set_sample_rate(&mut self, sample_rate: f64)

Notify module of sample rate changes. Read more
Source§

fn process(&mut self, input: &[Self::In], output: &mut [Self::Out])
where Self::In: Clone,

Process a block of samples for efficiency. Read more

Auto Trait Implementations§

§

impl<G> Freeze for GraphModuleAdapter<G>
where G: Freeze,

§

impl<G> RefUnwindSafe for GraphModuleAdapter<G>
where G: RefUnwindSafe,

§

impl<G> Send for GraphModuleAdapter<G>

§

impl<G> Sync for GraphModuleAdapter<G>

§

impl<G> Unpin for GraphModuleAdapter<G>
where G: Unpin,

§

impl<G> UnsafeUnpin for GraphModuleAdapter<G>
where G: UnsafeUnpin,

§

impl<G> UnwindSafe for GraphModuleAdapter<G>
where G: 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<M> ModuleExt for M
where M: Module,

Source§

fn then<M: Module<In = Self::Out>>(self, next: M) -> Chain<Self, M>

Chain this module with another (sequential composition: >>>)
Source§

fn parallel<M: Module>(self, other: M) -> Parallel<Self, M>

Run two modules in parallel (***)
Source§

fn fanout<M: Module<In = Self::In>>(self, other: M) -> Fanout<Self, M>
where Self::In: Clone,

Split input to two parallel processors (&&&)
Source§

fn map<F, U>(self, f: F) -> Map<Self, F>
where F: Fn(Self::Out) -> U,

Transform output with a pure function
Source§

fn contramap<F, U>(self, f: F) -> Contramap<Self, F, U>
where F: Fn(U) -> Self::In,

Transform input with a pure function
Source§

fn feedback<F>(self, combine: F) -> Feedback<Self, F>
where Self::Out: Default + Clone,

Create a feedback loop with a single-sample unit delay. Read more
Source§

fn first<C>(self) -> First<Self, C>

Apply this module only to the first element of a tuple
Source§

fn second<C>(self) -> Second<Self, C>

Apply this module only to the second element of a tuple
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.