[feat]: Oscillator fine-tune #22

Merged
e1lama merged 6 commits from feature/osc-19 into master 2023-09-16 23:26:45 +00:00
14 changed files with 170 additions and 131 deletions
Showing only changes of commit 00f1425f51 - Show all commits

20
inc/LFO.h Normal file
View 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()
{
}

View File

@@ -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();

View File

@@ -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();
}

View File

@@ -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());