pub struct TfSurface<'a> {
pub raster: &'a [f32],
pub frame_count: usize,
pub bin_count: usize,
pub sample_rate: u32,
pub hop_size: usize,
}Expand description
A time-frequency surface: frames × bins magnitude raster.
The raster is row-major: raster[frame * bins + bin].
This is a view (borrowed) — no heap allocation.
Fields§
§raster: &'a [f32]§frame_count: usize§bin_count: usize§sample_rate: u32§hop_size: usizeImplementations§
Source§impl<'a> TfSurface<'a>
impl<'a> TfSurface<'a>
Sourcepub fn new(
raster: &'a [f32],
frame_count: usize,
bin_count: usize,
sample_rate: u32,
hop_size: usize,
) -> Self
pub fn new( raster: &'a [f32], frame_count: usize, bin_count: usize, sample_rate: u32, hop_size: usize, ) -> Self
Create a surface view from a raw raster slice.
raster.len() must equal frame_count * bin_count.
Sourcepub fn frame_to_time(&self, frame: usize) -> f32
pub fn frame_to_time(&self, frame: usize) -> f32
Time in seconds for a given frame index.
Sourcepub fn bin_to_freq_linear(&self, bin: usize) -> f32
pub fn bin_to_freq_linear(&self, bin: usize) -> f32
Frequency in Hz for a linear bin index (STFT).
Sourcepub fn bin_to_freq_log(
&self,
bin: usize,
f_min: f32,
bins_per_octave: usize,
) -> f32
pub fn bin_to_freq_log( &self, bin: usize, f_min: f32, bins_per_octave: usize, ) -> f32
Frequency in Hz for a log-spaced bin index (CQT).
f_k = f_min * 2^(k / bins_per_octave)
Sourcepub fn sample_bilinear(&self, frame_f: f32, bin_f: f32) -> f32
pub fn sample_bilinear(&self, frame_f: f32, bin_f: f32) -> f32
Bilinear sample at fractional (frame_f, bin_f).
Sourcepub fn spectral_flux(&self, out: &mut [f32]) -> usize
pub fn spectral_flux(&self, out: &mut [f32]) -> usize
Spectral flux: sum of positive magnitude differences between
consecutive frames. Written to out (length frame_count - 1).
Sourcepub fn freq_gradient(&self, frame: usize, bin: usize) -> f32
pub fn freq_gradient(&self, frame: usize, bin: usize) -> f32
Frequency gradient at (frame, bin) — central difference.
Sourcepub fn time_gradient(&self, frame: usize, bin: usize) -> f32
pub fn time_gradient(&self, frame: usize, bin: usize) -> f32
Time gradient at (frame, bin) — central difference.
Sourcepub fn ridge_bin(&self, frame: usize) -> usize
pub fn ridge_bin(&self, frame: usize) -> usize
Find the ridge bin (peak magnitude) for a given frame. Returns the bin index of the maximum.
Sourcepub fn ridges(&self, out: &mut [usize]) -> usize
pub fn ridges(&self, out: &mut [usize]) -> usize
Collect ridge bins for all frames into out.
Returns the number of ridges written (= frame_count).
Sourcepub fn to_height_mesh(&self, out_verts: &mut [f32]) -> usize
pub fn to_height_mesh(&self, out_verts: &mut [f32]) -> usize
Convert to a height-map mesh: each (frame, bin) → (x, y, z)
where x = time, y = freq, z = magnitude.
Writes frame_count * bin_count vertices to out_verts as
[x, y, z] triples. Returns the number of vertices written.
Sourcepub fn total_energy(&self) -> f32
pub fn total_energy(&self) -> f32
Total energy (sum of all magnitudes).
Sourcepub fn frame_energy(&self, frame: usize) -> f32
pub fn frame_energy(&self, frame: usize) -> f32
Frame energy (sum of magnitudes in a single frame).
Trait Implementations§
impl<'a> Copy for TfSurface<'a>
Auto Trait Implementations§
impl<'a> Freeze for TfSurface<'a>
impl<'a> RefUnwindSafe for TfSurface<'a>
impl<'a> Send for TfSurface<'a>
impl<'a> Sync for TfSurface<'a>
impl<'a> Unpin for TfSurface<'a>
impl<'a> UnsafeUnpin for TfSurface<'a>
impl<'a> UnwindSafe for TfSurface<'a>
Blanket Implementations§
§impl<S, A> Aggregate<Result<S, Error>> for Awhere
A: Aggregate<S>,
impl<S, A> Aggregate<Result<S, Error>> for Awhere
A: Aggregate<S>,
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,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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