Demo program of digital signal processing: Variable LPF/HPF, Vocal canceller, Pitch shifter, Reverbrator. ディジタル信号処理のデモプログラム. 遮断周波数可変 LPF/HPF,ボーカルキャンセラ,ピッチシフタ,残響生成器.
Dependencies: Array_Matrix F446_AD_DA UIT_AQM1602 mbed
SignalProcessing/BilinearDesignLH.hpp@6:96b4f6ce2dc9, 2017-02-21 (annotated)
- Committer:
- MikamiUitOpen
- Date:
- Tue Feb 21 13:14:47 2017 +0000
- Revision:
- 6:96b4f6ce2dc9
- Parent:
- 0:fa74b1130cc3
7
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
MikamiUitOpen | 0:fa74b1130cc3 | 1 | //------------------------------------------------------------------------ |
MikamiUitOpen | 0:fa74b1130cc3 | 2 | // Design of Butterworth LPF and HPF using bilinear transform -- Header |
MikamiUitOpen | 0:fa74b1130cc3 | 3 | // |
MikamiUitOpen | 0:fa74b1130cc3 | 4 | // 2016/03/31, Copyright (c) 2016 MIKAMI, Naoki |
MikamiUitOpen | 0:fa74b1130cc3 | 5 | //------------------------------------------------------------------------ |
MikamiUitOpen | 0:fa74b1130cc3 | 6 | |
MikamiUitOpen | 0:fa74b1130cc3 | 7 | #ifndef BILINEAR_BUTTERWORTH_HPP |
MikamiUitOpen | 0:fa74b1130cc3 | 8 | #define BILINEAR_BUTTERWORTH_HPP |
MikamiUitOpen | 0:fa74b1130cc3 | 9 | |
MikamiUitOpen | 0:fa74b1130cc3 | 10 | #include "mbed.h" |
MikamiUitOpen | 0:fa74b1130cc3 | 11 | #include <complex> // requisite |
MikamiUitOpen | 0:fa74b1130cc3 | 12 | #include "Array.hpp" |
MikamiUitOpen | 0:fa74b1130cc3 | 13 | |
MikamiUitOpen | 0:fa74b1130cc3 | 14 | namespace Mikami |
MikamiUitOpen | 0:fa74b1130cc3 | 15 | { |
MikamiUitOpen | 0:fa74b1130cc3 | 16 | typedef complex<float> Complex; // define "Complex" |
MikamiUitOpen | 0:fa74b1130cc3 | 17 | |
MikamiUitOpen | 0:fa74b1130cc3 | 18 | class BilinearDesign |
MikamiUitOpen | 0:fa74b1130cc3 | 19 | { |
MikamiUitOpen | 0:fa74b1130cc3 | 20 | public: |
MikamiUitOpen | 0:fa74b1130cc3 | 21 | struct Coefs { float a1, a2, b1, b2; }; |
MikamiUitOpen | 0:fa74b1130cc3 | 22 | enum Type { LPF, HPF }; |
MikamiUitOpen | 0:fa74b1130cc3 | 23 | |
MikamiUitOpen | 0:fa74b1130cc3 | 24 | // Constructor |
MikamiUitOpen | 0:fa74b1130cc3 | 25 | BilinearDesign(int order, float fs) |
MikamiUitOpen | 0:fa74b1130cc3 | 26 | : PI_FS_(PI_/fs), ORDER_(order), |
MikamiUitOpen | 0:fa74b1130cc3 | 27 | sP_(order/2), zP_(order/2), ck_(order/2) {} |
MikamiUitOpen | 0:fa74b1130cc3 | 28 | |
MikamiUitOpen | 0:fa74b1130cc3 | 29 | // Destractor |
MikamiUitOpen | 0:fa74b1130cc3 | 30 | virtual ~BilinearDesign() {} |
MikamiUitOpen | 0:fa74b1130cc3 | 31 | |
MikamiUitOpen | 0:fa74b1130cc3 | 32 | // Execution of design |
MikamiUitOpen | 0:fa74b1130cc3 | 33 | void Execute(float fc, Type pb, Coefs c[], float& g); |
MikamiUitOpen | 0:fa74b1130cc3 | 34 | |
MikamiUitOpen | 0:fa74b1130cc3 | 35 | private: |
MikamiUitOpen | 0:fa74b1130cc3 | 36 | static const float PI_ = 3.1415926536f; |
MikamiUitOpen | 0:fa74b1130cc3 | 37 | const float PI_FS_; |
MikamiUitOpen | 0:fa74b1130cc3 | 38 | const int ORDER_; |
MikamiUitOpen | 0:fa74b1130cc3 | 39 | |
MikamiUitOpen | 0:fa74b1130cc3 | 40 | Array<Complex> sP_; // Poles on s-plane |
MikamiUitOpen | 0:fa74b1130cc3 | 41 | Array<Complex> zP_; // Poles on z-plane |
MikamiUitOpen | 0:fa74b1130cc3 | 42 | Array<Coefs> ck_; // Coefficients of transfer function for cascade form |
MikamiUitOpen | 0:fa74b1130cc3 | 43 | |
MikamiUitOpen | 0:fa74b1130cc3 | 44 | float gain_; // Gain factor for cascade form |
MikamiUitOpen | 0:fa74b1130cc3 | 45 | |
MikamiUitOpen | 0:fa74b1130cc3 | 46 | void Butterworth(); |
MikamiUitOpen | 0:fa74b1130cc3 | 47 | void Bilinear(float fc); |
MikamiUitOpen | 0:fa74b1130cc3 | 48 | void ToCascade(Type pb); |
MikamiUitOpen | 0:fa74b1130cc3 | 49 | void GetGain(Type pb); |
MikamiUitOpen | 0:fa74b1130cc3 | 50 | void GetCoefs(Coefs c[], float& gain); |
MikamiUitOpen | 0:fa74b1130cc3 | 51 | }; |
MikamiUitOpen | 0:fa74b1130cc3 | 52 | } |
MikamiUitOpen | 0:fa74b1130cc3 | 53 | #endif // BILINEAR_BUTTERWORTH_HPP |