Processing raw vocal recordings on a backend server gets expensive fast—and musicians understandably avoid uploading unreleased vocal stems to cloud buckets. Using Web Audio API ( OfflineAudioContext , BiquadFilterNode , and ConvolverNode ), you can run real-time scale quantization and 24-bit WAV rendering completely client-side.
1. Mapping Frequencies to Musical Scales
Once fundamental frequency f0 is extracted via time-domain autocorrelation over 70–900 Hz, converting to fractional MIDI notes makes scale snapping straightforward:
const rawMidi = 69 + 12 * Math . log2 ( f0 / 440 ) ;
Enter fullscreen mode
Exit fullscreen mode
By filtering target semitones against a root key and scale mask (see our interactive musical scale & retune speed reference chart ), you can interpolate smoothly between 45 ms natural phrasing and 0 ms hard-stepped Trap quantization.
2.…