FahlGrahn Audio v1.0.0
Loading...
Searching...
No Matches
Biquad.h
1#pragma once
2
3#include "IFilter.h"
4#include <array>
5#include <vector>
6
7class Biquad : public IFilter
8{
9 public:
10 Biquad(IFilter::Type type, double startFreq, int order = 2);
11
12 void prepare(const double sampleRate, const int numSamples, const int numChannels) override;
13 void process(std::span<const float> input, std::span<float> output, int channel) override;
14 void reset();
15 void setAllParams(double frequency, double gaindB, double q);
16 void setFrequency(double frequency) override;
17 void setQ(double q) override;
18 void setGain(double gaindB) override;
19 void setSampleRate(double sampleRate) override;
20 double filterResponse(double sampleRate, double currentFrequency) override;
21
22 std::vector<double> getCoefficients();
23 double getFrequency()
24 {
25 return mFrequency;
26 }
27
28 double getGain()
29 {
30 return mGaindB;
31 }
32
33 double getQ()
34 {
35 return mQ;
36 }
37
38 double getSampleRate()
39 {
40 return mSampleRate;
41 }
42 Type getType() const
43 {
44 return type;
45 }
46
47 struct Coeffs
48 {
49 std::array<double, 3> a{};
50 std::array<double, 3> b{};
51 };
52
53 struct Coeffs mCoeffs;
54
55 private:
56 void updateCoefficients();
57 Type type;
58 int mFilterOrder;
59 double mSampleRate;
60 double mFrequency;
61 double mQ;
62 double mGaindB;
63 int mNumChannels;
64 int mNumSamples;
65
66 std::vector<double> xn_1;
67 std::vector<double> xn_2;
68 std::vector<double> yn_1;
69 std::vector<double> yn_2;
70};
Definition Biquad.h:8
Definition IFilter.h:7
Definition Biquad.h:48