Skip to main content

Feedback

Struct Feedback 

Source
pub struct Feedback<M: Module, F> {
    pub module: M,
    pub combine: F,
    pub delay_buffer: M::Out,
}
Expand description

Feedback loop with a mandatory single-sample delay for causality.

Each tick computes combine(external_input, previous_output) and feeds the result to the wrapped module. previous_output is the module’s output from the previous tick (the delay_buffer), which starts at M::Out::default() on the first tick and after reset. See ModuleExt::feedback for the argument-order contract and a runnable example.

Fields§

§module: M§combine: F§delay_buffer: M::Out

The previous tick’s output, delayed one sample. Default on the first tick.

Trait Implementations§

Source§

impl<M, F, Combined> Module for Feedback<M, F>
where M: Module<In = Combined>, F: Fn(M::Out, M::Out) -> Combined + Send, M::Out: Default + Clone + Send,

Source§

type In = <M as Module>::Out

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

type Out = <M as Module>::Out

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<M, F> Freeze for Feedback<M, F>
where M: Freeze, F: Freeze, <M as Module>::Out: Freeze,

§

impl<M, F> RefUnwindSafe for Feedback<M, F>

§

impl<M, F> Send for Feedback<M, F>
where F: Send, <M as Module>::Out: Send,

§

impl<M, F> Sync for Feedback<M, F>
where M: Sync, F: Sync, <M as Module>::Out: Sync,

§

impl<M, F> Unpin for Feedback<M, F>
where M: Unpin, F: Unpin, <M as Module>::Out: Unpin,

§

impl<M, F> UnsafeUnpin for Feedback<M, F>
where M: UnsafeUnpin, F: UnsafeUnpin, <M as Module>::Out: UnsafeUnpin,

§

impl<M, F> UnwindSafe for Feedback<M, F>
where M: UnwindSafe, F: UnwindSafe, <M as Module>::Out: 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.