feat: filter type input
This commit is contained in:
@@ -10,4 +10,5 @@ class BandPassFilter : public Filter {
|
||||
BandPassFilter(float freq, float res, float q);
|
||||
BandPassFilter(/* args */);
|
||||
~BandPassFilter();
|
||||
bool IsSameFilterType(FilterType type) override { return type == BandPass; };
|
||||
};
|
||||
|
||||
@@ -1,6 +1,12 @@
|
||||
#pragma once
|
||||
#include "Effect.h"
|
||||
|
||||
enum FilterType {
|
||||
LowPass,
|
||||
BandPass,
|
||||
HighPass
|
||||
};
|
||||
|
||||
class Filter : public Effect {
|
||||
protected:
|
||||
float m_freq; // cutoff frequency
|
||||
@@ -16,7 +22,7 @@ class Filter : public Effect {
|
||||
|
||||
public:
|
||||
Filter(/* args */);
|
||||
~Filter();
|
||||
virtual ~Filter();
|
||||
void Trigger() override;
|
||||
void Release() override;
|
||||
float Process(float in);
|
||||
@@ -25,4 +31,5 @@ class Filter : public Effect {
|
||||
float GetFreq() { return m_freq; }
|
||||
float GetRes() { return m_q; }
|
||||
float GetPeakGain() { return m_norm; }
|
||||
virtual bool IsSameFilterType(FilterType type){ return false; };
|
||||
};
|
||||
|
||||
25
inc/FilterFactory.h
Normal file
25
inc/FilterFactory.h
Normal file
@@ -0,0 +1,25 @@
|
||||
#pragma once
|
||||
#include "Filter.h"
|
||||
#include "LowPassFilter.h"
|
||||
#include "BandPassFilter.h"
|
||||
#include "HighPassFilter.h"
|
||||
|
||||
struct FilterFactory {
|
||||
static Filter* CreateFilter(Filter* oldFilter, FilterType newType) {
|
||||
Filter* newFilter;
|
||||
switch (newType) {
|
||||
case LowPass:
|
||||
newFilter = new LowPassFilter(oldFilter);
|
||||
break;
|
||||
case BandPass:
|
||||
newFilter = new BandPassFilter(oldFilter);
|
||||
break;
|
||||
case HighPass:
|
||||
newFilter = new HighPassFilter(oldFilter);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return newFilter;
|
||||
}
|
||||
};
|
||||
@@ -10,4 +10,5 @@ class HighPassFilter : public Filter {
|
||||
HighPassFilter(Filter* filter);
|
||||
HighPassFilter(float freq, float res, float q);
|
||||
~HighPassFilter();
|
||||
bool IsSameFilterType(FilterType type) override { return type == HighPass; };
|
||||
};
|
||||
|
||||
@@ -11,4 +11,5 @@ class LowPassFilter : public Filter {
|
||||
LowPassFilter(Filter* filter);
|
||||
LowPassFilter(float freq, float res, float q);
|
||||
~LowPassFilter();
|
||||
bool IsSameFilterType(FilterType type) override { return type == LowPass; };
|
||||
};
|
||||
|
||||
@@ -21,7 +21,7 @@ class Renderer {
|
||||
void draw_adsr_panel(ADSR* adsr, ADSRGuiState& gui_adsr,
|
||||
const Rectangle& panel_bounds, float panel_y_offset);
|
||||
void draw_second_panel(Rectangle& bounds);
|
||||
float draw_filter_panel(Filter* filter, FilterGuiState& gui_filter,
|
||||
float draw_filter_panel(Synth& synth, FilterGuiState& gui_filter,
|
||||
const Rectangle& panel_bounds);
|
||||
|
||||
public:
|
||||
|
||||
@@ -35,4 +35,5 @@ class Synth {
|
||||
const bool& GetIsNoteTriggered() { return is_note_triggered; }
|
||||
ADSR* GetADSR() { return (ADSR*)m_effects[0]; }
|
||||
Filter* GetFilter() { return (Filter*)m_effects[1]; }
|
||||
void SetFilter(FilterType type);
|
||||
};
|
||||
@@ -2,6 +2,7 @@
|
||||
#include "OscillatorType.h"
|
||||
#include "raygui.h"
|
||||
#include <vector>
|
||||
#include "Filter.h"
|
||||
|
||||
struct OscillatorGuiState {
|
||||
float volume;
|
||||
@@ -20,8 +21,9 @@ struct ADSRGuiState {
|
||||
|
||||
struct FilterGuiState {
|
||||
float freq;
|
||||
float res;
|
||||
//todo: type
|
||||
float res; //todo: res
|
||||
FilterType type;
|
||||
bool is_dropdown_open;
|
||||
};
|
||||
|
||||
struct SynthGuiState {
|
||||
|
||||
Reference in New Issue
Block a user