55 lines
1.1 KiB
C++
55 lines
1.1 KiB
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.0;
|
||
|
|
update_coefficients();
|
||
|
|
}
|
||
|
|
|
||
|
|
void set_sample_rate(double sample_rate_);
|
||
|
|
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:
|
||
|
|
double max_stable_cutoff() const;
|
||
|
|
|
||
|
|
CommandType mode;
|
||
|
|
|
||
|
|
double cutoff;
|
||
|
|
double resonance;
|
||
|
|
double frequency_coefficient;
|
||
|
|
double low;
|
||
|
|
double band;
|
||
|
|
double high;
|
||
|
|
double damping;
|
||
|
|
|
||
|
|
double sample_rate;
|
||
|
|
};
|
||
|
|
|
||
|
|
#endif
|