|
DSPark 1.6.1
Header-only audio DSP framework in pure C++20 — zero dependencies
|
Signal x carrier ring modulation with mix control and zero-latency smoothing. More...
#include <RingModulator.h>
Public Types | |
| enum class | Mode { Classic , GeometricMean } |
| Modulation mathematical mode. More... | |
Public Member Functions | |
| void | prepare (const AudioSpec &spec) noexcept |
| Prepares the modulator for audio processing. | |
| void | processBlock (AudioBufferView< T > buffer) noexcept |
| Processes a block of audio in-place. | |
| void | reset () noexcept |
| Resets the internal phase of the carrier oscillator. | |
| void | setFrequency (T hz) noexcept |
| Sets the target carrier frequency. Smoothed internally. | |
| void | setMix (T mix) noexcept |
| Sets the target dry/wet mix. Smoothed internally. | |
| void | setMode (Mode m) noexcept |
| Sets the modulation mode. | |
| void | setSoar (T amount) noexcept |
| Sets the soar threshold for Geometric Mean mode. | |
| T | getFrequency () const noexcept |
| T | getMix () const noexcept |
| Mode | getMode () const noexcept |
| T | getSoar () 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). | |
Signal x carrier ring modulation with mix control and zero-latency smoothing.
Uses a single shared carrier oscillator for all channels ensuring phase coherence. The shared carrier is precomputed serially chunk by chunk (the phase accumulator is recursive); the per-channel apply loops are branch-free and auto-vectorizable.
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 66 of file RingModulator.h.
|
strong |
Modulation mathematical mode.
| Enumerator | |
|---|---|
| Classic | Standard multiplication (sum & difference frequencies). |
| GeometricMean | Geometric-mean mode: sqrt(|in|*|carrier|) * sign - richer, more musical. |
Definition at line 70 of file RingModulator.h.
|
inlinenoexcept |
Definition at line 260 of file RingModulator.h.
|
inlinenoexcept |
Definition at line 261 of file RingModulator.h.
|
inlinenoexcept |
Definition at line 262 of file RingModulator.h.
|
inlinenoexcept |
Definition at line 263 of file RingModulator.h.
|
inline |
Serializes the parameter state (setup/UI threads; allocates).
Definition at line 266 of file RingModulator.h.
|
inlinenoexcept |
Prepares the modulator for audio processing.
Settles the parameter smoothing state on the published targets. An invalid spec (non-positive or non-finite fields) is a no-op that keeps the previous state.
| spec | Audio specification including sample rate and channels. |
Definition at line 85 of file RingModulator.h.
|
inlinenoexcept |
Processes a block of audio in-place.
| buffer | View of the audio buffer to process. |
Definition at line 104 of file RingModulator.h.
|
inlinenoexcept |
Resets the internal phase of the carrier oscillator.
Definition at line 201 of file RingModulator.h.
|
inlinenoexcept |
Sets the target carrier frequency. Smoothed internally.
| hz | Frequency in Hertz. Negative values are legal (identical spectrum, inverted carrier phase); there is no upper clamp (carriers beyond Nyquist alias by design). Non-finite values are ignored. |
Definition at line 209 of file RingModulator.h.
|
inlinenoexcept |
Sets the target dry/wet mix. Smoothed internally.
| mix | Mix value from 0.0 (100% dry) to 1.0 (100% wet), clamped. Non-finite values are ignored. |
Definition at line 220 of file RingModulator.h.
|
inlinenoexcept |
Sets the modulation mode.
Applied per block without crossfade (an instantaneous timbre change). Out-of-range values are clamped so the getter stays honest.
| m | The chosen structural mode (Classic or GeometricMean). |
Definition at line 234 of file RingModulator.h.
|
inlinenoexcept |
Sets the soar threshold for Geometric Mean mode.
Prevents cross-zero dropouts. The value is internally scaled by the input amplitude to prevent static DC offsets during silence. The floor it puts under the carrier's zero crossings turns the dropout into a small step there (the audible trade-off of filling the notch). Applied per block (not smoothed).
| amount | 0 = strict geometric mean, 0.01 = subtle, 0.1 = strong. Floored at 0; non-finite values are ignored. |
Definition at line 254 of file RingModulator.h.
|
inline |
Restores parameters from a blob (tolerant; rejects foreign ids).
Definition at line 279 of file RingModulator.h.