pub struct StreamingFft { /* private fields */ }Expand description
Streaming FFT processor.
Samples are pushed incrementally. Once the internal buffer accumulates
fft_size samples a magnitude spectrum is emitted; then hop_size
samples are consumed from the front of the buffer so that the next
frame begins hop_size samples later (overlap = fft_size - hop_size).
Implementations§
Source§impl StreamingFft
impl StreamingFft
Sourcepub fn new(config: StreamingFftConfig) -> Self
pub fn new(config: StreamingFftConfig) -> Self
Create a new streaming FFT processor.
§Panics
Does not panic; invalid configuration is silently clamped where
possible. Callers should validate with StreamingFftConfig fields
before calling.
Sourcepub fn push(&mut self, samples: &[f64]) -> Vec<Vec<f64>>
pub fn push(&mut self, samples: &[f64]) -> Vec<Vec<f64>>
Push new samples into the stream.
Returns all completed magnitude spectra generated from the incoming
data. Each returned Vec<f64> has length fft_size / 2 + 1 and
contains the one-sided magnitude spectrum (DC to Nyquist).
A new frame is emitted every time the internal buffer reaches
fft_size samples; hop_size samples are then drained from the
front of the buffer so the next frame overlaps by
fft_size - hop_size samples.
Sourcepub fn flush(&mut self) -> Vec<Vec<f64>>
pub fn flush(&mut self) -> Vec<Vec<f64>>
Flush remaining buffered samples.
Zero-pads the internal buffer to fft_size and emits one spectrum if
the buffer is non-empty. Resets the buffer afterwards.
Returns an empty Vec if the buffer is already empty.
Sourcepub fn buffered_samples(&self) -> usize
pub fn buffered_samples(&self) -> usize
Number of samples currently held in the internal buffer.
Auto Trait Implementations§
impl Freeze for StreamingFft
impl RefUnwindSafe for StreamingFft
impl Send for StreamingFft
impl Sync for StreamingFft
impl Unpin for StreamingFft
impl UnsafeUnpin for StreamingFft
impl UnwindSafe for StreamingFft
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> 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