|
DSPark 1.8.0
Header-only C++20 DSP for real-time and offline audio
|
Scale-aware monophonic retune over the framework's YIN detector and phase-vocoder shifter. More...
#include <PitchCorrector.h>
Public Member Functions | |
| void | prepare (const AudioSpec &spec, int fftSize=0) |
| Allocates the detector and shifter state (setup thread). | |
| void | reset () noexcept |
| Clears all signal state and keeps the parameters (stream owner). | |
| void | setScale (std::uint16_t scaleBitmask, int rootPitchClass) noexcept |
| Selects the scale the output snaps to. | |
| void | setRetuneSpeedMs (T ms) noexcept |
| Sets the retune speed: the time constant, in milliseconds, of the glide from the sung pitch to the target note. | |
| void | setFormantPreserve (bool on) noexcept |
| Enables the shifter's cepstral formant preservation (the anti-chipmunk envelope pre-warp). Default off. | |
| std::uint16_t | getScaleMask () const noexcept |
| int | getRootPitchClass () const noexcept |
| T | getRetuneSpeedMs () const noexcept |
| bool | getFormantPreserve () const noexcept |
| 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). A missing field restores its default: chromatic from C, hard snap, formants off. | |
| int | getLatency () const noexcept |
| Reports the signal latency in samples: twice the analysis frame, which is 4096 samples at 44.1/48 kHz and about 85 ms at every supported rate, since the frame follows the rate. Zero before prepare(). | |
| int | getFrameSize () const noexcept |
| The analysis frame in effect, in samples: the automatic choice for this rate, or the rounded explicit request. Zero before prepare(). | |
| void | processBlock (AudioBufferView< T > buffer) noexcept |
| Processes audio in-place. Pass-through until prepare() succeeds. | |
Scale-aware monophonic retune over the framework's YIN detector and phase-vocoder shifter.
| T | Sample type (float or double). |
Definition at line 252 of file PitchCorrector.h.
|
inlinenoexcept |
Definition at line 397 of file PitchCorrector.h.
|
inlinenoexcept |
The analysis frame in effect, in samples: the automatic choice for this rate, or the rounded explicit request. Zero before prepare().
Definition at line 437 of file PitchCorrector.h.
|
inlinenoexcept |
Reports the signal latency in samples: twice the analysis frame, which is 4096 samples at 44.1/48 kHz and about 85 ms at every supported rate, since the frame follows the rate. Zero before prepare().
Definition at line 430 of file PitchCorrector.h.
|
inlinenoexcept |
Definition at line 391 of file PitchCorrector.h.
|
inlinenoexcept |
Definition at line 384 of file PitchCorrector.h.
|
inlinenoexcept |
Definition at line 377 of file PitchCorrector.h.
|
inline |
Serializes the parameter state (setup/UI threads; allocates).
Definition at line 403 of file PitchCorrector.h.
|
inline |
Allocates the detector and shifter state (setup thread).
Invalid specifications and non-finite sample rates are ignored and the previous state is kept; an unprepared instance passes audio through untouched. The detector uses its own automatic window policy, which holds its analysis span constant across rates; the shifter's frame follows the policy documented above.
| spec | Audio environment specification. |
| fftSize | Analysis frame for the internal shifter. Values <= 0 (the default) select the AUTOMATIC frame: the smallest power of two in [512, 32768] spanning at least 2048/48000 s (42.7 ms) at this rate - 2048 at 44.1/48 kHz, 4096 at 88.2/96 kHz, 8192 at 176.4/192 kHz. Read it back with getFrameSize(). An explicit request is rounded up to a power of two and clamped to [256, 1 << 20]; going below the automatic value buys settling time and costs the low register, in the proportions the frame note above states. |
Definition at line 284 of file PitchCorrector.h.
|
inlinenoexcept |
Processes audio in-place. Pass-through until prepare() succeeds.
Channels beyond the prepared count are left untouched, as in the shifter. Detection reads channel 0; every processed channel receives the same correction.
| buffer | Audio block. |
Definition at line 453 of file PitchCorrector.h.
|
inlinenoexcept |
Clears all signal state and keeps the parameters (stream owner).
The applied correction restarts at zero: a fresh stream has no note history worth continuing to correct.
Definition at line 314 of file PitchCorrector.h.
|
inlinenoexcept |
Enables the shifter's cepstral formant preservation (the anti-chipmunk envelope pre-warp). Default off.
Definition at line 371 of file PitchCorrector.h.
|
inlinenoexcept |
Sets the retune speed: the time constant, in milliseconds, of the glide from the sung pitch to the target note.
0 selects the hard snap (the full correction at once, quantized character). Values are clamped to [0, 10000]; non-finite values are ignored.
Definition at line 362 of file PitchCorrector.h.
|
inlinenoexcept |
Selects the scale the output snaps to.
| scaleBitmask | 12-bit harmony::NoteSet: bit k is the scale degree k semitones above the root (the harmony::allScales layout). Bits above the low 12 are ignored, and an empty mask disables correction. |
| rootPitchClass | Root as semitones above C; any integer folds into 0..11. |
Definition at line 341 of file PitchCorrector.h.
|
inline |
Restores parameters from a blob (tolerant; rejects foreign ids). A missing field restores its default: chromatic from C, hard snap, formants off.
Definition at line 416 of file PitchCorrector.h.