Skip to content

daisysp::Oscillator

More...

#include <oscillator.h>

Public Types

Name
enum @3

Public Functions

Name
Oscillator()
~Oscillator()
void Init(float sample_rate)
void SetFreq(const float f)
void SetAmp(const float a)
void SetWaveform(const uint8_t wf)
void SetPw(const float pw)
bool IsEOR()
bool IsEOC()
bool IsRising()
bool IsFalling()
float Process()
void PhaseAdd(float _phase)
void Reset(float _phase =0.0f)

Detailed Description

class daisysp::Oscillator;

Synthesis of several waveforms, including polyBLEP bandlimited waveforms.

Public Types Documentation

enum @3

Enumerator Value Description
WAVE_SIN
WAVE_TRI
WAVE_SAW
WAVE_RAMP
WAVE_SQUARE
WAVE_POLYBLEP_TRI
WAVE_POLYBLEP_SAW
WAVE_POLYBLEP_SQUARE
WAVE_LAST

Choices for output waveforms, POLYBLEP are appropriately labeled. Others are naive forms.

Public Functions Documentation

function Oscillator

inline Oscillator()

function ~Oscillator

inline ~Oscillator()

function Init

inline void Init(
    float sample_rate
)

Parameters:

  • sample_rate - sample rate of the audio engine being run, and the frequency that the Process function will be called.

Initializes the Oscillator

Defaults:

  • freq_ = 100 Hz
  • amp_ = 0.5
  • waveform_ = sine wave.

function SetFreq

inline void SetFreq(
    const float f
)

Changes the frequency of the Oscillator, and recalculates phase increment.


function SetAmp

inline void SetAmp(
    const float a
)

Sets the amplitude of the waveform.


function SetWaveform

inline void SetWaveform(
    const uint8_t wf
)

Sets the waveform to be synthesized by the Process() function.


function SetPw

inline void SetPw(
    const float pw
)

Sets the pulse width for WAVE_SQUARE and WAVE_POLYBLEP_SQUARE (range 0 - 1)


function IsEOR

inline bool IsEOR()

Returns true if cycle is at end of rise. Set during call to Process.


function IsEOC

inline bool IsEOC()

Returns true if cycle is at end of cycle. Set during call to Process.


function IsRising

inline bool IsRising()

Returns true if cycle rising.


function IsFalling

inline bool IsFalling()

Returns true if cycle falling.


function Process

float Process()

Processes the waveform to be generated, returning one sample. This should be called once per sample period.


function PhaseAdd

inline void PhaseAdd(
    float _phase
)

Adds a value 0.0-1.0 (equivalent to 0.0-TWO_PI) to the current phase. Useful for PM and "FM" synthesis.


function Reset

inline void Reset(
    float _phase =0.0f
)

Resets the phase to the input argument. If no argumeNt is present, it will reset phase to 0.0;

---

Updated on 2024-01-03 at 19:38:46 +0000