|
DSPark 1.6.1
Header-only audio DSP framework in pure C++20 — zero dependencies
|
Real-time phase-vocoder pitch shifter (+-12 semitones, stereo-linked). More...
#include <PitchShifter.h>
Public Member Functions | |
| void | prepare (const AudioSpec &spec, int fftSize=2048) |
| Allocates all rings and spectral state. | |
| void | reset () noexcept |
| Clears all signal state (keeps parameters). Safe on the audio thread. | |
| void | setSemitones (T st) noexcept |
| Sets the pitch shift in semitones, clamped to +-12. | |
| void | setPitchRatio (T ratio) noexcept |
| Sets the pitch shift as a frequency ratio, clamped to [0.5, 2]. Non-finite values are ignored. | |
| void | setMix (T mix) noexcept |
| Dry/wet mix, [0, 1]. The dry path is latency-compensated and the mix is smoothed linearly over one block (the wet stream is decorrelated from the dry, so an unsmoothed step would click). Non-finite values are ignored. | |
| void | setTransientPreserve (bool enabled) noexcept |
| Enables phase reset on detected transients (default on). | |
| void | setFormantPreserve (bool enabled) noexcept |
| Keeps formants (vocal timbre) in place while pitch moves. | |
| T | getSemitones () const noexcept |
| T | getMix () const noexcept |
| bool | getTransientPreserve () const noexcept |
| bool | getFormantPreserve () const noexcept |
| int | getLatency () const noexcept |
| Reports total latency in samples (2 * fftSize, measured exact at unity ratio; ~85 ms at the default 2048 frame and 48 kHz). | |
| std::vector< uint8_t > | getState () const |
| Serializes the parameter state (setup/UI threads; allocates). | |
| bool | setState (const uint8_t *data, size_t size) |
| Restores parameters from a blob (tolerant; rejects foreign ids). | |
| void | processBlock (AudioBufferView< T > buffer) noexcept |
| Processes audio in-place. | |
Real-time phase-vocoder pitch shifter (+-12 semitones, stereo-linked).
| T | Sample type (float or double). |
Definition at line 82 of file PitchShifter.h.
|
inlinenoexcept |
Definition at line 266 of file PitchShifter.h.
|
inlinenoexcept |
Reports total latency in samples (2 * fftSize, measured exact at unity ratio; ~85 ms at the default 2048 frame and 48 kHz).
Definition at line 273 of file PitchShifter.h.
|
inlinenoexcept |
Definition at line 257 of file PitchShifter.h.
|
inlinenoexcept |
Definition at line 251 of file PitchShifter.h.
|
inline |
Serializes the parameter state (setup/UI threads; allocates).
Definition at line 276 of file PitchShifter.h.
|
inlinenoexcept |
Definition at line 260 of file PitchShifter.h.
|
inline |
Allocates all rings and spectral state.
Invalid specs (non-positive/non-finite rate, block size or channel count) and fftSize values that are not a power of two in [256, 1 << 20] are ignored: the previous state is kept and an unprepared instance stays pass-through.
| spec | Audio environment specification. |
| fftSize | STFT frame size, power of two (default 2048). Smaller sizes lower latency and favour transients; larger sizes favour low-pitched material. |
Definition at line 100 of file PitchShifter.h.
|
inlinenoexcept |
Processes audio in-place.
Pass-through until prepare() succeeds. Channels beyond the prepared count are left untouched.
| buffer | Audio block; all prepared channels are processed. |
Definition at line 308 of file PitchShifter.h.
|
inlinenoexcept |
Clears all signal state (keeps parameters). Safe on the audio thread.
Definition at line 168 of file PitchShifter.h.
|
inlinenoexcept |
Keeps formants (vocal timbre) in place while pitch moves.
A cepstral lift extracts the smooth spectral envelope of each frame (quefrencies below ~1 ms) and the synthesis magnitudes are pre-warped by env(k*ratio)/env(k), so after the output resampler the envelope lands back where it started - the classic anti-chipmunk correction. Costs two extra FFTs per frame. Default off.
Definition at line 245 of file PitchShifter.h.
|
inlinenoexcept |
Dry/wet mix, [0, 1]. The dry path is latency-compensated and the mix is smoothed linearly over one block (the wet stream is decorrelated from the dry, so an unsmoothed step would click). Non-finite values are ignored.
Definition at line 224 of file PitchShifter.h.
|
inlinenoexcept |
Sets the pitch shift as a frequency ratio, clamped to [0.5, 2]. Non-finite values are ignored.
Definition at line 212 of file PitchShifter.h.
|
inlinenoexcept |
Sets the pitch shift in semitones, clamped to +-12.
The active shift glides toward the target at up to 0.5 semitones per analysis hop (a few ms at the default frame size), so live changes are click-free. Non-finite values are ignored.
Definition at line 204 of file PitchShifter.h.
|
inline |
Restores parameters from a blob (tolerant; rejects foreign ids).
Definition at line 287 of file PitchShifter.h.
|
inlinenoexcept |
Enables phase reset on detected transients (default on).
Definition at line 231 of file PitchShifter.h.