# Phase Vocoder
A spectral algorithm for independent time and pitch manipulation.
Uses discrete Fourier transform (DFT / FFT).
# 1 Time Stretch
# 1.1 Parameters
These can be tuned to taste.
: input audio block size (integer, eg 8192).
: input audio hop size (integer, eg 19).
: zero-padded block size (for DFT, integer, eg 262144).
: output audio hop size (integer, eg 432).
The time dilation factor is .
# 1.2 Algorithm
Take samples of input audio every samples.
Multiply by raised cosine window of length (peak amplitude , mean ).
Zero-pad to length , call it where is the block index in .
Take the discrete Fourier transform of , call it .
For each bin, normalize the (complex-valued) ratio to magnitude , and raise it to the power (which need not be an integer). Call the result . In case of division by zero or other badness, set .
Increment the phase of each bin by and normalize (just to be safe in case of rounding errors). Phase of is probably arbitrary but should have magnitude .
Then the output Fourier transform has the input’s magnitude with the accumulated phase: .
Take the inverse Fourier transform of , call it .
Multiply by raised cosine window of length (peak amplitude , mean ).
Multiply by gain factor: . This assumes that the gain of the DFT/FFT is not normalized.
Accumulate samples spaced every samples to output audio stream (overlap-add).
# 1.3 References
- Pure-data documentation
3.audio.examples/I07.phase.vocoder.pd(Pd version 0.53).