iir1: iir/RBJ.h Source File

iir1

Loading...
Searching...
No Matches
RBJ.h
1
36#ifndef IIR1_RBJ_H
37#define IIR1_RBJ_H
38
39#include "Common.h"
40#include "Biquad.h"
41#include "State.h"
42
43namespace Iir {
44
59#define ONESQRT2 (1/sqrt(2))
60
61namespace RBJ {
62
66 struct IIR_EXPORT RBJbase : Biquad
67 {
68 public:
70 template <typename Sample>
71 inline Sample filter(Sample s) {
72 return static_cast<Sample>(state.filter((double)s,*this));
73 }
75 void reset() {
76 state.reset();
77 }
79 const DirectFormI& getState() {
80 return state;
81 }
82 private:
83 DirectFormI state = {};
84 };
85
89 struct IIR_EXPORT LowPass : RBJbase
90 {
96 void setupN(double cutoffFrequency,
97 double q = ONESQRT2);
98
105 void setup(double sampleRate,
106 double cutoffFrequency,
107 double q = ONESQRT2) {
108 setupN(cutoffFrequency / sampleRate, q);
109 }
110 };
111
115 struct IIR_EXPORT HighPass : RBJbase
116 {
122 void setupN(double cutoffFrequency,
123 double q = ONESQRT2);
130 void setup (double sampleRate,
131 double cutoffFrequency,
132 double q = ONESQRT2) {
133 setupN(cutoffFrequency / sampleRate, q);
134 }
135 };
136
140 struct IIR_EXPORT BandPass1 : RBJbase
141 {
147 void setupN(double centerFrequency,
148 double bandWidth);
155 void setup (double sampleRate,
156 double centerFrequency,
157 double bandWidth) {
158 setupN(centerFrequency / sampleRate, bandWidth);
159 }
160 };
161
165 struct IIR_EXPORT BandPass2 : RBJbase
166 {
172 void setupN(double centerFrequency,
173 double bandWidth);
180 void setup (double sampleRate,
181 double centerFrequency,
182 double bandWidth) {
183 setupN(centerFrequency / sampleRate, bandWidth);
184 }
185 };
186
191 struct IIR_EXPORT BandStop : RBJbase
192 {
198 void setupN(double centerFrequency,
199 double bandWidth);
206 void setup (double sampleRate,
207 double centerFrequency,
208 double bandWidth) {
209 setupN(centerFrequency / sampleRate, bandWidth);
210 }
211 };
212
224 struct IIR_EXPORT IIRNotch : RBJbase
225 {
231 void setupN(double centerFrequency,
232 double q_factor = 10);
239 void setup (double sampleRate,
240 double centerFrequency,
241 double q_factor = 10) {
242 setupN(centerFrequency / sampleRate, q_factor);
243 }
244 };
245
249 struct IIR_EXPORT LowShelf : RBJbase
250 {
257 void setupN(double cutoffFrequency,
258 double gainDb,
259 double shelfSlope = 1);
267 void setup (double sampleRate,
268 double cutoffFrequency,
269 double gainDb,
270 double shelfSlope = 1) {
271 setupN( cutoffFrequency / sampleRate, gainDb, shelfSlope);
272 }
273 };
274
278 struct IIR_EXPORT HighShelf : RBJbase
279 {
286 void setupN(double cutoffFrequency,
287 double gainDb,
288 double shelfSlope = 1);
296 void setup (double sampleRate,
297 double cutoffFrequency,
298 double gainDb,
299 double shelfSlope = 1) {
300 setupN( cutoffFrequency / sampleRate, gainDb, shelfSlope);
301 }
302 };
303
307 struct IIR_EXPORT BandShelf : RBJbase
308 {
315 void setupN(double centerFrequency,
316 double gainDb,
317 double bandWidth);
325 void setup (double sampleRate,
326 double centerFrequency,
327 double gainDb,
328 double bandWidth) {
329 setupN(centerFrequency / sampleRate, gainDb, bandWidth);
330 }
331 };
332
336 struct IIR_EXPORT AllPass : RBJbase
337 {
343 void setupN(double phaseFrequency,
344 double q = ONESQRT2);
345
352 void setup (double sampleRate,
353 double phaseFrequency,
354 double q = ONESQRT2) {
355 setupN( phaseFrequency / sampleRate, q);
356 }
357 };
358
359}
360
361}
362
363
364#endif
Iir::Biquad
Definition Biquad.h:52
Iir::DirectFormI
Definition State.h:56
Iir
Definition Biquad.cpp:40
Iir::RBJ::AllPass
Definition RBJ.h:337
Iir::RBJ::AllPass::setup
void setup(double sampleRate, double phaseFrequency, double q=(1/sqrt(2)))
Definition RBJ.h:352
Iir::RBJ::BandPass1
Definition RBJ.h:141
Iir::RBJ::BandPass1::setup
void setup(double sampleRate, double centerFrequency, double bandWidth)
Definition RBJ.h:155
Iir::RBJ::BandPass2
Definition RBJ.h:166
Iir::RBJ::BandPass2::setup
void setup(double sampleRate, double centerFrequency, double bandWidth)
Definition RBJ.h:180
Iir::RBJ::BandShelf
Definition RBJ.h:308
Iir::RBJ::BandShelf::setup
void setup(double sampleRate, double centerFrequency, double gainDb, double bandWidth)
Definition RBJ.h:325
Iir::RBJ::BandStop
Definition RBJ.h:192
Iir::RBJ::BandStop::setup
void setup(double sampleRate, double centerFrequency, double bandWidth)
Definition RBJ.h:206
Iir::RBJ::HighPass
Definition RBJ.h:116
Iir::RBJ::HighPass::setup
void setup(double sampleRate, double cutoffFrequency, double q=(1/sqrt(2)))
Definition RBJ.h:130
Iir::RBJ::HighShelf
Definition RBJ.h:279
Iir::RBJ::HighShelf::setup
void setup(double sampleRate, double cutoffFrequency, double gainDb, double shelfSlope=1)
Definition RBJ.h:296
Iir::RBJ::IIRNotch
Definition RBJ.h:225
Iir::RBJ::IIRNotch::setup
void setup(double sampleRate, double centerFrequency, double q_factor=10)
Definition RBJ.h:239
Iir::RBJ::LowPass
Definition RBJ.h:90
Iir::RBJ::LowPass::setup
void setup(double sampleRate, double cutoffFrequency, double q=(1/sqrt(2)))
Definition RBJ.h:105
Iir::RBJ::LowShelf
Definition RBJ.h:250
Iir::RBJ::LowShelf::setup
void setup(double sampleRate, double cutoffFrequency, double gainDb, double shelfSlope=1)
Definition RBJ.h:267
Iir::RBJ::RBJbase
Definition RBJ.h:67
Iir::RBJ::RBJbase::reset
void reset()
resets the delay lines to zero
Definition RBJ.h:75
Iir::RBJ::RBJbase::filter
Sample filter(Sample s)
filter operation
Definition RBJ.h:71
Iir::RBJ::RBJbase::getState
const DirectFormI & getState()
gets the delay lines (=state) of the filter
Definition RBJ.h:79