10#ifndef DSY_OSCILLATOR_H
11#define DSY_OSCILLATOR_H
13#include "Utility/dsp.h"
50 void Init(
float sample_rate)
53 sr_recip_ = 1.0f / sample_rate;
58 phase_inc_ = CalcPhaseInc(freq_);
70 phase_inc_ = CalcPhaseInc(f);
76 inline void SetAmp(
const float a) { amp_ = a; }
81 waveform_ = wf < WAVE_LAST ? wf : WAVE_SIN;
85 inline void SetPw(
const float pw) { pw_ =
fclamp(pw, 0.0f, 1.0f); }
89 inline bool IsEOR() {
return eor_; }
93 inline bool IsEOC() {
return eoc_; }
97 inline bool IsRising() {
return phase_ < 0.5f; }
113 void Reset(
float _phase = 0.0f) { phase_ = _phase; }
116 float CalcPhaseInc(
float f);
118 float amp_, freq_, pw_;
119 float sr_, sr_recip_, phase_, phase_inc_;
120 float last_out_, last_freq_;
Definition oscillator.h:21
bool IsEOR()
Definition oscillator.h:89
void Init(float sample_rate)
Definition oscillator.h:50
void PhaseAdd(float _phase)
Definition oscillator.h:110
bool IsRising()
Definition oscillator.h:97
void SetWaveform(const uint8_t wf)
Definition oscillator.h:79
bool IsEOC()
Definition oscillator.h:93
void SetFreq(const float f)
Definition oscillator.h:67
void Reset(float _phase=0.0f)
Definition oscillator.h:113
float Process()
Definition oscillator.cpp:7
void SetPw(const float pw)
Definition oscillator.h:85
bool IsFalling()
Definition oscillator.h:101
void SetAmp(const float a)
Definition oscillator.h:76
FIR Filter implementation, generic and ARM CMSIS DSP based.
Definition adenv.h:16
float fclamp(float in, float min, float max)
Definition dsp.h:64