pub struct Downsample(pub u32);Expand description
Scalar downsampler with explicit tick phase.
The first input sample produces Some(x), then rate input samples produce
None, and the pattern repeats. This matches the phase convention used by
crate::Decimator when wrapping a scalar X -> Option<Y> processor into a
chunked one.
Use this when the stream is still scalar and phase must be tracked across
time. It does not by itself turn a chunk [X; N] into one output Y; pair
it with Decimator or TryDecimator for that.
Together with crate::Hold, this forms the scalar optional-sample pair:
Downsample removes samples by emitting None, while Hold fills those
gaps again by repeating the last present sample.
Compare with:
crate::Rate: stateless chunk-slot conversionDecimator: chunk adapter over a scalarX -> Option<Y>stage
State is the current countdown and should usually be initialized to 0.
§Examples
use dsp_process::{Downsample, SplitProcess};
let ds = Downsample(2);
let mut state = 0;
assert_eq!(ds.process(&mut state, 10), Some(10));
assert_eq!(ds.process(&mut state, 11), None);
assert_eq!(ds.process(&mut state, 12), None);
assert_eq!(ds.process(&mut state, 13), Some(13));Tuple Fields§
§0: u32Trait Implementations§
Source§impl Clone for Downsample
impl Clone for Downsample
Source§fn clone(&self) -> Downsample
fn clone(&self) -> Downsample
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl Copy for Downsample
Source§impl Debug for Downsample
impl Debug for Downsample
Source§impl Default for Downsample
impl Default for Downsample
Source§fn default() -> Downsample
fn default() -> Downsample
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for Downsample
impl RefUnwindSafe for Downsample
impl Send for Downsample
impl Sync for Downsample
impl Unpin for Downsample
impl UnsafeUnpin for Downsample
impl UnwindSafe for Downsample
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<'a, 'b, X, Y, S, T, const L: usize> SplitViewProcess<View<'a, X, FrameMajor, L>, ViewMut<'b, Y, FrameMajor, L>, S> for T
impl<'a, 'b, X, Y, S, T, const L: usize> SplitViewProcess<View<'a, X, FrameMajor, L>, ViewMut<'b, Y, FrameMajor, L>, S> for T
Source§fn process_view(
&self,
state: &mut S,
x: View<'a, X, FrameMajor, L>,
y: ViewMut<'b, Y, FrameMajor, L>,
)
fn process_view( &self, state: &mut S, x: View<'a, X, FrameMajor, L>, y: ViewMut<'b, Y, FrameMajor, L>, )
Process one typed input view into one typed output view.