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/VariableLpHp.hpp@5:503bd366fd73, 2017-01-31 (annotated)
- Committer:
- MikamiUitOpen
- Date:
- Tue Jan 31 12:52:35 2017 +0000
- Revision:
- 5:503bd366fd73
- Parent:
- 4:2f06a5893e4a
6
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
MikamiUitOpen | 0:fa74b1130cc3 | 1 | //-------------------------------------------------------------- |
MikamiUitOpen | 0:fa74b1130cc3 | 2 | // 遮断周波数可変フィルタ,LPF と HPF |
MikamiUitOpen | 0:fa74b1130cc3 | 3 | // |
MikamiUitOpen | 4:2f06a5893e4a | 4 | // 2017/01/30, Copyright (c) 2017 MIKAMI, Naoki |
MikamiUitOpen | 0:fa74b1130cc3 | 5 | //-------------------------------------------------------------- |
MikamiUitOpen | 0:fa74b1130cc3 | 6 | |
MikamiUitOpen | 0:fa74b1130cc3 | 7 | #ifndef VARIABLE_LOWPASS_HIGHPASS_FILTER_HPP |
MikamiUitOpen | 0:fa74b1130cc3 | 8 | #define VARIABLE_LOWPASS_HIGHPASS_FILTER_HPP |
MikamiUitOpen | 0:fa74b1130cc3 | 9 | |
MikamiUitOpen | 0:fa74b1130cc3 | 10 | #include "IIR_Cascade.hpp" |
MikamiUitOpen | 0:fa74b1130cc3 | 11 | #include "SignalProcessing.hpp" |
MikamiUitOpen | 0:fa74b1130cc3 | 12 | #include "BilinearDesignLH.hpp" |
MikamiUitOpen | 0:fa74b1130cc3 | 13 | #include "Array.hpp" |
MikamiUitOpen | 0:fa74b1130cc3 | 14 | using namespace Mikami; |
MikamiUitOpen | 0:fa74b1130cc3 | 15 | |
MikamiUitOpen | 0:fa74b1130cc3 | 16 | class VariableLpHp : public SignalProcessing |
MikamiUitOpen | 0:fa74b1130cc3 | 17 | { |
MikamiUitOpen | 0:fa74b1130cc3 | 18 | public: |
MikamiUitOpen | 0:fa74b1130cc3 | 19 | VariableLpHp(int order, float fs) |
MikamiUitOpen | 0:fa74b1130cc3 | 20 | : ORDER2_(order/2), coefs_(order/2), coefsIir_(order/2), |
MikamiUitOpen | 0:fa74b1130cc3 | 21 | designer_(order, fs), filter_(order) {} |
MikamiUitOpen | 0:fa74b1130cc3 | 22 | |
MikamiUitOpen | 0:fa74b1130cc3 | 23 | virtual float Execute(float xn1, float xn2) |
MikamiUitOpen | 0:fa74b1130cc3 | 24 | { return filter_.Execute((xn1 + xn2)*0.5f); } |
MikamiUitOpen | 0:fa74b1130cc3 | 25 | |
MikamiUitOpen | 0:fa74b1130cc3 | 26 | void Design(float fc, BilinearDesign::Type passBand) |
MikamiUitOpen | 0:fa74b1130cc3 | 27 | { |
MikamiUitOpen | 0:fa74b1130cc3 | 28 | float g0; |
MikamiUitOpen | 0:fa74b1130cc3 | 29 | designer_.Execute(fc, passBand, coefs_, g0); |
MikamiUitOpen | 0:fa74b1130cc3 | 30 | for (int n=0; n<ORDER2_; n++) |
MikamiUitOpen | 4:2f06a5893e4a | 31 | coefsIir_[n] = *(Biquad::Coefs *)&coefs_[n]; |
MikamiUitOpen | 4:2f06a5893e4a | 32 | |
MikamiUitOpen | 0:fa74b1130cc3 | 33 | filter_.SetCoefs(g0, coefsIir_); |
MikamiUitOpen | 0:fa74b1130cc3 | 34 | filter_.Clear(); |
MikamiUitOpen | 0:fa74b1130cc3 | 35 | } |
MikamiUitOpen | 5:503bd366fd73 | 36 | |
MikamiUitOpen | 0:fa74b1130cc3 | 37 | private: |
MikamiUitOpen | 0:fa74b1130cc3 | 38 | const int ORDER2_; |
MikamiUitOpen | 5:503bd366fd73 | 39 | |
MikamiUitOpen | 0:fa74b1130cc3 | 40 | Array<BilinearDesign::Coefs> coefs_; |
MikamiUitOpen | 0:fa74b1130cc3 | 41 | Array<Biquad::Coefs> coefsIir_; |
MikamiUitOpen | 0:fa74b1130cc3 | 42 | |
MikamiUitOpen | 0:fa74b1130cc3 | 43 | BilinearDesign designer_; |
MikamiUitOpen | 0:fa74b1130cc3 | 44 | IirCascade filter_; |
MikamiUitOpen | 0:fa74b1130cc3 | 45 | }; |
MikamiUitOpen | 4:2f06a5893e4a | 46 | #endif // VARIABLE_LOWPASS_HIGHPASS_FILTER_HPP |