[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_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();
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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());
|
||||
|
||||
Reference in New Issue
Block a user