Skip to main content

inverse_stft

Function inverse_stft 

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

Inverse STFT of the two-sided complex frames from crate::audio::stft::forward_stft back into a single time-domain signal.

  • spec: num_frames frames, each a length-frame_size two-sided spectrum of [re, im] bins (exactly the crate::audio::stft::forward_stft output).
  • frame_size: N, a power of two; the analysis/synthesis frame length.
  • hop: sample advance between frames (> 0). A COLA Hann at hop = N/2 gives exact interior reconstruction.

The frames are flattened into a num_frames × 2·N interleaved-complex buffer ([re, im, …]), a length-N Hann window is built for both the analysis and synthesis arguments, and the WOLA resynthesiser [etalon_signal::audio::istft_overlap_add_into] is invoked with caller-owned norm/out buffers (out_len = (num_frames − 1)·hop + N).

Returns the reconstructed samples (length out_len), or an empty Vec when spec is empty.