pub struct VisualSamplingFilter {
    recalc_state: bool,
    write_ptr: usize,
    sample_buffer: [f32; 10],
    last_output: (f32, f32),
}
Expand description

Accumulates the values for a single visible feedback value, like an LED (crate::Matrix::led_value_for) or the output feedbacks crate::Matrix::out_fb_for from the crate::Matrix.

Fields

recalc_state: bool

Holds a state bit, that is used to check if this filter needs to recalculate or not.

write_ptr: usize

Current write head into the sample buffer.

sample_buffer: [f32; 10]

Holds a set of the most recent samples to calculate the output.

last_output: (f32, f32)

Holds the last output, will only be recalculated when necessary.

Implementations

Used to check if we need to update this filter.

Retrieves the current output value of the filter. Negate the input for recalc_value one each frame, to reduce access to the retrieve_fn to be done only once per frame and per VisualSamplingFilter.

 use hexodsp::nodes::visual_sampling_filter::*;

 let mut vsf = VisualSamplingFilter::new();

 let inputs = [-0.87, -0.8, 0.2, 0.75, 0.5, 0.0, 0.22];
 let mut recalc = true;

 let mut last_output = (0.0, 0.0);
 for ip in inputs {
     last_output = vsf.get(recalc, ip);
     recalc = !recalc;
 }

 assert_eq!(last_output, (0.87, 0.75));

Trait Implementations

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more

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.

Calls U::from(self).

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

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
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.