pshifter
Phase-locked pitch shifting of a live audio signal, with optional formant scaling.
pshifter uses the same phase-locked vocoder algorithm as mincer, but reads from an audio input signal rather than a function table. It has no time-scaling control. The second output reports the fixed latency of the opcode, so a dry signal can be delayed by the same amount for alignment.
Formant preservation is optional. When kkeepform is non-zero and the pitch or formant scaling ratio is outside the neutral range, the spectral envelope is extracted from the source frame and restored on the output frame. Formant scaling follows pvswarp: setting kfscal to 1 preserves the original formants, setting it to kpitch leaves the naturally shifted formants, values above 1 stretch the envelope, and values below 1 compress it.
Syntax
Initialization
ifftsize -- FFT size (power-of-two), defaults to 2048. The opcode reports a latency of ifftsize/sr seconds in idel.
idecim -- decimation, defaults to 8 (meaning hopsize = ifftsize/8). Valid values are 4 to ifftsize and must divide ifftsize evenly.
ibeta -- scaling exponent for identity phase locking, used only when klock is 3. A value of 1 (the default) selects identity phase locking.
Performance
ain -- input audio signal.
kpitch -- pitch scaling ratio (1 = normal pitch, < 1 lower, > 1 higher). Values are clamped to the range 0.25 to 4; non-finite or negative values are treated as 1.
kfscal -- spectral envelope scaling ratio. Effective formant scaling is kpitch / kfscal. Values are converted to their absolute value and clamped to the range 0.25 to 4; non-finite or zero values are treated as 1. This argument has no effect when kkeepform is 0.
klock -- phase-locking mode: 0 disables locking; 1 selects the legacy phase-locking algorithm; 2 selects identity phase locking; 3 selects identity phase locking with the exponent given by ibeta. Other non-zero values use the legacy algorithm.
kkeepform -- formant preservation mode: 0 disables formant preservation; 1 selects liftered cepstrum envelope extraction; 2 selects true-envelope extraction. Values are rounded half up and values of 2.5 or higher select mode 2.
kcoefs -- number of cepstrum coefficients used for formant preservation (defaults to 80).
The input is held in a bounded circular buffer. The read position is recomputed from the write position on every frame, so pitch changes do not reset the overlap or formant state.
Examples
This example shifts fox.wav by four ratios and compares formant preservation modes 0, 1 and 2. The optional FFT size and decimation are omitted, so the defaults of 2048 and 8 are used. It uses the file pshifter.csd.
See also
mincer, pvswarp, Short-time Fourier Transform (STFT) Resynthesis, Tools for Real-time Spectral Processing (pvs opcodes)
Credits
Author: Victor Lazzarini
November 2026