MostlyHarmless 0.0.1
 
Loading...
Searching...
No Matches
marvin::dsp::oscillators::MultiOscillator< SampleType, Bandlimit > Class Template Referencefinal

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
 

Detailed Description

template<FloatType SampleType, Bandlimiting Bandlimit = Bandlimiting::Off>
class marvin::dsp::oscillators::MultiOscillator< SampleType, Bandlimit >

A switchable multi-shape oscillator, with optional BLEP.

Member Enumeration Documentation

◆ Shape

template<FloatType SampleType, Bandlimiting Bandlimit = Bandlimiting::Off>
enum class marvin::dsp::oscillators::MultiOscillator::Shape
strong

The available shapes to set the MultiOsc to use.

Enumerator
Sine 
Triangle 
Saw 
Square 
Pulse 
Noise 

Constructor & Destructor Documentation

◆ MultiOscillator() [1/2]

template<FloatType SampleType, Bandlimiting Bandlimit = Bandlimiting::Off>
marvin::dsp::oscillators::MultiOscillator< SampleType, Bandlimit >::MultiOscillator ( std::random_device & rd)
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.

Parameters
rdThe seed generator for the internal NoiseOscillator to use.

◆ MultiOscillator() [2/2]

template<FloatType SampleType, Bandlimiting Bandlimit = Bandlimiting::Off>
marvin::dsp::oscillators::MultiOscillator< SampleType, Bandlimit >::MultiOscillator ( std::random_device & rd,
Shape shape )
explicit

Sets the current shape to the value of the shape parameter.

Parameters
rdThe seed generator for the internal NoiseOscillator to use.
shapeThe shape the MultiOscillator should be configured to use.

Member Function Documentation

◆ initialise()

template<FloatType SampleType, Bandlimiting Bandlimit = Bandlimiting::Off>
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.

Parameters
sampleRateThe sample rate the oscillator should use.

◆ operator()()

template<FloatType SampleType, Bandlimiting Bandlimit = Bandlimiting::Off>
SampleType marvin::dsp::oscillators::MultiOscillator< SampleType, Bandlimit >::operator() ( )
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.

Returns
The selected oscillator's output.

◆ reset()

template<FloatType SampleType, Bandlimiting Bandlimit = Bandlimiting::Off>
void marvin::dsp::oscillators::MultiOscillator< SampleType, Bandlimit >::reset ( )
noexcept

Resets all internal oscillators to their initial states.

◆ setFrequency()

template<FloatType SampleType, Bandlimiting Bandlimit = Bandlimiting::Off>
void marvin::dsp::oscillators::MultiOscillator< SampleType, Bandlimit >::setFrequency ( SampleType newFrequency)
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.

Parameters
newFrequencyThe frequency the MultiOscillator should process at.

◆ setPhaseOffset()

template<FloatType SampleType, Bandlimiting Bandlimit = Bandlimiting::Off>
void marvin::dsp::oscillators::MultiOscillator< SampleType, Bandlimit >::setPhaseOffset ( SampleType newPhaseOffset)
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.

Parameters
newPhaseOffsetThe phase offset to use, between 0 and 1.

◆ setPulsewidth()

template<FloatType SampleType, Bandlimiting Bandlimit = Bandlimiting::Off>
void marvin::dsp::oscillators::MultiOscillator< SampleType, Bandlimit >::setPulsewidth ( SampleType newPulsewidth)
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.

◆ setShape()

template<FloatType SampleType, Bandlimiting Bandlimit = Bandlimiting::Off>
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.

Parameters
shapeThe shape the MultiOscillator should output.

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