Base class for all single-shape oscillator types. More...
#include <marvin_Oscillator.h>
Public Member Functions | |
virtual | ~OscillatorBase () noexcept=default |
virtual void | initialise (double sampleRate) |
virtual SampleType | operator() () noexcept=0 |
virtual SampleType | operator() (SampleType phase) noexcept=0 |
virtual void | reset () noexcept |
void | setFrequency (SampleType newFrequency) noexcept |
void | setPhaseOffset (SampleType newPhaseOffset) noexcept |
Protected Member Functions | |
void | incrementPhase () noexcept |
Protected Attributes | |
double | m_sampleRate {} |
SampleType | m_phaseIncrement { static_cast<SampleType>(0.0) } |
SampleType | m_phase { static_cast<SampleType>(0.0) } |
SampleType | m_phaseOffset { static_cast<SampleType>(0.0) } |
Base class for all single-shape oscillator types.
|
virtualdefaultnoexcept |
|
protectednoexcept |
Called by subclasses to increment the internal phase according to the frequency set in setFrequency
. Unused if using an external value for phase.
|
virtual |
Initialises the oscillator. Make sure this is called before attempting any audio processing, if relying on internal phase updates!
sampleRate | The sample rate the oscillator should run at. |
|
nodiscardpure virtualnoexcept |
Processes the next sample of the wave, handling phase increments internally. Make sure to call prepareToPlay and setFrequency before calling this function!
Implemented in marvin::dsp::oscillators::NoiseOscillator< SampleType >, marvin::dsp::oscillators::PulseOscillator< SampleType, Blep >, marvin::dsp::oscillators::PulseOscillator< SampleType, Bandlimiting::Off >, marvin::dsp::oscillators::SawOscillator< SampleType, Blep >, marvin::dsp::oscillators::SawOscillator< SampleType, Bandlimiting::Off >, marvin::dsp::oscillators::SineOscillator< SampleType >, marvin::dsp::oscillators::SquareOscillator< SampleType, Blep >, marvin::dsp::oscillators::SquareOscillator< SampleType, Bandlimiting::Off >, marvin::dsp::oscillators::TriOscillator< SampleType, Blamp >, and marvin::dsp::oscillators::TriOscillator< SampleType, Bandlimiting::Off >.
|
nodiscardpure virtualnoexcept |
Processes the next sample of the wave, using the provided phase - this overload will not update the internal phase of the oscillator, so the caller is entirely responsible for incrementing the phase according to frequency, etc. Does not require you to call initialise beforehand for this reason.
phase | The phase the oscillator should use, between 0 to 1. |
Implemented in marvin::dsp::oscillators::NoiseOscillator< SampleType >, marvin::dsp::oscillators::PulseOscillator< SampleType, Blep >, marvin::dsp::oscillators::PulseOscillator< SampleType, Bandlimiting::Off >, marvin::dsp::oscillators::SawOscillator< SampleType, Blep >, marvin::dsp::oscillators::SawOscillator< SampleType, Bandlimiting::Off >, marvin::dsp::oscillators::SineOscillator< SampleType >, marvin::dsp::oscillators::SquareOscillator< SampleType, Blep >, marvin::dsp::oscillators::SquareOscillator< SampleType, Bandlimiting::Off >, marvin::dsp::oscillators::TriOscillator< SampleType, Blamp >, and marvin::dsp::oscillators::TriOscillator< SampleType, Bandlimiting::Off >.
|
virtualnoexcept |
Resets the oscillator to its default state.
|
noexcept |
Sets the frequency of the oscillator in Hz. If using the overload of operator()
that takes a value for phase, this function will do nothing. The internal phaseIncrement
variable this function sets is not atomic, so ensure this is either called on the audio thread, or the audio thread is not running when this function is called.
newFrequency | The frequency to set, in Hz |
|
noexcept |
Sets a constant value to offset the internal phase by. Useful for using one oscillator as an lfo to control multiple sources. By default, this is set to 0. If using the overload of operator()
that takes a value for phase, this function will do nothing.
newPhaseOffset | The phase offset, between 0 and 1. |
|
protected |
|
protected |
|
protected |
|
protected |