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 SD_PlayerSkeleton FrequencyResponseDrawer
BiquadGrEq.hpp
00001 //-------------------------------------------------------------- 00002 // グラフィックイコライザで使う 1D タイプの 2 次のフィルタ 00003 // Biquad filter of 1D type for graphic equalizer 00004 // このクラスでは,係数は実行中に書き換えられることを想定している 00005 // 00006 // u[n] = x[n] + a1*u[n-1] + a2*u[n-2] 00007 // y[n] = b0*u[n] + b1*u[n-1] + b2*u[n-2] 00008 // x[n] : input signal 00009 // y[n] : output signal 00010 // 00011 // 2017/03/28, Copyright (c) 2017 MIKAMI, Naoki 00012 //-------------------------------------------------------------- 00013 00014 #ifndef IIR_BIQUAD_GREQ_HPP 00015 #define IIR_BIQUAD_GREQ_HPP 00016 00017 #include "mbed.h" 00018 00019 // 2nd order IIR filter 00020 namespace Mikami 00021 { 00022 class BiquadGrEq 00023 { 00024 public: 00025 struct Coefs { float a1, a2, b0, b1, b2; }; 00026 00027 BiquadGrEq(const Coefs ck = (Coefs){0, 0, 0, 0, 0}) 00028 { 00029 SetCoefficients(ck); 00030 Clear(); 00031 } 00032 00033 void SetCoefficients(const Coefs cf) { cf_ = cf; } 00034 00035 float Execute(float xn) 00036 { 00037 float un = xn + cf_.a1*un1_ + cf_.a2*un2_; 00038 float yn = cf_.b0*un + cf_.b1*un1_ + cf_.b2*un2_; 00039 00040 un2_ = un1_; 00041 un1_ = un; 00042 00043 return yn; 00044 } 00045 00046 void Clear() { un1_ = un2_ = 0; } 00047 00048 private: 00049 Coefs cf_; 00050 float un1_, un2_; 00051 00052 // disallow copy constructor 00053 BiquadGrEq(const BiquadGrEq&); 00054 }; 00055 } 00056 #endif // IIR_BIQUAD_GREQ_HPP
Generated on Tue Jul 12 2022 22:59:36 by
