[feat]: Oscillator fine-tune #22
20
inc/LFO.h
Normal file
20
inc/LFO.h
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "Oscillator.h"
|
||||||
|
|
||||||
|
class LFO: public Oscillator
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
/* data */
|
||||||
|
public:
|
||||||
|
LFO(/* args */);
|
||||||
|
~LFO();
|
||||||
|
void SetFreq(float freq) { m_phase_dt = (this->*m_dt_function)(freq); }
|
||||||
|
};
|
||||||
|
|
||||||
|
LFO::LFO(/* args */): Oscillator(Sine, 0.f, 0.5f)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
LFO::~LFO()
|
||||||
|
{
|
||||||
|
}
|
||||||
@@ -9,9 +9,7 @@ class Oscillator {
|
|||||||
float m_key;
|
float m_key;
|
||||||
float m_volume;
|
float m_volume;
|
||||||
float m_phase;
|
float m_phase;
|
||||||
float m_phase_dt;
|
|
||||||
float (Oscillator::*m_osc_function)(void);
|
float (Oscillator::*m_osc_function)(void);
|
||||||
float (Oscillator::*m_dt_function)(float freq);
|
|
||||||
void SineOscPhaseIncr();
|
void SineOscPhaseIncr();
|
||||||
void SawOscPhaseIncr();
|
void SawOscPhaseIncr();
|
||||||
float CalcSawPhaseDelta(float freq);
|
float CalcSawPhaseDelta(float freq);
|
||||||
@@ -22,6 +20,10 @@ class Oscillator {
|
|||||||
float Sign(float v);
|
float Sign(float v);
|
||||||
float SineOsc();
|
float SineOsc();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
float m_phase_dt;
|
||||||
|
float (Oscillator::*m_dt_function)(float freq);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Oscillator(OscillatorType osc, float fine, float volume);
|
Oscillator(OscillatorType osc, float fine, float volume);
|
||||||
~Oscillator();
|
~Oscillator();
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ void Application::UpdateOnNoteInput() {
|
|||||||
if (!m_synth.GetIsNoteTriggered()) {
|
if (!m_synth.GetIsNoteTriggered()) {
|
||||||
m_synth.Trigger((*m_current_note));
|
m_synth.Trigger((*m_current_note));
|
||||||
}
|
}
|
||||||
write_log("Note played: %s\n", m_current_note->name.c_str());
|
//write_log("Note played: %s\n", m_current_note->name.c_str());
|
||||||
} else if (is_note_up() && m_synth.GetIsNoteTriggered()) {
|
} else if (is_note_up() && m_synth.GetIsNoteTriggered()) {
|
||||||
m_synth.Release();
|
m_synth.Release();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,9 +4,10 @@
|
|||||||
#include "OscillatorType.h"
|
#include "OscillatorType.h"
|
||||||
#include "Settings.h"
|
#include "Settings.h"
|
||||||
#include "FilterFactory.h"
|
#include "FilterFactory.h"
|
||||||
|
#include "LFO.h"
|
||||||
|
|
||||||
Synth::Synth(/* args */) {
|
Synth::Synth(/* args */) {
|
||||||
m_lfo = new Oscillator(OscillatorType::Sine, 0.f, VOLUME);
|
m_lfo = new LFO();
|
||||||
AddOscillator();
|
AddOscillator();
|
||||||
AddOscillator();
|
AddOscillator();
|
||||||
AddEffect(new ADSR());
|
AddEffect(new ADSR());
|
||||||
|
|||||||
Reference in New Issue
Block a user