OpenWareLaboratory
MorphingOscillator Class Reference

The MorphingOscillator wraps a fixed number of Oscillators and crossfades between their outputs. More...

Inheritance diagram for MorphingOscillator:
Collaboration diagram for MorphingOscillator:

Public Member Functions

float generate ()
 Produce the next consecutive sample. More...
 
float generate (float fm)
 Produce a sample with frequency modulation. More...
 
void generate (FloatArray output)
 Produce a block of samples. More...
 
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)
 
size_t getNumberOfOscillators ()
 
OscillatorgetOscillator (size_t index)
 
float getPhase ()
 Get current oscillator phase in radians. More...
 
void getSamples (FloatArray output)
 
void getSamples (FloatArray output, FloatArray fm)
 
void morph (float value)
 Morph between all configured oscillators. More...
 
 MorphingOscillator (Oscillator **osc, size_t count, FloatArray buffer)
 
void reset ()
 Reset oscillator (typically resets phase) More...
 
void setFrequency (float value)
 Set oscillator frequency in Hertz. More...
 
void setOscillator (size_t index, Oscillator *oscillator)
 
void setPhase (float value)
 Set current oscillator phase in radians. More...
 
virtual void setSampleRate (float value)
 Set oscillator sample rate. More...
 

Static Public Member Functions

static MorphingOscillatorcreate (size_t oscillator_count, size_t blocksize)
 
static void destroy (MorphingOscillator *obj)
 

Protected Attributes

FloatArray buffer
 
Oscillatorhi = NULL
 
Oscillatorlo = NULL
 
Oscillator ** osc
 
size_t osc_count
 
float xf = 0
 

Detailed Description

The MorphingOscillator wraps a fixed number of Oscillators and crossfades between their outputs.

Only two oscillator outputs are computed at a time. When changing between crossfading oscillators, their phases are synchronised.

Definition at line 12 of file MorphingOscillator.h.

Constructor & Destructor Documentation

◆ MorphingOscillator()

MorphingOscillator::MorphingOscillator ( Oscillator **  osc,
size_t  count,
FloatArray  buffer 
)
inline

Definition at line 21 of file MorphingOscillator.h.

Referenced by create().

Member Function Documentation

◆ create()

static MorphingOscillator* MorphingOscillator::create ( size_t  oscillator_count,
size_t  blocksize 
)
inlinestatic

Definition at line 97 of file MorphingOscillator.h.

References FloatArray::create(), and MorphingOscillator().

◆ destroy()

static void MorphingOscillator::destroy ( MorphingOscillator obj)
inlinestatic

Definition at line 101 of file MorphingOscillator.h.

References buffer, FloatArray::destroy(), and osc.

◆ generate() [1/4]

float MorphingOscillator::generate ( )
inlinevirtual

Produce the next consecutive sample.

Reimplemented from SignalGenerator.

Definition at line 41 of file MorphingOscillator.h.

References Oscillator::generate(), hi, lo, and xf.

◆ generate() [2/4]

float MorphingOscillator::generate ( float  fm)
inlinevirtual

Produce a sample with frequency modulation.

Implements Oscillator.

Definition at line 46 of file MorphingOscillator.h.

References Oscillator::generate(), hi, lo, and xf.

◆ generate() [3/4]

void MorphingOscillator::generate ( FloatArray  output)
inlinevirtual

Produce a block of samples.

Reimplemented from SignalGenerator.

Definition at line 51 of file MorphingOscillator.h.

References FloatArray::add(), buffer, Oscillator::generate(), hi, lo, FloatArray::multiply(), and xf.

◆ generate() [4/4]

void MorphingOscillator::generate ( FloatArray  output,
FloatArray  fm 
)
inlinevirtual

Produce a block of samples with frequency modulation.

Reimplemented from Oscillator.

Definition at line 58 of file MorphingOscillator.h.

References FloatArray::add(), buffer, Oscillator::generate(), hi, lo, FloatArray::multiply(), and xf.

◆ getFrequency()

float MorphingOscillator::getFrequency ( )
inlinevirtual

Get oscillator frequency in Hertz.

Implements Oscillator.

Definition at line 27 of file MorphingOscillator.h.

References Oscillator::getFrequency(), and lo.

Referenced by morph().

◆ 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().

◆ getNumberOfOscillators()

size_t MorphingOscillator::getNumberOfOscillators ( )
inline

Definition at line 86 of file MorphingOscillator.h.

References osc_count.

◆ getOscillator()

Oscillator* MorphingOscillator::getOscillator ( size_t  index)
inline

Definition at line 89 of file MorphingOscillator.h.

References osc.

◆ getPhase()

float MorphingOscillator::getPhase ( )
inlinevirtual

Get current oscillator phase in radians.

Returns
a value between 0 and 2*pi

Implements Oscillator.

Definition at line 34 of file MorphingOscillator.h.

References Oscillator::getPhase(), and lo.

Referenced by morph().

◆ 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().

◆ morph()

void MorphingOscillator::morph ( float  value)
inline

Morph between all configured oscillators.

Parameters
valuea cross fade index between 0 and 1.

Definition at line 69 of file MorphingOscillator.h.

References clamp, getFrequency(), getPhase(), hi, lo, osc, osc_count, Oscillator::setFrequency(), Oscillator::setPhase(), and xf.

◆ reset()

void MorphingOscillator::reset ( )
inlinevirtual

Reset oscillator (typically resets phase)

Implements Oscillator.

Definition at line 37 of file MorphingOscillator.h.

References hi, lo, and Oscillator::reset().

◆ setFrequency()

void MorphingOscillator::setFrequency ( float  value)
inlinevirtual

Set oscillator frequency in Hertz.

Implements Oscillator.

Definition at line 23 of file MorphingOscillator.h.

References hi, lo, and Oscillator::setFrequency().

◆ setOscillator()

void MorphingOscillator::setOscillator ( size_t  index,
Oscillator oscillator 
)
inline

Definition at line 92 of file MorphingOscillator.h.

References hi, lo, and osc.

◆ setPhase()

void MorphingOscillator::setPhase ( float  phase)
inlinevirtual

Set current oscillator phase in radians.

Parameters
phasea value between 0 and 2*pi

Implements Oscillator.

Definition at line 30 of file MorphingOscillator.h.

References hi, lo, and Oscillator::setPhase().

◆ setSampleRate()

Field Documentation

◆ buffer

FloatArray MorphingOscillator::buffer
protected

Definition at line 16 of file MorphingOscillator.h.

Referenced by destroy(), and generate().

◆ hi

Oscillator* MorphingOscillator::hi = NULL
protected

Definition at line 18 of file MorphingOscillator.h.

Referenced by generate(), morph(), reset(), setFrequency(), setOscillator(), and setPhase().

◆ lo

Oscillator* MorphingOscillator::lo = NULL
protected

◆ osc

Oscillator** MorphingOscillator::osc
protected

Definition at line 14 of file MorphingOscillator.h.

Referenced by destroy(), getOscillator(), morph(), and setOscillator().

◆ osc_count

size_t MorphingOscillator::osc_count
protected

Definition at line 15 of file MorphingOscillator.h.

Referenced by getNumberOfOscillators(), and morph().

◆ xf

float MorphingOscillator::xf = 0
protected

Definition at line 19 of file MorphingOscillator.h.

Referenced by generate(), and morph().


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