FahlGrahn Audio v1.0.0
Loading...
Searching...
No Matches
Filter.h
1#pragma once
2
3// #include "Biquad.h"
4#include <IFilter.h>
5#include <memory>
6#include <optional>
7#include <span>
8#include <vector>
9
10class Filter
11{
12 public:
13 enum Type
14 {
15 kHighPass,
16 kLowPass,
17 kLowShelf,
18 kHighShelf,
19 kPeak,
20 kNumTypes
21 };
22
23 enum Order
24 {
25 k6dBSlope,
26 k12dBSlope,
27 k18dBSlope,
28 k24dbSlope,
29 };
30
31 template <int FilterOrder = 2>
32 static std::unique_ptr<Filter> createFilterInstance(Type filterType, double startFrequency)
33 {
34 switch (FilterOrder)
35 {
36 case 1:
37 break;
38 case 2:
39 break;
40 case 3:
41 break;
42 case 4:
43 break;
44
45 default:
46 // assert here for invalid filter order
47 break;
48 }
49
50 return std::unique_ptr<Filter>(new Filter(filterType, startFrequency));
51 }
52
53 void prepare(double sampleRate, int numSamples, int numChannels);
54 void setFrequency(double frequency);
55 void setGain(double gain);
56 void setQ(double q);
57 void setFilterOrder(Order filterOrder);
58 void setSampleRate(double sampleRate);
59 double filterResponse(double sampleRate, double x);
60 Type getType() const
61 {
62 return mFilterType;
63 }
64
65 void process(std::span<const float> input, std::span<float> output, int channel);
66
67 protected:
68 private:
69 Filter(Type filterType, double startFrequency);
70 Type mFilterType;
71 std::vector<std::unique_ptr<IFilter>> mFilters;
72};
Definition Filter.h:11