sfFDN
Loading...
Searching...
No Matches
sfFDN::RingModulator Class Reference

A ring modulator. More...

#include <nonlinear.h>

Inheritance diagram for sfFDN::RingModulator:
[legend]
Collaboration diagram for sfFDN::RingModulator:
[legend]

Public Member Functions

 RingModulator (const RingModulatorOptions &options={})
 Constructs a ring modulator.
 
float GetFrequency () const noexcept SFFDN_NONBLOCKING
 Returns the modulation frequency, in cycles per sample.
 
float GetAmplitude () const noexcept SFFDN_NONBLOCKING
 Returns the linear gain applied to the modulating sinusoid.
 
float Tick (float input) noexcept SFFDN_NONBLOCKING
 Processes a single sample.
 
void Process (const AudioBuffer &input, AudioBuffer &output) noexcept SFFDN_NONBLOCKING override
 Processes the audio buffer.
 
uint32_t InputChannelCount () const noexcept SFFDN_NONBLOCKING override
 Returns the number of input channels this processor expects.
 
uint32_t OutputChannelCount () const noexcept SFFDN_NONBLOCKING override
 Returns the number of output channels this processor produces.
 
void Clear () override
 Restores the configured initial phase.
 
std::unique_ptr< AudioProcessorClone () const override
 Creates a copy of the processor.
 
- Public Member Functions inherited from sfFDN::AudioProcessor

Additional Inherited Members

- Protected Member Functions inherited from sfFDN::AudioProcessor
 AudioProcessor (const AudioProcessor &)=default
 
AudioProcessoroperator= (const AudioProcessor &)=default
 
 AudioProcessor (AudioProcessor &&) noexcept=default
 
AudioProcessoroperator= (AudioProcessor &&) noexcept=default
 

Detailed Description

A ring modulator.

Implements equation (5) of the paper:

\[ y(n) = g_\mathrm{rm}\, x(n) \sin(2 \pi f_\mathrm{rm} n). \]

The multiplication replaces the spectrum of the input with two sidebands, shifted by \(\pm f_\mathrm{rm}\). Below about 20 Hz the effect is heard as a tremolo, and above it as a change of timbre: harmonic when the modulation frequency is an integer ratio of the input, and bell-like or metallic otherwise.

The average power of a unit-amplitude sinusoid is one half, so the default amplitude of \(\sqrt{2}\) makes the operation energy preserving on average. That is an average over a modulation period, not a bound: the instantaneous gain still reaches \(\sqrt{2}\) at the peaks of the modulator. In a network with short, strongly recirculating delay lines, or with a diagonally dominant feedback matrix, several channels can peak together for long enough to make the energy grow. Lower the amplitude if that happens.

Constructor & Destructor Documentation

◆ RingModulator()

sfFDN::RingModulator::RingModulator ( const RingModulatorOptions & options = {})
explicit

Constructs a ring modulator.

Parameters
optionsThe configuration options.
Exceptions
std::invalid_argumentif the frequency is negative or not finite, if the amplitude is not finite, or if the initial phase is not in [0, 1].

Member Function Documentation

◆ Clear()

void sfFDN::RingModulator::Clear ( )
overridevirtual

Restores the configured initial phase.

Implements sfFDN::AudioProcessor.

◆ Clone()

std::unique_ptr< AudioProcessor > sfFDN::RingModulator::Clone ( ) const
overridevirtual

Creates a copy of the processor.

The running modulation phase is carried over, not restarted.

Implements sfFDN::AudioProcessor.

◆ InputChannelCount()

uint32_t sfFDN::RingModulator::InputChannelCount ( ) const
overridevirtualnoexcept

Returns the number of input channels this processor expects.

This is always 1.

Implements sfFDN::AudioProcessor.

◆ OutputChannelCount()

uint32_t sfFDN::RingModulator::OutputChannelCount ( ) const
overridevirtualnoexcept

Returns the number of output channels this processor produces.

This is always 1.

Implements sfFDN::AudioProcessor.

◆ Process()

void sfFDN::RingModulator::Process ( const AudioBuffer & input,
AudioBuffer & output )
overridevirtualnoexcept

Processes the audio buffer.

Note
The input and output buffers must have one channel and the same number of samples.

Implements sfFDN::AudioProcessor.


The documentation for this class was generated from the following file: