pub struct AudioAnalyzer {
fft: FFTAnalyzer,
bass_att: f32,
mid_att: f32,
treb_att: f32,
attenuation: f32,
agc_bass_avg: f32,
agc_mid_avg: f32,
agc_treb_avg: f32,
}Expand description
Audio analyzer for extracting per-band volumes.
Fields§
§fft: FFTAnalyzer§bass_att: f32Long-term smoothed bass — the bass_att variable preset equations read.
mid_att: f32Long-term smoothed mid — the mid_att variable preset equations read.
treb_att: f32Long-term smoothed treble — the treb_att variable preset equations read.
attenuation: f32Exponential-smoothing retention factor for the _att channels. Closer
to 1.0 = longer history. MD2’s _att channels are heavily smoothed
so they represent recent average loudness, not instantaneous.
agc_bass_avg: f32Per-band running average used by the AGC to steer the gain. Updated each frame from the raw pre-AGC band level; the AGC divides the target level by this to compute the gain factor. Floor at 0.05 so the gain doesn’t blow up on near-silent input.
agc_mid_avg: f32§agc_treb_avg: f32Implementations§
Source§impl AudioAnalyzer
impl AudioAnalyzer
Sourcepub fn analyze(&mut self, samples: &[f32]) -> AudioLevels
pub fn analyze(&mut self, samples: &[f32]) -> AudioLevels
Analyze audio samples and return per-band volumes.
Pipeline: FFT → raw band integral → AGC. The AGC keeps each
band hovering near AGC_TARGET_LEVEL = 1.0 on typical content,
so bass > 1.5 on the output unambiguously means “louder than
usual” — the convention every MD2 preset’s beat-detection block
is authored against. Without the AGC, quiet tracks float around
0.2-0.4 and never trigger BeatDetectionMode::HardCut1; loud
tracks pin at the 8.0 clamp and beat detection saturates.
Sourcepub fn set_attenuation(&mut self, attenuation: f32)
pub fn set_attenuation(&mut self, attenuation: f32)
Set attenuation factor.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for AudioAnalyzer
impl RefUnwindSafe for AudioAnalyzer
impl Send for AudioAnalyzer
impl Sync for AudioAnalyzer
impl Unpin for AudioAnalyzer
impl UnwindSafe for AudioAnalyzer
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
§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>
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§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().