Skip to main content

griffin_lim

Function griffin_lim 

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

Run iterations Griffin-Lim rounds and write the reconstructed time signal.

  • target_mags: num_frames × (N/2 + 1) non-negative magnitude targets, frame i at target_mags[i*(N/2+1) .. (i+1)*(N/2+1)].
  • spectra: num_frames × 2N interleaved-complex working buffer, seeded by the caller with an initial estimate (typically target magnitude × e^{jφ} for some initial phase φ, Hermitian-symmetric). Updated in place; num_frames = spectra.len() / (2N).
  • fft_size: N, a power of two.
  • hop: sample advance between frames (> 0).
  • iterations: number of projection rounds (0 just inverts the seed).
  • analysis_window / synthesis_window: length-N windows (WOLA pair).
  • ifft_scratch: ≥ N floats (clobbered).
  • norm: ≥ out_len floats, ISTFT normalisation scratch (clobbered).
  • out: ≥ out_len floats; receives the reconstruction, where out_len = (num_frames − 1)·hop + N.

Returns out_len. Errors mirror istft, plus AudioError::InvalidParameter if target_mags.len() does not equal num_frames × (N/2 + 1).