Skip to main content

forward_stft

Function forward_stft 

Source
pub fn forward_stft(
    samples: &[f32],
    frame_size: usize,
    hop: usize,
) -> Result<Vec<Vec<[f32; 2]>>, StftBakeError>
Expand description

Real forward STFT over samples.

frame_size must be a power of two in [2, 1024] (the forge FFT’s accelerated window; the CPU DFT floor honours the same size), otherwise StftBakeError::InvalidFrameCount.

For each frame start s = 0, hop, 2·hop, … while s + frame_size ≤ samples.len(): take samples[s..s+frame_size], apply the Hann window, build the interleaved complex buffer [re = windowed, im = 0], run it through crate::wgsl_forge::dispatch::fft_f32, and collect the frame’s frame_size complex bins as [re, im].

Returns one inner Vec<[f32;2]> (length frame_size) per frame.