← Gallery Griffin-Lim — rebuild audio from a spectrogram

Griffin-Lim — rebuild audio from a spectrogram

scripts/xa-advanced.js — reconstruction A/B

A spectrogram only stores how loud each frequency is — the phase that makes it playable audio is thrown away. Griffin-Lim invents a plausible phase and rebuilds sound from the magnitudes alone: A/B the original chord against the reconstruction and hear that the pitch survives. Technically, a 440 + 660 Hz chord's |STFT(1024, 256)| goes through griffinlim(32) with deterministic zero-phase init (before a repair this returned one sample — an istft arg-shift put center=true into length). Badges mirror examples/node/xa-advanced.mjs: audio-length output, strictly decreasing spectral convergence over iterations 1–8, <10% relative L2 magnitude error after 32 iterations, and an FFT-peak pitch within 1% of 440 Hz.

target |STFT| (original)

|STFT| of the 32-iteration reconstruction

spectral-convergence error vs iteration (k = 1..8, deterministic)