feat: adsr gui

This commit is contained in:
2023-09-05 23:45:16 +04:00
parent a0514bad98
commit 54c4e540ac
6 changed files with 88 additions and 5 deletions

View File

@@ -33,4 +33,5 @@ class ADSR : public Effect {
// void RetriggerState() override;
void Process(std::vector<float>& samples) override;
void Reset();
void SetParameters(float attack, float decay, float sustain, float release);
};

View File

@@ -3,13 +3,14 @@
#include "SynthGuiState.h"
#include "raylib.h"
#include <vector>
#include "ADSR.h"
class Renderer {
private:
void draw_main_panel(const Rectangle& panel_bounds);
void draw_add_oscillator_button(Synth& synth, SynthGuiState& synth_gui,
Rectangle panel_bounds);
void draw_oscillators_panels(
float draw_oscillators_panels(
const std::vector<Oscillator*>& oscillators,
const std::vector<OscillatorGuiState*>& gui_oscillators,
const Rectangle& panel_bounds);
@@ -18,7 +19,7 @@ class Renderer {
const std::vector<OscillatorGuiState*>& guiOscillators);
void draw_ui(Synth& synth, SynthGuiState& synth_gui);
void draw_signal(Synth& synth, SynthGuiState& synth_gui);
void draw_adsr_panel(ADSR* adsr, ADSRGuiState& gui_adsr, const Rectangle& panel_bounds, float panel_y_offset);
public:
Renderer(/* args */);
~Renderer();

View File

@@ -6,6 +6,7 @@
#include "Oscillator.h"
#include "Settings.h"
#include <vector>
#include "ADSR.h"
class Synth {
private:
@@ -32,4 +33,5 @@ class Synth {
const std::vector<float>& GetOutSignal() { return m_out_signal; }
const std::vector<Oscillator*>& GetOscillators() { return m_oscillators; }
const bool& GetIsNoteTriggered() { return is_note_triggered; }
ADSR* GetADSR() { return (ADSR*)m_effects[0]; }
};

View File

@@ -11,6 +11,14 @@ struct OscillatorGuiState {
Rectangle shape_dropdown_rect;
};
struct ADSRGuiState {
float attack;
float decay;
float sustain;
float release;
};
struct SynthGuiState {
std::vector<OscillatorGuiState*> oscillators;
ADSRGuiState adsr;
};