pub struct FftAnalyzer {
pub magnitudes: Vec<f32>,
pub smoothed: Vec<f32>,
/* private fields */
}Expand description
Holds the rolling sample buffer and performs FFT analysis.
Fields§
§magnitudes: Vec<f32>Latest magnitude spectrum (fft_size/2 bins).
smoothed: Vec<f32>Smoothed magnitudes for visuals.
Implementations§
Source§impl FftAnalyzer
impl FftAnalyzer
Sourcepub fn new(fft_size: usize, sample_rate: u32) -> Self
pub fn new(fft_size: usize, sample_rate: u32) -> Self
Create an analyser with the given FFT window size and sample rate. Typical sizes: 512, 1024, 2048, 4096.
pub fn set_window(&mut self, w: Window)
Sourcepub fn push_samples(&mut self, samples: &[f32])
pub fn push_samples(&mut self, samples: &[f32])
Push new audio samples (mono f32). Keeps a rolling window.
Sourcepub fn freq_bands(&self, bands: usize) -> Vec<f32>
pub fn freq_bands(&self, bands: usize) -> Vec<f32>
Return bands logarithmically-spaced frequency magnitudes.
Index 0 = bass, index bands-1 = treble.
Sourcepub fn dominant_freq(&self) -> f32
pub fn dominant_freq(&self) -> f32
Dominant frequency in Hz (peak of magnitude spectrum).
Sourcepub fn is_beat(&self) -> bool
pub fn is_beat(&self) -> bool
Beat detection: true if current frame energy significantly exceeds average.
Sourcepub fn beat_ratio(&self) -> f32
pub fn beat_ratio(&self) -> f32
Beat energy ratio (1.0 = at threshold, >1 = strong beat).
Auto Trait Implementations§
impl !RefUnwindSafe for FftAnalyzer
impl !UnwindSafe for FftAnalyzer
impl Freeze for FftAnalyzer
impl Send for FftAnalyzer
impl Sync for FftAnalyzer
impl Unpin for FftAnalyzer
impl UnsafeUnpin for FftAnalyzer
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