Skip to main content

inverse_cqt

Function inverse_cqt 

Source
pub fn inverse_cqt(
    spectrogram: &[f32],
    n_frames: usize,
    n_bins: usize,
    sample_rate: f32,
    f_min: f32,
    bins_per_octave: usize,
    hop: usize,
    frame_len: usize,
    out: &mut [f32],
) -> Result<usize, AudioError>
Expand description

Approximate inverse CQT via magnitude-weighted sinusoidal overlap-add.

spectrogram is a row-major [n_frames × n_bins] magnitude matrix (as produced by super::spectrogram::cqt_spectrogram). Each bin k maps to centre frequency f_min * 2^(k / bins_per_octave). The reconstruction sums, for every frame and bin, mag * hann * sin(2π f_k n / sr) into the output at absolute sample index n, with frames placed hop samples apart.

Returns the number of samples written: (n_frames - 1) * hop + frame_len (0 if n_frames == 0). out is fully overwritten in [0, len) (accumulation starts from zero).

§Errors