Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: F746_GUI F746_SAI_IO FrequencyResponseDrawer SD_PlayerSkeleton UIT_FFT_Real
Biquad.hpp
00001 //-------------------------------------------------------------- 00002 // 縦続形 IIR フィルタで使う 1D タイプの 2 次のフィルタ 00003 // Biquad filter of 1D type for IIR filter of cascade structure 00004 // このクラスでは,係数は実行中に書き換えられることを想定している 00005 // 00006 // u[n] = x[n] + a1*u[n-1] + a2*u[n-2] 00007 // y[n] = u[n] + b1*u[n-1] + b2*u[n-2] 00008 // x[n] : input signal 00009 // y[n] : output signal 00010 // b0 = 1 00011 // 00012 // 2017/03/26, Copyright (c) 2017 MIKAMI, Naoki 00013 //-------------------------------------------------------------- 00014 00015 #ifndef IIR_BIQUAD_HPP 00016 #define IIR_BIQUAD_HPP 00017 00018 #include "mbed.h" 00019 00020 // 2nd order IIR filter 00021 namespace Mikami 00022 { 00023 class Biquad 00024 { 00025 public: 00026 struct Coefs { float a1, a2, b1, b2; }; 00027 00028 Biquad(const Coefs ck = (Coefs){0, 0, 0, 0}) 00029 { 00030 SetCoefficients(ck); 00031 Clear(); 00032 } 00033 00034 void SetCoefficients(const Coefs cf) { cf_ = cf; } 00035 00036 float Execute(float xn) 00037 { 00038 float un = xn + cf_.a1*un1_ + cf_.a2*un2_; 00039 float yn = un + cf_.b1*un1_ + cf_.b2*un2_; 00040 00041 un2_ = un1_; 00042 un1_ = un; 00043 00044 return yn; 00045 } 00046 00047 void Clear() { un1_ = un2_ = 0; } 00048 00049 private: 00050 Coefs cf_; 00051 float un1_, un2_; 00052 00053 // disallow copy constructor 00054 Biquad(const Biquad&); 00055 }; 00056 } 00057 #endif // IIR_BIQUAD_HPP
Generated on Tue Jul 12 2022 21:58:54 by
1.7.2