pub struct SlidingDft<T: Float> { /* private fields */ }Expand description
Standard Sliding DFT that maintains all N frequency bins.
After the first N samples have been pushed the spectrum is valid.
Each subsequent push updates all N bins in O(N).
Note: This variant can accumulate numerical drift over very long
runs. If that is a concern, use ModulatedSdft instead.
Implementations§
Source§impl<T: Float> SlidingDft<T>
impl<T: Float> SlidingDft<T>
Sourcepub fn push(&mut self, sample: Complex<T>)
pub fn push(&mut self, sample: Complex<T>)
Push one complex sample and update all frequency bins.
Sourcepub fn push_real(&mut self, sample: T)
pub fn push_real(&mut self, sample: T)
Convenience: push a real-valued sample (imaginary part = 0).
Sourcepub fn spectrum(&self) -> &[Complex<T>]
pub fn spectrum(&self) -> &[Complex<T>]
Current frequency-domain spectrum.
Returns a zero-filled slice until the first N samples have been pushed.
Sourcepub fn bin(&self, k: usize) -> Complex<T>
pub fn bin(&self, k: usize) -> Complex<T>
Read a single frequency bin.
Returns Complex::zero() if the index is out of range or not yet initialised.
Sourcepub fn magnitude_spectrum(&self) -> Vec<T>
pub fn magnitude_spectrum(&self) -> Vec<T>
Magnitude spectrum: |X[k]| for each bin.
Sourcepub fn power_spectrum(&self) -> Vec<T>
pub fn power_spectrum(&self) -> Vec<T>
Power spectrum: |X[k]|² for each bin.
Sourcepub fn window_size(&self) -> usize
pub fn window_size(&self) -> usize
Window size.
Sourcepub fn is_initialized(&self) -> bool
pub fn is_initialized(&self) -> bool
Whether the buffer has been filled at least once (spectrum is valid).
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for SlidingDft<T>
impl<T> RefUnwindSafe for SlidingDft<T>where
T: RefUnwindSafe,
impl<T> Send for SlidingDft<T>
impl<T> Sync for SlidingDft<T>
impl<T> Unpin for SlidingDft<T>where
T: Unpin,
impl<T> UnsafeUnpin for SlidingDft<T>
impl<T> UnwindSafe for SlidingDft<T>where
T: UnwindSafe,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more