From 00f1425f510438587cd9fb22e976401241fa048f Mon Sep 17 00:00:00 2001 From: HiveBeats Date: Sun, 10 Sep 2023 12:40:44 +0400 Subject: [PATCH] wip: filter lfo (still not worked) --- inc/LFO.h | 20 ++++++++++++++++++++ inc/Oscillator.h | 6 ++++-- src/Application.cpp | 2 +- src/Synth.cpp | 3 ++- 4 files changed, 27 insertions(+), 4 deletions(-) create mode 100644 inc/LFO.h diff --git a/inc/LFO.h b/inc/LFO.h new file mode 100644 index 0000000..d5676fe --- /dev/null +++ b/inc/LFO.h @@ -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() +{ +} diff --git a/inc/Oscillator.h b/inc/Oscillator.h index 2a3b19a..01691b9 100644 --- a/inc/Oscillator.h +++ b/inc/Oscillator.h @@ -9,9 +9,7 @@ class Oscillator { float m_key; float m_volume; float m_phase; - float m_phase_dt; float (Oscillator::*m_osc_function)(void); - float (Oscillator::*m_dt_function)(float freq); void SineOscPhaseIncr(); void SawOscPhaseIncr(); float CalcSawPhaseDelta(float freq); @@ -22,6 +20,10 @@ class Oscillator { float Sign(float v); float SineOsc(); + protected: + float m_phase_dt; + float (Oscillator::*m_dt_function)(float freq); + public: Oscillator(OscillatorType osc, float fine, float volume); ~Oscillator(); diff --git a/src/Application.cpp b/src/Application.cpp index 8edda26..7be8bc9 100644 --- a/src/Application.cpp +++ b/src/Application.cpp @@ -94,7 +94,7 @@ void Application::UpdateOnNoteInput() { if (!m_synth.GetIsNoteTriggered()) { 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()) { m_synth.Release(); } diff --git a/src/Synth.cpp b/src/Synth.cpp index 9a944ac..f10313a 100644 --- a/src/Synth.cpp +++ b/src/Synth.cpp @@ -4,9 +4,10 @@ #include "OscillatorType.h" #include "Settings.h" #include "FilterFactory.h" +#include "LFO.h" Synth::Synth(/* args */) { - m_lfo = new Oscillator(OscillatorType::Sine, 0.f, VOLUME); + m_lfo = new LFO(); AddOscillator(); AddOscillator(); AddEffect(new ADSR());