iir1

ChebyshevII.h
1
36 #ifndef IIR1_CHEBYSHEVII_H
37 #define IIR1_CHEBYSHEVII_H
38
39 #include "Common.h"
40 #include "Cascade.h"
41 #include "PoleFilter.h"
42 #include "State.h"
43
44 namespace Iir {
45
53 namespace ChebyshevII {
54
58 class IIR_EXPORT AnalogLowPass : public LayoutBase
59 {
60 public:
61 AnalogLowPass ();
62
63 void design (const int numPoles,
64 double stopBandDb);
65
66 private:
67 int m_numPoles = 0;
68 double m_stopBandDb = 0.0;
69 };
70
71
75 class IIR_EXPORT AnalogLowShelf : public LayoutBase
76 {
77 public:
78 AnalogLowShelf ();
79
80 void design (int numPoles,
81 double gainDb,
82 double stopBandDb);
83
84 private:
85 int m_numPoles = 0;
86 double m_stopBandDb = 0.0;
87 double m_gainDb = 0.0;
88 };
89
90 //------------------------------------------------------------------------------
91
92 struct IIR_EXPORT LowPassBase : PoleFilterBase <AnalogLowPass>
93 {
94 void setup (int order,
95 double cutoffFrequency,
96 double stopBandDb);
97 };
98
99 struct IIR_EXPORT HighPassBase : PoleFilterBase <AnalogLowPass>
100 {
101 void setup (int order,
102 double cutoffFrequency,
103 double stopBandDb);
104 };
105
106 struct IIR_EXPORT BandPassBase : PoleFilterBase <AnalogLowPass>
107 {
108 void setup (int order,
109 double centerFrequency,
110 double widthFrequency,
111 double stopBandDb);
112 };
113
114 struct IIR_EXPORT BandStopBase : PoleFilterBase <AnalogLowPass>
115 {
116 void setup (int order,
117 double centerFrequency,
118 double widthFrequency,
119 double stopBandDb);
120 };
121
122 struct IIR_EXPORT LowShelfBase : PoleFilterBase <AnalogLowShelf>
123 {
124 void setup (int order,
125 double cutoffFrequency,
126 double gainDb,
127 double stopBandDb);
128 };
129
130 struct IIR_EXPORT HighShelfBase : PoleFilterBase <AnalogLowShelf>
131 {
132 void setup (int order,
133 double cutoffFrequency,
134 double gainDb,
135 double stopBandDb);
136 };
137
138 struct IIR_EXPORT BandShelfBase : PoleFilterBase <AnalogLowShelf>
139 {
140 void setup (int order,
141 double centerFrequency,
142 double widthFrequency,
143 double gainDb,
144 double stopBandDb);
145 };
146
147 //------------------------------------------------------------------------------
148
149 //
150 // Userland filters
151 //
152
158 template <int FilterOrder = DEFAULT_FILTER_ORDER, class StateType = DEFAULT_STATE>
159 struct LowPass : PoleFilter <LowPassBase, StateType, FilterOrder>
160 {
167 void setup (double sampleRate,
168 double cutoffFrequency,
169 double stopBandDb) {
170 LowPassBase::setup (FilterOrder,
171 cutoffFrequency / sampleRate,
172 stopBandDb);
173 }
174
182 void setup (int reqOrder,
183 double sampleRate,
184 double cutoffFrequency,
185 double stopBandDb) {
186 if (reqOrder > FilterOrder) throw_invalid_argument(orderTooHigh);
187 LowPassBase::setup (reqOrder,
188 cutoffFrequency / sampleRate,
189 stopBandDb);
190 }
191
192
193
194
195
201 void setupN(double cutoffFrequency,
202 double stopBandDb) {
203 LowPassBase::setup (FilterOrder,
204 cutoffFrequency,
205 stopBandDb);
206 }
207
214 void setupN(int reqOrder,
215 double cutoffFrequency,
216 double stopBandDb) {
217 if (reqOrder > FilterOrder) throw_invalid_argument(orderTooHigh);
218 LowPassBase::setup (reqOrder,
219 cutoffFrequency,
220 stopBandDb);
221 }
222
223 };
224
230 template <int FilterOrder = DEFAULT_FILTER_ORDER, class StateType = DEFAULT_STATE>
231 struct HighPass : PoleFilter <HighPassBase, StateType, FilterOrder>
232 {
239 void setup (double sampleRate,
240 double cutoffFrequency,
241 double stopBandDb) {
242 HighPassBase::setup (FilterOrder,
243 cutoffFrequency / sampleRate,
244 stopBandDb);
245 }
246
254 void setup (int reqOrder,
255 double sampleRate,
256 double cutoffFrequency,
257 double stopBandDb) {
258 if (reqOrder > FilterOrder) throw_invalid_argument(orderTooHigh);
259 HighPassBase::setup (reqOrder,
260 cutoffFrequency / sampleRate,
261 stopBandDb);
262 }
263
264
265
266
272 void setupN(double cutoffFrequency,
273 double stopBandDb) {
274 HighPassBase::setup (FilterOrder,
275 cutoffFrequency,
276 stopBandDb);
277 }
278
285 void setupN(int reqOrder,
286 double cutoffFrequency,
287 double stopBandDb) {
288 if (reqOrder > FilterOrder) throw_invalid_argument(orderTooHigh);
289 HighPassBase::setup (reqOrder,
290 cutoffFrequency,
291 stopBandDb);
292 }
293
294 };
295
301 template <int FilterOrder = DEFAULT_FILTER_ORDER, class StateType = DEFAULT_STATE>
302 struct BandPass : PoleFilter <BandPassBase, StateType, FilterOrder, FilterOrder*2>
303 {
311 void setup (double sampleRate,
312 double centerFrequency,
313 double widthFrequency,
314 double stopBandDb) {
315 BandPassBase::setup (FilterOrder,
316 centerFrequency / sampleRate,
317 widthFrequency / sampleRate,
318 stopBandDb);
319 }
320
329 void setup (int reqOrder,
330 double sampleRate,
331 double centerFrequency,
332 double widthFrequency,
333 double stopBandDb) {
334 if (reqOrder > FilterOrder) throw_invalid_argument(orderTooHigh);
335 BandPassBase::setup (reqOrder,
336 centerFrequency / sampleRate,
337 widthFrequency / sampleRate,
338 stopBandDb);
339 }
340
341
342
343
350 void setupN(double centerFrequency,
351 double widthFrequency,
352 double stopBandDb) {
353 BandPassBase::setup (FilterOrder,
354 centerFrequency,
355 widthFrequency,
356 stopBandDb);
357 }
358
366 void setupN(int reqOrder,
367 double centerFrequency,
368 double widthFrequency,
369 double stopBandDb) {
370 if (reqOrder > FilterOrder) throw_invalid_argument(orderTooHigh);
371 BandPassBase::setup (reqOrder,
372 centerFrequency,
373 widthFrequency,
374 stopBandDb);
375 }
376 };
377
383 template <int FilterOrder = DEFAULT_FILTER_ORDER, class StateType = DEFAULT_STATE>
384 struct BandStop : PoleFilter <BandStopBase, StateType, FilterOrder, FilterOrder*2>
385 {
393 void setup (double sampleRate,
394 double centerFrequency,
395 double widthFrequency,
396 double stopBandDb) {
397 BandStopBase::setup (FilterOrder,
398 centerFrequency / sampleRate,
399 widthFrequency / sampleRate,
400 stopBandDb);
401 }
402
411 void setup (int reqOrder,
412 double sampleRate,
413 double centerFrequency,
414 double widthFrequency,
415 double stopBandDb) {
416 if (reqOrder > FilterOrder) throw_invalid_argument(orderTooHigh);
417 BandStopBase::setup (reqOrder,
418 centerFrequency / sampleRate,
419 widthFrequency / sampleRate,
420 stopBandDb);
421 }
422
423
424
425
432 void setupN(double centerFrequency,
433 double widthFrequency,
434 double stopBandDb) {
435 BandStopBase::setup (FilterOrder,
436 centerFrequency,
437 widthFrequency,
438 stopBandDb);
439 }
440
448 void setupN(int reqOrder,
449 double centerFrequency,
450 double widthFrequency,
451 double stopBandDb) {
452 if (reqOrder > FilterOrder) throw_invalid_argument(orderTooHigh);
453 BandStopBase::setup (reqOrder,
454 centerFrequency,
455 widthFrequency,
456 stopBandDb);
457 }
458 };
459
465 template <int FilterOrder = DEFAULT_FILTER_ORDER, class StateType = DEFAULT_STATE>
466 struct LowShelf : PoleFilter <LowShelfBase, StateType, FilterOrder>
467 {
475 void setup (double sampleRate,
476 double cutoffFrequency,
477 double gainDb,
478 double stopBandDb) {
479 LowShelfBase::setup (FilterOrder,
480 cutoffFrequency / sampleRate,
481 gainDb,
482 stopBandDb);
483 }
484
493 void setup (int reqOrder,
494 double sampleRate,
495 double cutoffFrequency,
496 double gainDb,
497 double stopBandDb) {
498 if (reqOrder > FilterOrder) throw_invalid_argument(orderTooHigh);
499 LowShelfBase::setup (reqOrder,
500 cutoffFrequency / sampleRate,
501 gainDb,
502 stopBandDb);
503 }
504
505
506
507
508
515 void setupN(double cutoffFrequency,
516 double gainDb,
517 double stopBandDb) {
518 LowShelfBase::setup (FilterOrder,
519 cutoffFrequency,
520 gainDb,
521 stopBandDb);
522 }
523
531 void setupN(int reqOrder,
532 double cutoffFrequency,
533 double gainDb,
534 double stopBandDb) {
535 if (reqOrder > FilterOrder) throw_invalid_argument(orderTooHigh);
536 LowShelfBase::setup (reqOrder,
537 cutoffFrequency,
538 gainDb,
539 stopBandDb);
540 }
541
542 };
543
549 template <int FilterOrder = DEFAULT_FILTER_ORDER, class StateType = DEFAULT_STATE>
550 struct HighShelf : PoleFilter <HighShelfBase, StateType, FilterOrder>
551 {
559 void setup (double sampleRate,
560 double cutoffFrequency,
561 double gainDb,
562 double stopBandDb) {
563 HighShelfBase::setup (FilterOrder,
564 cutoffFrequency / sampleRate,
565 gainDb,
566 stopBandDb);
567 }
568
577 void setup (int reqOrder,
578 double sampleRate,
579 double cutoffFrequency,
580 double gainDb,
581 double stopBandDb) {
582 if (reqOrder > FilterOrder) throw_invalid_argument(orderTooHigh);
583 HighShelfBase::setup (reqOrder,
584 cutoffFrequency / sampleRate,
585 gainDb,
586 stopBandDb);
587 }
588
589
590
591
592
593
600 void setupN(double cutoffFrequency,
601 double gainDb,
602 double stopBandDb) {
603 HighShelfBase::setup (FilterOrder,
604 cutoffFrequency,
605 gainDb,
606 stopBandDb);
607 }
608
616 void setupN(int reqOrder,
617 double cutoffFrequency,
618 double gainDb,
619 double stopBandDb) {
620 if (reqOrder > FilterOrder) throw_invalid_argument(orderTooHigh);
621 HighShelfBase::setup (reqOrder,
622 cutoffFrequency,
623 gainDb,
624 stopBandDb);
625 }
626
627 };
628
634 template <int FilterOrder = DEFAULT_FILTER_ORDER, class StateType = DEFAULT_STATE>
635 struct BandShelf : PoleFilter <BandShelfBase, StateType, FilterOrder, FilterOrder*2>
636 {
645 void setup (double sampleRate,
646 double centerFrequency,
647 double widthFrequency,
648 double gainDb,
649 double stopBandDb) {
650 BandShelfBase::setup (FilterOrder,
651 centerFrequency / sampleRate,
652 widthFrequency / sampleRate,
653 gainDb,
654 stopBandDb);
655 }
656
657
667 void setup (int reqOrder,
668 double sampleRate,
669 double centerFrequency,
670 double widthFrequency,
671 double gainDb,
672 double stopBandDb) {
673 if (reqOrder > FilterOrder) throw_invalid_argument(orderTooHigh);
674 BandShelfBase::setup (reqOrder,
675 centerFrequency / sampleRate,
676 widthFrequency / sampleRate,
677 gainDb,
678 stopBandDb);
679 }
680
681
682
683
684
685
686
694 void setupN(double centerFrequency,
695 double widthFrequency,
696 double gainDb,
697 double stopBandDb) {
698 BandShelfBase::setup (FilterOrder,
699 centerFrequency,
700 widthFrequency,
701 gainDb,
702 stopBandDb);
703 }
704
705
714 void setupN(int reqOrder,
715 double centerFrequency,
716 double widthFrequency,
717 double gainDb,
718 double stopBandDb) {
719 if (reqOrder > FilterOrder) throw_invalid_argument(orderTooHigh);
720 BandShelfBase::setup (reqOrder,
721 centerFrequency,
722 widthFrequency,
723 gainDb,
724 stopBandDb);
725 }
726
727
728 };
729
730 }
731
732 }
733
734 #endif
Iir::ChebyshevII::AnalogLowPass
Definition: ChebyshevII.h:59
Iir::ChebyshevII::AnalogLowShelf
Definition: ChebyshevII.h:76
Iir::LayoutBase
Definition: Layout.h:63
Iir::PoleFilterBase
Definition: PoleFilter.h:95
Iir
Definition: Biquad.cpp:40
Iir::ChebyshevII::BandPassBase
Definition: ChebyshevII.h:107
Iir::ChebyshevII::BandPass
Definition: ChebyshevII.h:303
Iir::ChebyshevII::BandPass::setup
void setup(int reqOrder, double sampleRate, double centerFrequency, double widthFrequency, double stopBandDb)
Definition: ChebyshevII.h:329
Iir::ChebyshevII::BandPass::setupN
void setupN(double centerFrequency, double widthFrequency, double stopBandDb)
Definition: ChebyshevII.h:350
Iir::ChebyshevII::BandPass::setup
void setup(double sampleRate, double centerFrequency, double widthFrequency, double stopBandDb)
Definition: ChebyshevII.h:311
Iir::ChebyshevII::BandPass::setupN
void setupN(int reqOrder, double centerFrequency, double widthFrequency, double stopBandDb)
Definition: ChebyshevII.h:366
Iir::ChebyshevII::BandShelfBase
Definition: ChebyshevII.h:139
Iir::ChebyshevII::BandShelf
Definition: ChebyshevII.h:636
Iir::ChebyshevII::BandShelf::setup
void setup(int reqOrder, double sampleRate, double centerFrequency, double widthFrequency, double gainDb, double stopBandDb)
Definition: ChebyshevII.h:667
Iir::ChebyshevII::BandShelf::setupN
void setupN(int reqOrder, double centerFrequency, double widthFrequency, double gainDb, double stopBandDb)
Definition: ChebyshevII.h:714
Iir::ChebyshevII::BandShelf::setupN
void setupN(double centerFrequency, double widthFrequency, double gainDb, double stopBandDb)
Definition: ChebyshevII.h:694
Iir::ChebyshevII::BandShelf::setup
void setup(double sampleRate, double centerFrequency, double widthFrequency, double gainDb, double stopBandDb)
Definition: ChebyshevII.h:645
Iir::ChebyshevII::BandStopBase
Definition: ChebyshevII.h:115
Iir::ChebyshevII::BandStop
Definition: ChebyshevII.h:385
Iir::ChebyshevII::BandStop::setup
void setup(double sampleRate, double centerFrequency, double widthFrequency, double stopBandDb)
Definition: ChebyshevII.h:393
Iir::ChebyshevII::BandStop::setupN
void setupN(int reqOrder, double centerFrequency, double widthFrequency, double stopBandDb)
Definition: ChebyshevII.h:448
Iir::ChebyshevII::BandStop::setupN
void setupN(double centerFrequency, double widthFrequency, double stopBandDb)
Definition: ChebyshevII.h:432
Iir::ChebyshevII::BandStop::setup
void setup(int reqOrder, double sampleRate, double centerFrequency, double widthFrequency, double stopBandDb)
Definition: ChebyshevII.h:411
Iir::ChebyshevII::HighPassBase
Definition: ChebyshevII.h:100
Iir::ChebyshevII::HighPass
Definition: ChebyshevII.h:232
Iir::ChebyshevII::HighPass::setup
void setup(int reqOrder, double sampleRate, double cutoffFrequency, double stopBandDb)
Definition: ChebyshevII.h:254
Iir::ChebyshevII::HighPass::setup
void setup(double sampleRate, double cutoffFrequency, double stopBandDb)
Definition: ChebyshevII.h:239
Iir::ChebyshevII::HighPass::setupN
void setupN(int reqOrder, double cutoffFrequency, double stopBandDb)
Definition: ChebyshevII.h:285
Iir::ChebyshevII::HighPass::setupN
void setupN(double cutoffFrequency, double stopBandDb)
Definition: ChebyshevII.h:272
Iir::ChebyshevII::HighShelfBase
Definition: ChebyshevII.h:131
Iir::ChebyshevII::HighShelf
Definition: ChebyshevII.h:551
Iir::ChebyshevII::HighShelf::setupN
void setupN(double cutoffFrequency, double gainDb, double stopBandDb)
Definition: ChebyshevII.h:600
Iir::ChebyshevII::HighShelf::setup
void setup(int reqOrder, double sampleRate, double cutoffFrequency, double gainDb, double stopBandDb)
Definition: ChebyshevII.h:577
Iir::ChebyshevII::HighShelf::setupN
void setupN(int reqOrder, double cutoffFrequency, double gainDb, double stopBandDb)
Definition: ChebyshevII.h:616
Iir::ChebyshevII::HighShelf::setup
void setup(double sampleRate, double cutoffFrequency, double gainDb, double stopBandDb)
Definition: ChebyshevII.h:559
Iir::ChebyshevII::LowPassBase
Definition: ChebyshevII.h:93
Iir::ChebyshevII::LowPass
Definition: ChebyshevII.h:160
Iir::ChebyshevII::LowPass::setupN
void setupN(int reqOrder, double cutoffFrequency, double stopBandDb)
Definition: ChebyshevII.h:214
Iir::ChebyshevII::LowPass::setup
void setup(double sampleRate, double cutoffFrequency, double stopBandDb)
Definition: ChebyshevII.h:167
Iir::ChebyshevII::LowPass::setupN
void setupN(double cutoffFrequency, double stopBandDb)
Definition: ChebyshevII.h:201
Iir::ChebyshevII::LowPass::setup
void setup(int reqOrder, double sampleRate, double cutoffFrequency, double stopBandDb)
Definition: ChebyshevII.h:182
Iir::ChebyshevII::LowShelfBase
Definition: ChebyshevII.h:123
Iir::ChebyshevII::LowShelf
Definition: ChebyshevII.h:467
Iir::ChebyshevII::LowShelf::setup
void setup(int reqOrder, double sampleRate, double cutoffFrequency, double gainDb, double stopBandDb)
Definition: ChebyshevII.h:493
Iir::ChebyshevII::LowShelf::setupN
void setupN(int reqOrder, double cutoffFrequency, double gainDb, double stopBandDb)
Definition: ChebyshevII.h:531
Iir::ChebyshevII::LowShelf::setup
void setup(double sampleRate, double cutoffFrequency, double gainDb, double stopBandDb)
Definition: ChebyshevII.h:475
Iir::ChebyshevII::LowShelf::setupN
void setupN(double cutoffFrequency, double gainDb, double stopBandDb)
Definition: ChebyshevII.h:515
Iir::PoleFilter
Definition: PoleFilter.h:119