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

Committer:
MikamiUitOpen
Date:
Sun Jan 29 09:11:30 2017 +0000
Revision:
0:fa74b1130cc3
Child:
4:2f06a5893e4a
1

Who changed what in which revision?

UserRevisionLine numberNew contents of line
MikamiUitOpen 0:fa74b1130cc3 1 //--------------------------------------------------------------
MikamiUitOpen 0:fa74b1130cc3 2 // 遮断周波数可変フィルタ,LPF と HPF
MikamiUitOpen 0:fa74b1130cc3 3 //
MikamiUitOpen 0:fa74b1130cc3 4 // 2017/01/26, 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 0:fa74b1130cc3 31 {
MikamiUitOpen 0:fa74b1130cc3 32 coefsIir_[n].a1 = coefs_[n].a1;
MikamiUitOpen 0:fa74b1130cc3 33 coefsIir_[n].a2 = coefs_[n].a2;
MikamiUitOpen 0:fa74b1130cc3 34 coefsIir_[n].b1 = coefs_[n].b1;
MikamiUitOpen 0:fa74b1130cc3 35 coefsIir_[n].b2 = 1.0f;
MikamiUitOpen 0:fa74b1130cc3 36 }
MikamiUitOpen 0:fa74b1130cc3 37 filter_.SetCoefs(g0, coefsIir_);
MikamiUitOpen 0:fa74b1130cc3 38 filter_.Clear();
MikamiUitOpen 0:fa74b1130cc3 39 }
MikamiUitOpen 0:fa74b1130cc3 40
MikamiUitOpen 0:fa74b1130cc3 41 private:
MikamiUitOpen 0:fa74b1130cc3 42 const int ORDER2_;
MikamiUitOpen 0:fa74b1130cc3 43
MikamiUitOpen 0:fa74b1130cc3 44 Array<BilinearDesign::Coefs> coefs_;
MikamiUitOpen 0:fa74b1130cc3 45 Array<Biquad::Coefs> coefsIir_;
MikamiUitOpen 0:fa74b1130cc3 46
MikamiUitOpen 0:fa74b1130cc3 47 BilinearDesign designer_;
MikamiUitOpen 0:fa74b1130cc3 48 IirCascade filter_;
MikamiUitOpen 0:fa74b1130cc3 49 };
MikamiUitOpen 0:fa74b1130cc3 50 #endif // VARIABLE_LOWPASS_HIGHPASS_FILTER_HPP