51 lines
1010 B
C++
51 lines
1010 B
C++
|
|
#ifndef FILTER
|
||
|
|
#define FILTER
|
||
|
|
|
||
|
|
#include <cstdint>
|
||
|
|
#include <cmath>
|
||
|
|
#include <numbers>
|
||
|
|
|
||
|
|
#include "../include/command.hpp"
|
||
|
|
|
||
|
|
class Filter{
|
||
|
|
public:
|
||
|
|
Filter(){
|
||
|
|
mode = CommandType::SetFilterOff;
|
||
|
|
|
||
|
|
cutoff = 1000.0;
|
||
|
|
resonance = 0.707;
|
||
|
|
frequency_coefficient = 0.0;
|
||
|
|
low = 0.0;
|
||
|
|
band = 0.0;
|
||
|
|
high = 0.0;
|
||
|
|
damping = 0.0;
|
||
|
|
|
||
|
|
sample_rate = 48000;
|
||
|
|
}
|
||
|
|
|
||
|
|
void set_cutoff(double value);
|
||
|
|
void set_resonance(double value);
|
||
|
|
void set_filter_off();
|
||
|
|
void set_low_pass_filter();
|
||
|
|
void set_band_pass_filter();
|
||
|
|
void set_high_pass_filter();
|
||
|
|
void update_coefficients();
|
||
|
|
|
||
|
|
double process(double input);
|
||
|
|
|
||
|
|
private:
|
||
|
|
CommandType mode;
|
||
|
|
|
||
|
|
double cutoff;
|
||
|
|
double resonance;
|
||
|
|
double frequency_coefficient;
|
||
|
|
double low;
|
||
|
|
double band;
|
||
|
|
double high;
|
||
|
|
double damping;
|
||
|
|
|
||
|
|
uint32_t sample_rate;
|
||
|
|
};
|
||
|
|
|
||
|
|
#endif
|