pub struct DualWindowStft { /* private fields */ }Expand description
Dual-window STFT processor.
Uses a long analysis window for frequency resolution and a shorter synthesis window for low-latency output. The output latency equals the synthesis window size, not the analysis window size.
Implementations§
Source§impl DualWindowStft
impl DualWindowStft
Sourcepub fn new(analysis_size: usize, synthesis_size: usize, hop_size: usize) -> Self
pub fn new(analysis_size: usize, synthesis_size: usize, hop_size: usize) -> Self
Create a new dual-window STFT processor.
§Arguments
analysis_size- Analysis window size (determines frequency resolution)synthesis_size- Synthesis window size (determines output latency)hop_size- Hop size in samples
Sourcepub fn analyze(&mut self, sample: f32) -> bool
pub fn analyze(&mut self, sample: f32) -> bool
Push a single sample. Returns true when a hop boundary is reached.
When true, the spectrum is available in freq_buffer_mut() for
in-place modification. Call synthesize_in_place() after modifying.
Sourcepub fn freq_buffer_mut(&mut self) -> &mut [Complex<f32>]
pub fn freq_buffer_mut(&mut self) -> &mut [Complex<f32>]
Access the frequency buffer for in-place modification after analyze() returns true.
Sourcepub fn synthesize_in_place(&mut self)
pub fn synthesize_in_place(&mut self)
Synthesize output from the current frequency buffer (after in-place modification).
Call this after analyze() returns true and the spectrum has been modified
via freq_buffer_mut(). The output samples accumulate in the internal buffer
and can be read via read_output().
Sourcepub fn read_output(&mut self) -> f32
pub fn read_output(&mut self) -> f32
Read one output sample. Returns 0.0 if no output is ready yet.
Sourcepub fn process_block<F>(
&mut self,
input: &[f32],
output: &mut [f32],
process_fn: F,
)
pub fn process_block<F>( &mut self, input: &[f32], output: &mut [f32], process_fn: F, )
Process a block: analyze, apply user function, synthesize.
§Arguments
input- Input samplesoutput- Output buffer (same length as input)process_fn- Function to modify the spectrum (called at each hop boundary)
Sourcepub fn latency_samples(&self) -> usize
pub fn latency_samples(&self) -> usize
Get the output latency in samples.
Auto Trait Implementations§
impl Freeze for DualWindowStft
impl !RefUnwindSafe for DualWindowStft
impl Send for DualWindowStft
impl Sync for DualWindowStft
impl Unpin for DualWindowStft
impl UnsafeUnpin for DualWindowStft
impl !UnwindSafe for DualWindowStft
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.