|
DSPark 1.6.1
Header-only audio DSP framework in pure C++20 — zero dependencies
|
Constant-Hz frequency shift optimized via Quadrature Oscillator. More...
#include <FrequencyShifter.h>
Public Member Functions | |
| void | prepare (const AudioSpec &spec) |
| Prepares the frequency shifter state and allocates internal buffers. | |
| void | processBlock (AudioBufferView< T > buffer) noexcept |
| Processes audio in-place applying the frequency shift. | |
| void | reset () noexcept |
| Resets internal filter states and phase accumulator. | |
| void | setShift (T hz) noexcept |
| Sets the frequency shift amount in Hz. | |
| void | setMix (T mix) noexcept |
| Sets the dry/wet mix. Smoothed internally. | |
| T | getShift () const noexcept |
| T | getMix () 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). | |
Static Public Member Functions | |
| static constexpr int | getLatency () noexcept |
| Reports the processing latency in samples. | |
Constant-Hz frequency shift optimized via Quadrature Oscillator.
Uses a recursive rotation matrix to generate the complex carrier, avoiding expensive per-sample trigonometric calls; the oscillator state is re-anchored from the double-precision phase accumulator at every block, so rounding drift never accumulates past one block.
Channels beyond those passed to prepare() are left untouched (pass-through), as is the whole buffer before prepare().
| T | Sample type (float or double). |
Definition at line 61 of file FrequencyShifter.h.
|
inlinestaticconstexprnoexcept |
Reports the processing latency in samples.
The Hilbert transformer delays BOTH the dry (real branch) and shifted paths by its FIR group delay; report this for plugin delay compensation.
Definition at line 217 of file FrequencyShifter.h.
|
inlinenoexcept |
Definition at line 209 of file FrequencyShifter.h.
|
inlinenoexcept |
Definition at line 206 of file FrequencyShifter.h.
|
inline |
Serializes the parameter state (setup/UI threads; allocates).
Definition at line 223 of file FrequencyShifter.h.
|
inline |
Prepares the frequency shifter state and allocates internal buffers.
Settles the mix smoothing state on the published target. An invalid spec (non-positive or non-finite fields) is a no-op that keeps the previous state.
| spec | Audio environment specification (sample rate, num channels). |
Definition at line 73 of file FrequencyShifter.h.
|
inlinenoexcept |
Processes audio in-place applying the frequency shift.
| buffer | Audio data view. |
Definition at line 94 of file FrequencyShifter.h.
|
inlinenoexcept |
Resets internal filter states and phase accumulator.
Definition at line 173 of file FrequencyShifter.h.
|
inlinenoexcept |
Sets the dry/wet mix. Smoothed internally.
| mix | Range [0.0, 1.0], clamped. 0.0 = pure dry (phase-aligned), 1.0 = fully shifted. Non-finite values are ignored. |
Definition at line 199 of file FrequencyShifter.h.
|
inlinenoexcept |
Sets the frequency shift amount in Hz.
| hz | Shift in Hz (negative shifts frequencies down). There is no range clamp: carriers beyond Nyquist alias by design. Non-finite values are ignored (a NaN here would poison the phase accumulator permanently). |
Definition at line 188 of file FrequencyShifter.h.
|
inline |
Restores parameters from a blob (tolerant; rejects foreign ids).
Definition at line 234 of file FrequencyShifter.h.