Skip to main content

istft

Function istft 

Source
pub fn istft(
    spectra: &mut [f32],
    fft_size: usize,
    hop: usize,
    analysis_window: &[f32],
    synthesis_window: &[f32],
    ifft_scratch: &mut [f32],
    norm: &mut [f32],
    out: &mut [f32],
) -> Result<usize, AudioError>
Expand description

Inverse STFT of a run of complex spectra into a single time-domain signal.

  • spectra: num_frames × (2·fft_size) interleaved-complex bins ([re, im, …]), frame i at spectra[i*2N .. (i+1)*2N]. Clobbered in place (each frame is inverse-transformed). num_frames is inferred as spectra.len() / (2·fft_size).
  • fft_size: N, a power of two; equals the analysis frame size.
  • hop: sample advance between frames (> 0).
  • analysis_window / synthesis_window: the length-N windows used in analysis and applied in synthesis. Their product forms the normalisation.
  • ifft_scratch: ≥ N floats; per-frame real inverse output (clobbered).
  • norm: ≥ out_len floats; accumulates Σ w_a·w_s (clobbered).
  • out: ≥ out_len floats; receives the reconstructed signal, where out_len = (num_frames − 1)·hop + N.

Returns the number of output samples written (out_len).

Errors: AudioError::InvalidParameter for a non-power-of-two/zero fft_size, zero hop, wrong window lengths, or a spectra length that is not a multiple of 2·fft_size; AudioError::OutputBufferTooSmall if ifft_scratch, norm, or out are too short.