![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
The experiment using this program is introduced on "Interface" No.2, CQ publishing Co.,Ltd, 2015. 本プログラムを使った実験は,CQ出版社のインターフェース 2015年2月号で紹介しています.
Dependencies: DSProcessingIO mbed
IIR_Cascade.hpp@1:5ece9454ba73, 2014-07-29 (annotated)
- Committer:
- CQpub0Mikami
- Date:
- Tue Jul 29 06:55:48 2014 +0000
- Revision:
- 1:5ece9454ba73
- Parent:
- 0:398107c96b1b
ver.2
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
CQpub0Mikami | 0:398107c96b1b | 1 | //-------------------------------------------------------------- |
CQpub0Mikami | 0:398107c96b1b | 2 | // IIR filter ---- Cascade structure |
CQpub0Mikami | 0:398107c96b1b | 3 | // Copyright (c) 2014 MIKAMI, Naoki, 2014/07/15 |
CQpub0Mikami | 0:398107c96b1b | 4 | //-------------------------------------------------------------- |
CQpub0Mikami | 0:398107c96b1b | 5 | |
CQpub0Mikami | 0:398107c96b1b | 6 | #ifndef IIR_CASCADE_HPP |
CQpub0Mikami | 0:398107c96b1b | 7 | #define IIR_CASCADE_HPP |
CQpub0Mikami | 0:398107c96b1b | 8 | |
CQpub0Mikami | 0:398107c96b1b | 9 | #include "mbed.h" |
CQpub0Mikami | 0:398107c96b1b | 10 | #include "Biquad.hpp" |
CQpub0Mikami | 0:398107c96b1b | 11 | |
CQpub0Mikami | 0:398107c96b1b | 12 | namespace Mikami |
CQpub0Mikami | 0:398107c96b1b | 13 | { |
CQpub0Mikami | 0:398107c96b1b | 14 | // IIR filter -- Cascade structure |
CQpub0Mikami | 0:398107c96b1b | 15 | template<int order> class IirCascade |
CQpub0Mikami | 0:398107c96b1b | 16 | { |
CQpub0Mikami | 0:398107c96b1b | 17 | private: |
CQpub0Mikami | 0:398107c96b1b | 18 | Biquad hk_[order]; // Elements of cascade structure |
CQpub0Mikami | 0:398107c96b1b | 19 | const float G0_; // gain factor |
CQpub0Mikami | 0:398107c96b1b | 20 | |
CQpub0Mikami | 0:398107c96b1b | 21 | IirCascade(const IirCascade&); |
CQpub0Mikami | 0:398107c96b1b | 22 | IirCascade& operator=(const IirCascade&); |
CQpub0Mikami | 0:398107c96b1b | 23 | |
CQpub0Mikami | 0:398107c96b1b | 24 | public: |
CQpub0Mikami | 0:398107c96b1b | 25 | IirCascade(float g0, const Biquad::Coefs ck[]) |
CQpub0Mikami | 0:398107c96b1b | 26 | : G0_(g0) |
CQpub0Mikami | 0:398107c96b1b | 27 | { |
CQpub0Mikami | 0:398107c96b1b | 28 | for (int k=0; k<order; k++) |
CQpub0Mikami | 0:398107c96b1b | 29 | hk_[k] = Biquad(ck[k]); |
CQpub0Mikami | 0:398107c96b1b | 30 | } |
CQpub0Mikami | 0:398107c96b1b | 31 | |
CQpub0Mikami | 0:398107c96b1b | 32 | float Execute(float xn) |
CQpub0Mikami | 0:398107c96b1b | 33 | { |
CQpub0Mikami | 0:398107c96b1b | 34 | float yn = G0_*xn; |
CQpub0Mikami | 0:398107c96b1b | 35 | for (int k=0; k<order; k++) |
CQpub0Mikami | 0:398107c96b1b | 36 | yn = hk_[k].Execute(yn); |
CQpub0Mikami | 0:398107c96b1b | 37 | |
CQpub0Mikami | 0:398107c96b1b | 38 | return yn; |
CQpub0Mikami | 0:398107c96b1b | 39 | } |
CQpub0Mikami | 0:398107c96b1b | 40 | |
CQpub0Mikami | 0:398107c96b1b | 41 | void Clear() |
CQpub0Mikami | 0:398107c96b1b | 42 | { |
CQpub0Mikami | 0:398107c96b1b | 43 | for (int k=0; k<order; k++) |
CQpub0Mikami | 0:398107c96b1b | 44 | hk_[k].Clear(); |
CQpub0Mikami | 0:398107c96b1b | 45 | } |
CQpub0Mikami | 0:398107c96b1b | 46 | }; |
CQpub0Mikami | 0:398107c96b1b | 47 | } |
CQpub0Mikami | 0:398107c96b1b | 48 | #endif // IIR_CASCADE_HPP |
CQpub0Mikami | 0:398107c96b1b | 49 |