Search guides and the APICtrl K
  1. API reference
  2. DSP

stft.h

A short-time Fourier transform you can process in the middle of.

#include <sonore/stft.h>
On this page

Design notes

fft.h has the transform, an analyser that only LOOKS, and a convolver that does one specific thing in the frequency domain. What was missing was the general frame: window, transform, hand the spectrum to the caller, transform back, overlap-add -- the substrate of a spectral gate, a denoiser, a freeze, a vocoder, a phase vocoder. This is that frame, and only that: the processing is the functor you pass in.

Reconstruction is EXACT, not approximately: the overlap-add normalisation is computed at prepare() by summing the squared window over one hop's worth of positions, and every output sample is divided by the sum at its position. That holds for any window and any overlap where the sum is never zero, which is every sensible combination, and it means the identity processor gives back the input to float precision -- asserted in the unit test -- rather than the 1.5x-with-ripple that a "Hann at 75% is COLA" shortcut produces with a symmetric window.

Included by dsp.h. Depends on Fft<> from fft.h.

Types 1

template <size_t Size = 1024, size_t Overlap = 4> class Stft

Size is the frame; Overlap the number of frames covering each sample, so the hop is Size / Overlap. 1024 / 4 is the general-purpose choice: 21 ms frames at 48 kHz, 5 ms hop. Latency is exactly Size, and it is reported.

↑↓ to move↵ to openEvery public name in the headers, and every guide