Tzopilotl
Docs
GitHub

Writing SynthDefs

13. Spectral Processing

spectralChain(input, fftSize, hopSize, bodyFn) windows and FFTs input, hands each spectral frame to bodyFn (a fn(S) S whose argument is the frame signal), and overlap-adds the processed frames back to a time-domain output. fftSize is the frame length in samples (a power of two); hopSize is the analysis stride. Operations inside the body apply to the frame's bins.

-- process the spectrum: the body maps each analysis frame
fn spectralFx() S {
    let x = inlet(FLOAT32);
    spectralChain(x, 1024, 256, fn(frame S) S {
        frame * frame        -- e.g. square the bins (spectral contrast)
    }) |> outlet
}
↑ Back to top