pub struct AudioAnalysis {
pub frame_rate: u32,
pub amplitude: Vec<f32>,
pub bands: Vec<[f32; 16]>,
pub start: f64,
pub end: Option<f64>,
}Expand description
Per-track audio analysis: amplitude (RMS) and frequency bands per video frame.
Fields§
§frame_rate: u32The video frame rate this analysis was computed at.
amplitude: Vec<f32>RMS amplitude per frame, normalized 0..1 over the whole track.
bands: Vec<[f32; 16]>16 log-spaced frequency bands (20 Hz–16 kHz) per frame, normalized 0..1.
start: f64Where the track sits on the scenario timeline (AudioTrack::start).
The analysis indexes the file from its own sample 0, while every
consumer asks in scenario time. Without this the two only line up when
start == 0: a track placed at 73 s played from its beginning while the
waveform drew the file’s content at 73 s. Held here rather than at the
call sites because the cache is keyed by path and the painters never see
the AudioTrack.
end: Option<f64>AudioTrack::end, past which the track is cut and the visualisation
must go flat rather than keep drawing an envelope nobody hears.
Implementations§
Source§impl AudioAnalysis
impl AudioAnalysis
Sourcepub fn amplitude_at(&self, time: f64) -> f32
pub fn amplitude_at(&self, time: f64) -> f32
Get the amplitude at a given time (seconds), clamped to valid range.
Sourcepub fn band_at(&self, time: f64, band: u8) -> f32
pub fn band_at(&self, time: f64, band: u8) -> f32
Get a specific band [0..16) value at a given time.
Sourcepub fn amplitude_smoothed(&self, time: f64, smoothing_frames: u32) -> f32
pub fn amplitude_smoothed(&self, time: f64, smoothing_frames: u32) -> f32
Smoothed amplitude at time: average over the past smoothing_frames frames (inclusive of current).
Trait Implementations§
Source§impl Clone for AudioAnalysis
impl Clone for AudioAnalysis
Source§fn clone(&self) -> AudioAnalysis
fn clone(&self) -> AudioAnalysis
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for AudioAnalysis
impl RefUnwindSafe for AudioAnalysis
impl Send for AudioAnalysis
impl Sync for AudioAnalysis
impl Unpin for AudioAnalysis
impl UnsafeUnpin for AudioAnalysis
impl UnwindSafe for AudioAnalysis
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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