iir1: iir/ChebyshevI.h Source File

iir1

Loading...
Searching...
No Matches
ChebyshevI.h
1
36#ifndef IIR1_CHEBYSHEVI_H
37#define IIR1_CHEBYSHEVI_H
38
39#include "Common.h"
40#include "Cascade.h"
41#include "PoleFilter.h"
42#include "State.h"
43
44namespace Iir {
45
50namespace ChebyshevI {
51
55 class IIR_EXPORT AnalogLowPass : public LayoutBase
56{
57public:
58 AnalogLowPass ();
59
60 void design (const int numPoles,
61 double rippleDb);
62
63private:
64 int m_numPoles = 0;
65 double m_rippleDb = 0.0;
66};
67
71 class IIR_EXPORT AnalogLowShelf : public LayoutBase
72{
73public:
74 AnalogLowShelf ();
75
76 void design (int numPoles,
77 double gainDb,
78 double rippleDb);
79
80private:
81 int m_numPoles = 0;
82 double m_rippleDb = 0.0;
83 double m_gainDb = 0.0;
84};
85
86//------------------------------------------------------------------------------
87
88 struct IIR_EXPORT LowPassBase : PoleFilterBase <AnalogLowPass>
89{
90 void setup (int order,
91 double cutoffFrequency,
92 double rippleDb);
93};
94
95 struct IIR_EXPORT HighPassBase : PoleFilterBase <AnalogLowPass>
96{
97 void setup (int order,
98 double cutoffFrequency,
99 double rippleDb);
100};
101
102 struct IIR_EXPORT BandPassBase : PoleFilterBase <AnalogLowPass>
103{
104 void setup (int order,
105 double centerFrequency,
106 double widthFrequency,
107 double rippleDb);
108};
109
110 struct IIR_EXPORT BandStopBase : PoleFilterBase <AnalogLowPass>
111{
112 void setup (int order,
113 double centerFrequency,
114 double widthFrequency,
115 double rippleDb);
116};
117
118 struct IIR_EXPORT LowShelfBase : PoleFilterBase <AnalogLowShelf>
119{
120 void setup (int order,
121 double cutoffFrequency,
122 double gainDb,
123 double rippleDb);
124};
125
126 struct IIR_EXPORT HighShelfBase : PoleFilterBase <AnalogLowShelf>
127{
128 void setup (int order,
129 double cutoffFrequency,
130 double gainDb,
131 double rippleDb);
132};
133
134 struct IIR_EXPORT BandShelfBase : PoleFilterBase <AnalogLowShelf>
135{
136 void setup (int order,
137 double centerFrequency,
138 double widthFrequency,
139 double gainDb,
140 double rippleDb);
141};
142
143//------------------------------------------------------------------------------
144
145//
146// Userland filters
147//
148
154template <int FilterOrder = DEFAULT_FILTER_ORDER, class StateType = DEFAULT_STATE>
155 struct LowPass : PoleFilter <LowPassBase, StateType, FilterOrder>
156 {
163 void setup (double sampleRate,
164 double cutoffFrequency,
165 double rippleDb) {
166 LowPassBase::setup (FilterOrder,
167 cutoffFrequency / sampleRate,
168 rippleDb);
169 }
170
178 void setup (int reqOrder,
179 double sampleRate,
180 double cutoffFrequency,
181 double rippleDb) {
182 if (reqOrder > FilterOrder) throw_invalid_argument(orderTooHigh);
183 LowPassBase::setup (reqOrder,
184 cutoffFrequency / sampleRate,
185 rippleDb);
186 }
187
188
189
195 void setupN(double cutoffFrequency,
196 double rippleDb) {
197 LowPassBase::setup (FilterOrder,
198 cutoffFrequency,
199 rippleDb);
200 }
201
208 void setupN(int reqOrder,
209 double cutoffFrequency,
210 double rippleDb) {
211 if (reqOrder > FilterOrder) throw_invalid_argument(orderTooHigh);
212 LowPassBase::setup (reqOrder,
213 cutoffFrequency,
214 rippleDb);
215 }
216};
217
223template <int FilterOrder = DEFAULT_FILTER_ORDER, class StateType = DEFAULT_STATE>
224 struct HighPass : PoleFilter <HighPassBase, StateType, FilterOrder>
225 {
232 void setup (double sampleRate,
233 double cutoffFrequency,
234 double rippleDb) {
235 HighPassBase::setup (FilterOrder,
236 cutoffFrequency / sampleRate,
237 rippleDb);
238 }
239
247 void setup (int reqOrder,
248 double sampleRate,
249 double cutoffFrequency,
250 double rippleDb) {
251 if (reqOrder > FilterOrder) throw_invalid_argument(orderTooHigh);
252 HighPassBase::setup (reqOrder,
253 cutoffFrequency / sampleRate,
254 rippleDb);
255 }
256
257
258
264 void setupN(double cutoffFrequency,
265 double rippleDb) {
266 HighPassBase::setup (FilterOrder,
267 cutoffFrequency,
268 rippleDb);
269 }
270
277 void setupN(int reqOrder,
278 double cutoffFrequency,
279 double rippleDb) {
280 if (reqOrder > FilterOrder) throw_invalid_argument(orderTooHigh);
281 HighPassBase::setup (reqOrder,
282 cutoffFrequency,
283 rippleDb);
284 }
285};
286
292template <int FilterOrder = DEFAULT_FILTER_ORDER, class StateType = DEFAULT_STATE>
293 struct BandPass : PoleFilter <BandPassBase, StateType, FilterOrder, FilterOrder*2>
294 {
302 void setup (double sampleRate,
303 double centerFrequency,
304 double widthFrequency,
305 double rippleDb) {
306 BandPassBase::setup (FilterOrder,
307 centerFrequency / sampleRate,
308 widthFrequency / sampleRate,
309 rippleDb);
310 }
311
320 void setup (int reqOrder,
321 double sampleRate,
322 double centerFrequency,
323 double widthFrequency,
324 double rippleDb) {
325 if (reqOrder > FilterOrder) throw_invalid_argument(orderTooHigh);
326 BandPassBase::setup (reqOrder,
327 centerFrequency / sampleRate,
328 widthFrequency / sampleRate,
329 rippleDb);
330 }
331
332
333
340 void setupN(double centerFrequency,
341 double widthFrequency,
342 double rippleDb) {
343 BandPassBase::setup (FilterOrder,
344 centerFrequency,
345 widthFrequency,
346 rippleDb);
347 }
348
356 void setupN(int reqOrder,
357 double centerFrequency,
358 double widthFrequency,
359 double rippleDb) {
360 if (reqOrder > FilterOrder) throw_invalid_argument(orderTooHigh);
361 BandPassBase::setup (reqOrder,
362 centerFrequency,
363 widthFrequency,
364 rippleDb);
365 }
366};
367
373template <int FilterOrder = DEFAULT_FILTER_ORDER, class StateType = DEFAULT_STATE>
374 struct BandStop : PoleFilter <BandStopBase, StateType, FilterOrder, FilterOrder*2>
375 {
383 void setup (double sampleRate,
384 double centerFrequency,
385 double widthFrequency,
386 double rippleDb) {
387 BandStopBase::setup (FilterOrder,
388 centerFrequency / sampleRate,
389 widthFrequency / sampleRate,
390 rippleDb);
391 }
392
401 void setup (int reqOrder,
402 double sampleRate,
403 double centerFrequency,
404 double widthFrequency,
405 double rippleDb) {
406 if (reqOrder > FilterOrder) throw_invalid_argument(orderTooHigh);
407 BandStopBase::setup (reqOrder,
408 centerFrequency / sampleRate,
409 widthFrequency / sampleRate,
410 rippleDb);
411 }
412
413
414
421 void setupN(double centerFrequency,
422 double widthFrequency,
423 double rippleDb) {
424 BandStopBase::setup (FilterOrder,
425 centerFrequency,
426 widthFrequency,
427 rippleDb);
428 }
429
437 void setupN(int reqOrder,
438 double centerFrequency,
439 double widthFrequency,
440 double rippleDb) {
441 if (reqOrder > FilterOrder) throw_invalid_argument(orderTooHigh);
442 BandStopBase::setup (reqOrder,
443 centerFrequency,
444 widthFrequency,
445 rippleDb);
446 }
447
448};
449
455template <int FilterOrder = DEFAULT_FILTER_ORDER, class StateType = DEFAULT_STATE>
456 struct LowShelf : PoleFilter <LowShelfBase, StateType, FilterOrder>
457 {
465 void setup (double sampleRate,
466 double cutoffFrequency,
467 double gainDb,
468 double rippleDb) {
469 LowShelfBase::setup (FilterOrder,
470 cutoffFrequency / sampleRate,
471 gainDb,
472 rippleDb);
473 }
474
483 void setup (int reqOrder,
484 double sampleRate,
485 double cutoffFrequency,
486 double gainDb,
487 double rippleDb) {
488 if (reqOrder > FilterOrder) throw_invalid_argument(orderTooHigh);
489 LowShelfBase::setup (reqOrder,
490 cutoffFrequency / sampleRate,
491 gainDb,
492 rippleDb);
493 }
494
495
496
503 void setupN(double cutoffFrequency,
504 double gainDb,
505 double rippleDb) {
506 LowShelfBase::setup (FilterOrder,
507 cutoffFrequency,
508 gainDb,
509 rippleDb);
510 }
511
519 void setupN(int reqOrder,
520 double cutoffFrequency,
521 double gainDb,
522 double rippleDb) {
523 if (reqOrder > FilterOrder) throw_invalid_argument(orderTooHigh);
524 LowShelfBase::setup (reqOrder,
525 cutoffFrequency,
526 gainDb,
527 rippleDb);
528 }
529};
530
536template <int FilterOrder = DEFAULT_FILTER_ORDER, class StateType = DEFAULT_STATE>
537 struct HighShelf : PoleFilter <HighShelfBase, StateType, FilterOrder>
538 {
546 void setup (double sampleRate,
547 double cutoffFrequency,
548 double gainDb,
549 double rippleDb) {
550 HighShelfBase::setup (FilterOrder,
551 cutoffFrequency / sampleRate,
552 gainDb,
553 rippleDb);
554 }
555
564 void setup (int reqOrder,
565 double sampleRate,
566 double cutoffFrequency,
567 double gainDb,
568 double rippleDb) {
569 if (reqOrder > FilterOrder) throw_invalid_argument(orderTooHigh);
570 HighShelfBase::setup (reqOrder,
571 cutoffFrequency / sampleRate,
572 gainDb,
573 rippleDb);
574 }
575
576
577
578
585 void setupN(double cutoffFrequency,
586 double gainDb,
587 double rippleDb) {
588 HighShelfBase::setup (FilterOrder,
589 cutoffFrequency,
590 gainDb,
591 rippleDb);
592 }
593
601 void setupN(int reqOrder,
602 double cutoffFrequency,
603 double gainDb,
604 double rippleDb) {
605 if (reqOrder > FilterOrder) throw_invalid_argument(orderTooHigh);
606 HighShelfBase::setup (reqOrder,
607 cutoffFrequency,
608 gainDb,
609 rippleDb);
610 }
611
612};
613
619template <int FilterOrder = DEFAULT_FILTER_ORDER, class StateType = DEFAULT_STATE>
620 struct BandShelf : PoleFilter <BandShelfBase, StateType, FilterOrder, FilterOrder*2>
621 {
630 void setup (double sampleRate,
631 double centerFrequency,
632 double widthFrequency,
633 double gainDb,
634 double rippleDb) {
635 BandShelfBase::setup (FilterOrder,
636 centerFrequency / sampleRate,
637 widthFrequency / sampleRate,
638 gainDb,
639 rippleDb);
640
641 }
642
652 void setup (int reqOrder,
653 double sampleRate,
654 double centerFrequency,
655 double widthFrequency,
656 double gainDb,
657 double rippleDb) {
658 if (reqOrder > FilterOrder) throw_invalid_argument(orderTooHigh);
659 BandShelfBase::setup (reqOrder,
660 centerFrequency / sampleRate,
661 widthFrequency / sampleRate,
662 gainDb,
663 rippleDb);
664
665 }
666
667
668
669
677 void setupN(double centerFrequency,
678 double widthFrequency,
679 double gainDb,
680 double rippleDb) {
681 BandShelfBase::setup (FilterOrder,
682 centerFrequency,
683 widthFrequency,
684 gainDb,
685 rippleDb);
686
687 }
688
697 void setupN(int reqOrder,
698 double centerFrequency,
699 double widthFrequency,
700 double gainDb,
701 double rippleDb) {
702 if (reqOrder > FilterOrder) throw_invalid_argument(orderTooHigh);
703 BandShelfBase::setup (reqOrder,
704 centerFrequency,
705 widthFrequency,
706 gainDb,
707 rippleDb);
708
709 }
710
711 };
712
713}
714
715}
716
717#endif
Iir::ChebyshevI::AnalogLowPass
Definition ChebyshevI.h:56
Iir::ChebyshevI::AnalogLowShelf
Definition ChebyshevI.h:72
Iir::LayoutBase
Definition Layout.h:63
Iir::PoleFilterBase
Definition PoleFilter.h:95
Iir
Definition Biquad.cpp:40
Iir::ChebyshevI::BandPassBase
Definition ChebyshevI.h:103
Iir::ChebyshevI::BandPass
Definition ChebyshevI.h:294
Iir::ChebyshevI::BandPass::setupN
void setupN(int reqOrder, double centerFrequency, double widthFrequency, double rippleDb)
Definition ChebyshevI.h:356
Iir::ChebyshevI::BandPass::setupN
void setupN(double centerFrequency, double widthFrequency, double rippleDb)
Definition ChebyshevI.h:340
Iir::ChebyshevI::BandPass::setup
void setup(double sampleRate, double centerFrequency, double widthFrequency, double rippleDb)
Definition ChebyshevI.h:302
Iir::ChebyshevI::BandPass::setup
void setup(int reqOrder, double sampleRate, double centerFrequency, double widthFrequency, double rippleDb)
Definition ChebyshevI.h:320
Iir::ChebyshevI::BandShelfBase
Definition ChebyshevI.h:135
Iir::ChebyshevI::BandShelf
Definition ChebyshevI.h:621
Iir::ChebyshevI::BandShelf::setupN
void setupN(int reqOrder, double centerFrequency, double widthFrequency, double gainDb, double rippleDb)
Definition ChebyshevI.h:697
Iir::ChebyshevI::BandShelf::setup
void setup(double sampleRate, double centerFrequency, double widthFrequency, double gainDb, double rippleDb)
Definition ChebyshevI.h:630
Iir::ChebyshevI::BandShelf::setup
void setup(int reqOrder, double sampleRate, double centerFrequency, double widthFrequency, double gainDb, double rippleDb)
Definition ChebyshevI.h:652
Iir::ChebyshevI::BandShelf::setupN
void setupN(double centerFrequency, double widthFrequency, double gainDb, double rippleDb)
Definition ChebyshevI.h:677
Iir::ChebyshevI::BandStopBase
Definition ChebyshevI.h:111
Iir::ChebyshevI::BandStop
Definition ChebyshevI.h:375
Iir::ChebyshevI::BandStop::setupN
void setupN(double centerFrequency, double widthFrequency, double rippleDb)
Definition ChebyshevI.h:421
Iir::ChebyshevI::BandStop::setup
void setup(int reqOrder, double sampleRate, double centerFrequency, double widthFrequency, double rippleDb)
Definition ChebyshevI.h:401
Iir::ChebyshevI::BandStop::setupN
void setupN(int reqOrder, double centerFrequency, double widthFrequency, double rippleDb)
Definition ChebyshevI.h:437
Iir::ChebyshevI::BandStop::setup
void setup(double sampleRate, double centerFrequency, double widthFrequency, double rippleDb)
Definition ChebyshevI.h:383
Iir::ChebyshevI::HighPassBase
Definition ChebyshevI.h:96
Iir::ChebyshevI::HighPass
Definition ChebyshevI.h:225
Iir::ChebyshevI::HighPass::setup
void setup(double sampleRate, double cutoffFrequency, double rippleDb)
Definition ChebyshevI.h:232
Iir::ChebyshevI::HighPass::setup
void setup(int reqOrder, double sampleRate, double cutoffFrequency, double rippleDb)
Definition ChebyshevI.h:247
Iir::ChebyshevI::HighPass::setupN
void setupN(int reqOrder, double cutoffFrequency, double rippleDb)
Definition ChebyshevI.h:277
Iir::ChebyshevI::HighPass::setupN
void setupN(double cutoffFrequency, double rippleDb)
Definition ChebyshevI.h:264
Iir::ChebyshevI::HighShelfBase
Definition ChebyshevI.h:127
Iir::ChebyshevI::HighShelf
Definition ChebyshevI.h:538
Iir::ChebyshevI::HighShelf::setup
void setup(int reqOrder, double sampleRate, double cutoffFrequency, double gainDb, double rippleDb)
Definition ChebyshevI.h:564
Iir::ChebyshevI::HighShelf::setup
void setup(double sampleRate, double cutoffFrequency, double gainDb, double rippleDb)
Definition ChebyshevI.h:546
Iir::ChebyshevI::HighShelf::setupN
void setupN(double cutoffFrequency, double gainDb, double rippleDb)
Definition ChebyshevI.h:585
Iir::ChebyshevI::HighShelf::setupN
void setupN(int reqOrder, double cutoffFrequency, double gainDb, double rippleDb)
Definition ChebyshevI.h:601
Iir::ChebyshevI::LowPassBase
Definition ChebyshevI.h:89
Iir::ChebyshevI::LowPass
Definition ChebyshevI.h:156
Iir::ChebyshevI::LowPass::setupN
void setupN(int reqOrder, double cutoffFrequency, double rippleDb)
Definition ChebyshevI.h:208
Iir::ChebyshevI::LowPass::setupN
void setupN(double cutoffFrequency, double rippleDb)
Definition ChebyshevI.h:195
Iir::ChebyshevI::LowPass::setup
void setup(int reqOrder, double sampleRate, double cutoffFrequency, double rippleDb)
Definition ChebyshevI.h:178
Iir::ChebyshevI::LowPass::setup
void setup(double sampleRate, double cutoffFrequency, double rippleDb)
Definition ChebyshevI.h:163
Iir::ChebyshevI::LowShelfBase
Definition ChebyshevI.h:119
Iir::ChebyshevI::LowShelf
Definition ChebyshevI.h:457
Iir::ChebyshevI::LowShelf::setup
void setup(double sampleRate, double cutoffFrequency, double gainDb, double rippleDb)
Definition ChebyshevI.h:465
Iir::ChebyshevI::LowShelf::setupN
void setupN(double cutoffFrequency, double gainDb, double rippleDb)
Definition ChebyshevI.h:503
Iir::ChebyshevI::LowShelf::setupN
void setupN(int reqOrder, double cutoffFrequency, double gainDb, double rippleDb)
Definition ChebyshevI.h:519
Iir::ChebyshevI::LowShelf::setup
void setup(int reqOrder, double sampleRate, double cutoffFrequency, double gainDb, double rippleDb)
Definition ChebyshevI.h:483
Iir::PoleFilter
Definition PoleFilter.h:119