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: UIT_IIR_Filter UIT_ACM1602NI UITDSP_ADDA mbed UIT_AQM1602
BilinearDesignLH.hpp
00001 //------------------------------------------------------------------------------ 00002 // Design of Butterworth LPF and HPF using bilinear transform -- Header 00003 // 00004 // 2014/06/29, Copyright (c) 2014 MIKAMI, Naoki 00005 //------------------------------------------------------------------------------ 00006 00007 #ifndef BILINEAR_BUTTERWORTH_HPP 00008 #define BILINEAR_BUTTERWORTH_HPP 00009 00010 #include "mbed.h" 00011 #include <complex> // requisite 00012 00013 namespace Mikami 00014 { 00015 typedef complex<float> Complex; // define "Complex" 00016 00017 class BilinearDesign 00018 { 00019 public: 00020 struct Coefs { float a1, a2, b1; }; 00021 enum Type { LPF, HPF }; 00022 00023 // Constructor 00024 BilinearDesign(int order, float fs, Type pb) 00025 : PI_FS_(PI_/fs), ORDER_(order), PB_(pb) 00026 { 00027 sP_ = new Complex[order/2]; 00028 zP_ = new Complex[order/2]; 00029 ck_ = new Coefs[order/2]; 00030 } 00031 00032 // Destractor 00033 ~BilinearDesign() 00034 { 00035 delete[] sP_; 00036 delete[] zP_; 00037 delete[] ck_; 00038 } 00039 00040 // Execution of design 00041 void Execute(float fc, Coefs c[], float& g); 00042 00043 private: 00044 static const float PI_ = 3.1415926536f; 00045 const float PI_FS_; 00046 const int ORDER_; 00047 const Type PB_; 00048 00049 Complex* sP_; // Poles on s-plane 00050 Complex* zP_; // Poles on z-plane 00051 Coefs* ck_; // Coefficients of transfer function for cascade form 00052 float gain_; // Gain factor for cascade form 00053 00054 void Butterworth(); 00055 void Bilinear(float fc); 00056 void ToCascade(); 00057 void GetGain(); 00058 void GetCoefs(Coefs c[], float& gain); 00059 }; 00060 } 00061 #endif // BILINEAR_BUTTERWORTH_HPP 00062
Generated on Thu Jul 14 2022 01:14:10 by
1.7.2