DSPark 1.6.1
Header-only audio DSP framework in pure C++20 — zero dependencies
Loading...
Searching...
No Matches
RingModulator.h File Reference

Ring modulation - multiplies the signal by an oscillator carrier. More...

#include "../Core/AudioBuffer.h"
#include "../Core/AudioSpec.h"
#include "../Core/DenormalGuard.h"
#include "../Core/DspMath.h"
#include "../Core/Phasor.h"
#include "../Core/StateBlob.h"
#include <algorithm>
#include <array>
#include <atomic>
#include <cmath>
#include <cstddef>
#include <cstdint>
#include <numbers>
#include <vector>
Include dependency graph for RingModulator.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  dspark::RingModulator< T >
 Signal x carrier ring modulation with mix control and zero-latency smoothing. More...
 

Namespaces

namespace  dspark
 Main namespace for the DSPark framework.
 

Detailed Description

Ring modulation - multiplies the signal by an oscillator carrier.

Produces sum and difference frequencies by multiplying the input signal with a sine wave carrier. Classic effect for metallic, bell-like, or robotic tones. Includes a dry/wet mix control and parameter smoothing to prevent zipper noise during real-time automation.

Threading: prepare() belongs to the setup thread; processBlock() and reset() belong to the audio thread. Setters are lock-free atomic publications, safe from any thread, consumed at the next processBlock(). Non-finite setter arguments are ignored.

Dependencies: Phasor.h, DspMath.h, AudioSpec.h, AudioBuffer.h, StateBlob.h.

ring.prepare(spec);
ring.setFrequency(440.0f); // carrier at 440 Hz
ring.setMix(1.0f); // 100% wet
// In audio callback:
ring.processBlock(buffer);
Signal x carrier ring modulation with mix control and zero-latency smoothing.
void processBlock(AudioBufferView< T > buffer) noexcept
Processes a block of audio in-place.
void setMix(T mix) noexcept
Sets the target dry/wet mix. Smoothed internally.
void prepare(const AudioSpec &spec) noexcept
Prepares the modulator for audio processing.
void setFrequency(T hz) noexcept
Sets the target carrier frequency. Smoothed internally.

Definition in file RingModulator.h.