|
sfFDN
|
A ring modulator. More...
#include <nonlinear.h>
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< AudioProcessor > | Clone () 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 | |
| AudioProcessor & | operator= (const AudioProcessor &)=default |
| AudioProcessor (AudioProcessor &&) noexcept=default | |
| AudioProcessor & | operator= (AudioProcessor &&) noexcept=default |
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.
|
explicit |
Constructs a ring modulator.
| options | The configuration options. |
| std::invalid_argument | if the frequency is negative or not finite, if the amplitude is not finite, or if the initial phase is not in [0, 1]. |
|
overridevirtual |
Restores the configured initial phase.
Implements sfFDN::AudioProcessor.
|
overridevirtual |
Creates a copy of the processor.
The running modulation phase is carried over, not restarted.
Implements sfFDN::AudioProcessor.
|
overridevirtualnoexcept |
Returns the number of input channels this processor expects.
This is always 1.
Implements sfFDN::AudioProcessor.
|
overridevirtualnoexcept |
Returns the number of output channels this processor produces.
This is always 1.
Implements sfFDN::AudioProcessor.
|
overridevirtualnoexcept |
Processes the audio buffer.
Implements sfFDN::AudioProcessor.