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

A pulse oscillator, with optional BLEP, and pulsewidth control. More...

#include <marvin_Oscillator.h>

Inheritance diagram for marvin::dsp::oscillators::PulseOscillator< SampleType, Blep >:
marvin::dsp::oscillators::OscillatorBase< SampleType >

Public Member Functions

 ~PulseOscillator () noexcept override=default
 
SampleType operator() () noexcept override
 
SampleType operator() (SampleType phase) noexcept override
 
void setPulsewidth (SampleType newPulsewidth) noexcept
 
- Public Member Functions inherited from marvin::dsp::oscillators::OscillatorBase< SampleType >
virtual ~OscillatorBase () noexcept=default
 
virtual void initialise (double sampleRate)
 
virtual void reset () noexcept
 
void setFrequency (SampleType newFrequency) noexcept
 
void setPhaseOffset (SampleType newPhaseOffset) noexcept
 

Additional Inherited Members

- Protected Member Functions inherited from marvin::dsp::oscillators::OscillatorBase< SampleType >
void incrementPhase () noexcept
 
- Protected Attributes inherited from marvin::dsp::oscillators::OscillatorBase< SampleType >
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) }
 

Detailed Description

template<FloatType SampleType, Bandlimiting Blep = Bandlimiting::Off>
class marvin::dsp::oscillators::PulseOscillator< SampleType, Blep >

A pulse oscillator, with optional BLEP, and pulsewidth control.

Constructor & Destructor Documentation

◆ ~PulseOscillator()

template<FloatType SampleType, Bandlimiting Blep = Bandlimiting::Off>
marvin::dsp::oscillators::PulseOscillator< SampleType, Blep >::~PulseOscillator ( )
overridedefaultnoexcept

Member Function Documentation

◆ operator()() [1/2]

template<FloatType SampleType, Bandlimiting Blep = Bandlimiting::Off>
SampleType marvin::dsp::oscillators::PulseOscillator< SampleType, Blep >::operator() ( )
nodiscardoverridevirtualnoexcept

Processes the next sample of the wave, handling phase increments internally. Make sure to call prepareToPlay and setFrequency before calling this function!

Returns
The oscillator's output.

Implements marvin::dsp::oscillators::OscillatorBase< SampleType >.

◆ operator()() [2/2]

template<FloatType SampleType, Bandlimiting Blep = Bandlimiting::Off>
SampleType marvin::dsp::oscillators::PulseOscillator< SampleType, Blep >::operator() ( SampleType phase)
nodiscardoverridevirtualnoexcept

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.

Parameters
phaseThe phase the oscillator should use, between 0 to 1.
Returns
The oscillator's output.

Implements marvin::dsp::oscillators::OscillatorBase< SampleType >.

◆ setPulsewidth()

template<FloatType SampleType, Bandlimiting Blep = Bandlimiting::Off>
void marvin::dsp::oscillators::PulseOscillator< SampleType, Blep >::setPulsewidth ( SampleType newPulsewidth)
noexcept

Sets the oscillator's pulsewidth. Note that the internal pulsewidth 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
newPulsewidthThe duration of an oscillation, between 0 and 1, that the pulse should be high for.

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