Audio FX
 
Loading...
Searching...
No Matches
eq.h
1#ifndef EQ_H
2#define EQ_H
3
4#include <vector>
5#include <cassert>
6#include "filters/filter.h"
7#include "filters/bell.h"
8#include "filters/hp.h"
9#include "filters/lp.h"
10#include "filters/hs.h"
11#include "filters/ls.h"
12#include "params.h"
13
27class EQ
28{
29private:
30 int sampleRate;
31 double gains[NUM_GAIN_FILTERS];
32 Biquad **filters = nullptr;
33 void addFilters();
34
35public:
36
41 EQ(int sr);
42
49 EQ(int sr, double g[], int lenG);
50
54 ~EQ();
55
60 void applyEQ(vector<vector<double>> &samples);
61
62 /* Setters */
63 void setHighPass(double cutoffFreq, double q = 0.707) { this->filters[0]->setCoefficients(cutoffFreq, q); }
64 void setLowShelf(double gain, double slope = 1.0) { this->filters[1]->setCoefficients(gain, slope); }
65 void setBell1(double gain, double bw = 0.6) { this->filters[2]->setCoefficients(gain, bw); }
66 void setBell2(double gain, double bw = 0.3) {this->filters[3]->setCoefficients(gain, bw);}
67 void setBell3(double gain, double bw = 0.4) {this->filters[4]->setCoefficients(gain, bw);}
68 void setBell4(double gain, double bw = 0.2) {this->filters[5]->setCoefficients(gain, bw);}
69 void setHighShelf(double gain, double slope = 1.0) { this->filters[6]->setCoefficients(gain, slope); }
70 void setLowPass(double cutoffFreq, double q = 0.707){this->filters[7]->setCoefficients(cutoffFreq, q);}
71
72};
73
74#endif
Represents a Biquad filter which is a type of filter.
Definition biquad.h:12
virtual void setCoefficients(double, double)=0
sets the parameters of the filter. What is being set depends on the type of filter
~EQ()
Destory filters and free memory.
EQ(int sr, double g[], int lenG)
Initialize filters for EQ giving then the corresponding gains in g.
void applyEQ(vector< vector< double > > &samples)
Apply filters to samples in a cascading fashion.
EQ(int sr)
Initialize all filters for EQ.