[refactor]: rearrange code
This commit is contained in:
@@ -30,8 +30,6 @@ class ADSR : public Effect {
|
||||
~ADSR();
|
||||
void Trigger() override;
|
||||
void Release() override;
|
||||
// void RetriggerState() override;
|
||||
void Process(std::vector<float>& samples) override;
|
||||
void Reset();
|
||||
void SetParameters(float attack, float decay, float sustain, float release);
|
||||
};
|
||||
|
||||
@@ -8,11 +8,7 @@
|
||||
struct Adder {
|
||||
static void SumOscillators(const std::vector<Oscillator*>& oscillators,
|
||||
std::vector<float>& signal) {
|
||||
size_t sample_count =
|
||||
STREAM_BUFFER_SIZE; //(size_t)(1.f/FPS * SAMPLE_RATE);
|
||||
|
||||
// std::vector<float>* output = new std::vector<float>();
|
||||
// output->reserve(sample_count);
|
||||
size_t sample_count = STREAM_BUFFER_SIZE;
|
||||
|
||||
for (size_t i = 0; i < sample_count; i++) {
|
||||
float sample = 0.0f;
|
||||
|
||||
@@ -8,6 +8,5 @@ class Effect {
|
||||
~Effect(){};
|
||||
virtual void Trigger(){};
|
||||
virtual void Release(){};
|
||||
// virtual void RetriggerState(){};
|
||||
virtual void Process(std::vector<float>& samples){};
|
||||
};
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
|
||||
class KeyBoard {
|
||||
private:
|
||||
/* data */
|
||||
static int get_semitone_shift_internal(const char* root_note,
|
||||
char* target_note) {
|
||||
const char* pitch_classes[12] = {"C", "C#", "D", "D#", "E", "F",
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
#include "cstdio"
|
||||
|
||||
#define write_log(format,args...) do { \
|
||||
printf(format, ## args); \
|
||||
} while(0)
|
||||
#define write_log(format, args...) \
|
||||
do { \
|
||||
printf(format, ##args); \
|
||||
} while (0)
|
||||
|
||||
@@ -8,8 +8,6 @@
|
||||
class Renderer {
|
||||
private:
|
||||
void draw_main_panel(const Rectangle& panel_bounds);
|
||||
void draw_add_oscillator_button(Synth& synth, SynthGuiState& synth_gui,
|
||||
Rectangle panel_bounds);
|
||||
float draw_oscillators_panels(
|
||||
const std::vector<Oscillator*>& oscillators,
|
||||
const std::vector<OscillatorGuiState*>& gui_oscillators,
|
||||
|
||||
@@ -13,14 +13,13 @@ class Synth {
|
||||
bool is_note_triggered;
|
||||
std::vector<Oscillator*> m_oscillators;
|
||||
std::vector<Effect*> m_effects;
|
||||
// OscillatorUI* ui_oscillators;
|
||||
// Note m_current_note;
|
||||
std::vector<float> m_out_signal;
|
||||
void zero_signal();
|
||||
void get_note();
|
||||
void trigger_note_on_effects();
|
||||
void untrigger_note_on_effects();
|
||||
void apply_effects();
|
||||
void add_oscillator();
|
||||
|
||||
public:
|
||||
Synth(/* args */);
|
||||
@@ -28,7 +27,6 @@ class Synth {
|
||||
void Trigger(Note input);
|
||||
void Process();
|
||||
void Release();
|
||||
void AddOscillator();
|
||||
void AddEffect(Effect* fx);
|
||||
const std::vector<float>& GetOutSignal() { return m_out_signal; }
|
||||
const std::vector<Oscillator*>& GetOscillators() { return m_oscillators; }
|
||||
|
||||
Reference in New Issue
Block a user