OpenWareLaboratory
SquareWaveOscillator Class Reference
Inheritance diagram for SquareWaveOscillator:
Collaboration diagram for SquareWaveOscillator:

Public Member Functions

float generate ()
 Produce the next consecutive sample. More...
 
float generate (float fm)
 Produce a sample with frequency modulation. More...
 
virtual void generate (FloatArray output)
 Produce a block of samples. More...
 
virtual void generate (FloatArray output, FloatArray fm)
 Produce a block of samples with frequency modulation. More...
 
float getFrequency ()
 Get oscillator frequency in Hertz. More...
 
float getNextSample ()
 
float getNextSample (float fm)
 
float getPhase ()
 Get current oscillator phase in radians. More...
 
float getSample ()
 
float getSampleRate ()
 
void getSamples (FloatArray output)
 
void getSamples (FloatArray output, FloatArray fm)
 
void reset ()
 Reset oscillator (typically resets phase) More...
 
void setFrequency (float freq)
 Set oscillator frequency in Hertz. More...
 
void setPhase (float ph)
 Set current oscillator phase in radians. More...
 
void setPulseWidth (float value)
 Set pulse width to a value between 0 and 1. More...
 
void setSampleRate (float sr)
 Set oscillator sample rate. More...
 
 SquareWaveOscillator ()
 
 SquareWaveOscillator (float sr)
 

Static Public Member Functions

static SquareWaveOscillatorcreate (float sr)
 
static void destroy (SquareWaveOscillator *osc)
 

Static Public Attributes

static constexpr float begin_phase = 0
 
static constexpr float end_phase = 1
 

Static Protected Member Functions

static float polyblep (float t, float dt)
 Calculate poly blep antialiasing compensation on normalised (to range [0, 1]) phase and phase increment (angular rate) values. More...
 

Protected Attributes

float incr
 
float mul
 
float phase
 
float pw = 0.5
 

Detailed Description

Definition at line 6 of file SquareWaveOscillator.h.

Constructor & Destructor Documentation

◆ SquareWaveOscillator() [1/2]

SquareWaveOscillator::SquareWaveOscillator ( )
inline

Definition at line 12 of file SquareWaveOscillator.h.

◆ SquareWaveOscillator() [2/2]

SquareWaveOscillator::SquareWaveOscillator ( float  sr)
inline

Member Function Documentation

◆ create()

static SquareWaveOscillator * OscillatorTemplate< SquareWaveOscillator , Oscillator , float >::create ( float  sr)
inlinestaticinherited

Definition at line 115 of file Oscillator.h.

◆ destroy()

static void OscillatorTemplate< SquareWaveOscillator , Oscillator , float >::destroy ( SquareWaveOscillator osc)
inlinestaticinherited

Definition at line 120 of file Oscillator.h.

◆ generate() [1/4]

float OscillatorTemplate< SquareWaveOscillator , Oscillator , float >::generate ( )
inlinevirtualinherited

Produce the next consecutive sample.

Reimplemented from Oscillator.

Definition at line 99 of file Oscillator.h.

◆ generate() [2/4]

float OscillatorTemplate< SquareWaveOscillator , Oscillator , float >::generate ( float  fm)
inlinevirtualinherited

Produce a sample with frequency modulation.

Implements Oscillator.

Definition at line 106 of file Oscillator.h.

◆ generate() [3/4]

◆ generate() [4/4]

virtual void Oscillator::generate ( FloatArray  output,
FloatArray  fm 
)
inlinevirtualinherited

Produce a block of samples with frequency modulation.

Reimplemented in VosimOscillator, SineOscillator, SampleOscillator< im >, PolyBlepOscillator, and MorphingOscillator.

Definition at line 50 of file Oscillator.h.

References Oscillator::generate(), and SimpleArray< T >::getSize().

◆ getFrequency()

float OscillatorTemplate< SquareWaveOscillator , Oscillator , float >::getFrequency ( )
inlinevirtualinherited

Get oscillator frequency in Hertz.

Implements Oscillator.

Definition at line 86 of file Oscillator.h.

◆ getNextSample() [1/2]

float Oscillator::getNextSample ( )
inlineinherited

Definition at line 55 of file Oscillator.h.

References Oscillator::generate().

◆ getNextSample() [2/2]

float Oscillator::getNextSample ( float  fm)
inlineinherited

Definition at line 57 of file Oscillator.h.

References Oscillator::generate().

◆ getPhase()

float OscillatorTemplate< SquareWaveOscillator , Oscillator , float >::getPhase ( )
inlinevirtualinherited

Get current oscillator phase in radians.

Returns
a value between 0 and 2*pi

Implements Oscillator.

Definition at line 92 of file Oscillator.h.

◆ getSample()

float SquareWaveOscillator::getSample ( )
inline

Definition at line 22 of file SquareWaveOscillator.h.

References OscillatorTemplate< SquareWaveOscillator >::phase, and pw.

◆ getSampleRate()

float OscillatorTemplate< SquareWaveOscillator , Oscillator , float >::getSampleRate ( )
inlineinherited

Definition at line 80 of file Oscillator.h.

◆ getSamples() [1/2]

void Oscillator::getSamples ( FloatArray  output)
inlineinherited

Definition at line 59 of file Oscillator.h.

References Oscillator::generate().

◆ getSamples() [2/2]

void Oscillator::getSamples ( FloatArray  output,
FloatArray  fm 
)
inlineinherited

Definition at line 63 of file Oscillator.h.

References Oscillator::generate().

◆ polyblep()

static float OscillatorTemplate< SquareWaveOscillator , Oscillator , float >::polyblep ( float  t,
float  dt 
)
inlinestaticprotectedinherited

Calculate poly blep antialiasing compensation on normalised (to range [0, 1]) phase and phase increment (angular rate) values.

Definition at line 128 of file Oscillator.h.

◆ reset()

void OscillatorTemplate< SquareWaveOscillator , Oscillator , float >::reset ( )
inlinevirtualinherited

Reset oscillator (typically resets phase)

Implements Oscillator.

Definition at line 96 of file Oscillator.h.

◆ setFrequency()

void OscillatorTemplate< SquareWaveOscillator , Oscillator , float >::setFrequency ( float  freq)
inlinevirtualinherited

Set oscillator frequency in Hertz.

Implements Oscillator.

Definition at line 83 of file Oscillator.h.

◆ setPhase()

void OscillatorTemplate< SquareWaveOscillator , Oscillator , float >::setPhase ( float  ph)
inlinevirtualinherited

Set current oscillator phase in radians.

Parameters
phasea value between 0 and 2*pi

Implements Oscillator.

Definition at line 89 of file Oscillator.h.

◆ setPulseWidth()

void SquareWaveOscillator::setPulseWidth ( float  value)
inline

Set pulse width to a value between 0 and 1.

Definition at line 19 of file SquareWaveOscillator.h.

References pw.

◆ setSampleRate()

void OscillatorTemplate< SquareWaveOscillator , Oscillator , float >::setSampleRate ( float  sr)
inlinevirtualinherited

Set oscillator sample rate.

Reimplemented from Oscillator.

Definition at line 75 of file Oscillator.h.

Field Documentation

◆ begin_phase

constexpr float SquareWaveOscillator::begin_phase = 0
staticconstexpr

Definition at line 10 of file SquareWaveOscillator.h.

◆ end_phase

constexpr float SquareWaveOscillator::end_phase = 1
staticconstexpr

Definition at line 11 of file SquareWaveOscillator.h.

◆ incr

float OscillatorTemplate< SquareWaveOscillator , Oscillator , float >::incr
protectedinherited

Definition at line 73 of file Oscillator.h.

◆ mul

float OscillatorTemplate< SquareWaveOscillator , Oscillator , float >::mul
protectedinherited

Definition at line 71 of file Oscillator.h.

◆ phase

float OscillatorTemplate< SquareWaveOscillator , Oscillator , float >::phase
protectedinherited

Definition at line 72 of file Oscillator.h.

◆ pw

float SquareWaveOscillator::pw = 0.5
protected

Definition at line 8 of file SquareWaveOscillator.h.

Referenced by getSample(), and setPulseWidth().


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