pub struct FFTAnalyzer {
fft_size: usize,
window: Vec<f32>,
fft_buffer: Vec<f32>,
bins: Vec<f32>,
sample_rate: f32,
}Expand description
FFT analyzer for audio frequency analysis.
Fields§
§fft_size: usizeFFT size (power of 2)
window: Vec<f32>Window function (Hann window)
fft_buffer: Vec<f32>FFT buffer (real and imaginary parts)
bins: Vec<f32>Frequency bins
sample_rate: f32Sample rate
Implementations§
Source§impl FFTAnalyzer
impl FFTAnalyzer
Sourcepub fn new(fft_size: usize, sample_rate: f32) -> Option<Self>
pub fn new(fft_size: usize, sample_rate: f32) -> Option<Self>
Create a new FFT analyzer. Returns None if fft_size is not a power of 2.
Sourcepub fn new_or_default(fft_size: usize, sample_rate: f32) -> Self
pub fn new_or_default(fft_size: usize, sample_rate: f32) -> Self
Create a new FFT analyzer, panicking on invalid input.
Use new for fallible construction.
Sourcepub fn analyze(&mut self, samples: &[f32]) -> &[f32]
pub fn analyze(&mut self, samples: &[f32]) -> &[f32]
Analyze audio samples and return frequency bins.
Sourcepub fn get_treble(&self) -> f32
pub fn get_treble(&self) -> f32
Get treble level (2000-20000 Hz).
Sourcefn get_frequency_range(&self, min_freq: f32, max_freq: f32) -> f32
fn get_frequency_range(&self, min_freq: f32, max_freq: f32) -> f32
Get energy in a frequency range.
Sourcefn fft_inplace(&mut self)
fn fft_inplace(&mut self)
Simple in-place FFT (Cooley-Tukey algorithm).
Auto Trait Implementations§
impl Freeze for FFTAnalyzer
impl RefUnwindSafe for FFTAnalyzer
impl Send for FFTAnalyzer
impl Sync for FFTAnalyzer
impl Unpin for FFTAnalyzer
impl UnwindSafe 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
§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
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>
Converts
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>
Converts
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