pub struct Decimator<P>(pub P);Expand description
Adapt a scalar optional-output stage to chunk input mode.
Synchronizes to the inner tick by discarding samples after tick.
Panics if tick does not match N.
This is the chunked counterpart to Interpolator.
The inner processor must tick exactly once per input chunk. Decimator
processes the whole chunk and panics if the contract is violated. Use
TryDecimator when violating that contract should be reported instead of
panicking.
Unlike crate::Rate, this adapter still runs the
inner processor on every sample in the chunk before choosing the output.
That is the right semantics for recursive stages such as CIC decimators.
Conceptually, this is the chunk-level companion to crate::Downsample:
Downsample gates a scalar stream into Option<Y>, while Decimator
turns that exact-one-tick-per-chunk protocol into [X; N] -> Y.
Unlike crate::ChunkIn, this still executes the inner stage on every
sample in the chunk and is therefore the right adapter for recursive
decimators.
§Examples
use dsp_process::{Decimator, FnSplitProcess, SplitProcess};
let proc = Decimator(FnSplitProcess(|state: &mut bool, x: i32| {
let y = if *state { Some(x) } else { None };
*state = !*state;
y
}));
let mut tick = false;
assert_eq!(proc.process(&mut tick, [1, 2]), 2);Tuple Fields§
§0: P