pub struct ApplyNM<A, B, const N: usize, const M: usize> where
    A: 'static,
    B: 'static, 
{ /* private fields */ }
Expand description

Applies a function on N samples in the input stream, and creates M samples in the output stream. Handy for interleaved samples for example. See examples/audio/play_stereo.rs

Inputs

in: Input

Outputs

out: Output after function applied

Usage

use futuresdr::blocks::ApplyNM;
use futuresdr::runtime::Flowgraph;
use num_complex::Complex;

let mut fg = Flowgraph::new();

// Convert mono stream to stereo interleaved stream
let mono_to_stereo = fg.add_block(ApplyNM::<f32, f32, 1, 2>::new(move |v: &[f32], d: &mut [f32]| {
    d[0] =  v[0] * 0.5; // gain left
    d[1] =  v[0] * 0.9; // gain right
}));
// Note that the closure can also hold state
// Additionally, the closure can change the type of the sample

Implementations

Trait Implementations

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

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

Should always be Self

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more