A switchable multi-shape oscillator, with optional BLEP. More...
#include <marvin_Oscillator.h>
Public Types | |
enum class | Shape { Sine , Triangle , Saw , Square , Pulse , Noise } |
Public Member Functions | |
MultiOscillator (std::random_device &rd) | |
MultiOscillator (std::random_device &rd, Shape shape) | |
void | initialise (double sampleRate) |
SampleType | operator() () noexcept |
void | reset () noexcept |
void | setShape (Shape shape) |
void | setFrequency (SampleType newFrequency) noexcept |
void | setPhaseOffset (SampleType newPhaseOffset) noexcept |
void | setPulsewidth (SampleType newPulsewidth) noexcept |
A switchable multi-shape oscillator, with optional BLEP.
|
strong |
|
explicit |
As NoiseOscillator requires a std::random_device
parameter in its constructor, it's also needed here to forward to the internal instance of NoiseOscillator. Uses SHAPE::SINE
as the default shape.
rd | The seed generator for the internal NoiseOscillator to use. |
|
explicit |
Sets the current shape to the value of the shape parameter.
rd | The seed generator for the internal NoiseOscillator to use. |
shape | The shape the MultiOscillator should be configured to use. |
void marvin::dsp::oscillators::MultiOscillator< SampleType, Bandlimit >::initialise | ( | double | sampleRate | ) |
Initialises all child oscillators. Make sure to call this before any calls to the call operator.
sampleRate | The sample rate the oscillator should use. |
|
nodiscardnoexcept |
Processes a sample with the configured oscillator. As this class calls the external-phase overloads of the child oscillators and manages the phase itself, all child oscillators will share the same phase when switched.
|
noexcept |
Resets all internal oscillators to their initial states.
|
noexcept |
Sets the frequency the MultiOscillator should output. This propagates to all internal oscillators. Note that the internal phaseIncrement
variable this function sets is not atomic, so ensure this function is either called on the audio thread, or that the audio thread is not running when this function is called.
newFrequency | The frequency the MultiOscillator should process at. |
|
noexcept |
Sets a fixed phase offset for the internal phase calculation, which is set to 0 by default. This propagates to all internal oscillator types. Note that the internal phase
variable this function sets is not atomic, so ensure this function is either called on the audio thread, or that the audio thread is not running when this function is called.
newPhaseOffset | The phase offset to use, between 0 and 1. |
|
noexcept |
Sets the pulsewidth the MultiOscillator should use when configured with SHAPE::PULSE
. Note that the internal pulsewidth
variable the PulseOscillator class uses is not atomic, so ensure this function is either called on the audio thread, or that the audio thread is not running when this function is called.
void marvin::dsp::oscillators::MultiOscillator< SampleType, Bandlimit >::setShape | ( | Shape | shape | ) |
Configures the shape the MultiOscillator should output. Note that the internal shape variable is not atomic, and is read directly on the audio thread - so make sure this function is called on the audio thread, or that the audio thread is not running when this function is called.
shape | The shape the MultiOscillator should output. |