V001. 2017_11_30 10:21 Working code from Tuesday's lab session.
Fork of 2017_11_28_ELEC347_Coursework by
DSP Coursework ELEC347 2017-2018 Group members: Matthew Thewsey, Thomas Morris, Samuel Waggett, Christopher Hills .
Filter.hpp@18:b442994a01fd, 2017-12-06 (annotated)
- Committer:
- chills
- Date:
- Wed Dec 06 02:44:44 2017 +0000
- Revision:
- 18:b442994a01fd
- Parent:
- 13:db76473a3d76
Task 4.2 Cut Filter Implementation
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mwthewsey | 0:d39a06ca6bf1 | 1 | class FILTER |
mwthewsey | 0:d39a06ca6bf1 | 2 | { |
mwthewsey | 0:d39a06ca6bf1 | 3 | private: |
mwthewsey | 0:d39a06ca6bf1 | 4 | |
mwthewsey | 0:d39a06ca6bf1 | 5 | int _Fs; |
mwthewsey | 0:d39a06ca6bf1 | 6 | int _Fo; |
mwthewsey | 2:f6e49378dd8a | 7 | double _Boost; |
mwthewsey | 0:d39a06ca6bf1 | 8 | int _Q; |
mwthewsey | 2:f6e49378dd8a | 9 | double _Wo_d; |
mwthewsey | 2:f6e49378dd8a | 10 | double _Wo_d2; |
mwthewsey | 2:f6e49378dd8a | 11 | float _Com_Den; |
thomasmorris | 11:7efb6e4759cc | 12 | float _NC0,_NC1,_NC2,_DC1,_DC2; |
mwthewsey | 2:f6e49378dd8a | 13 | |
mwthewsey | 2:f6e49378dd8a | 14 | float _FilterOutput; |
mwthewsey | 0:d39a06ca6bf1 | 15 | float _centreTap; //internal node of filter |
mwthewsey | 0:d39a06ca6bf1 | 16 | float _b0; |
mwthewsey | 0:d39a06ca6bf1 | 17 | float _b1; |
mwthewsey | 0:d39a06ca6bf1 | 18 | float _b2; |
mwthewsey | 0:d39a06ca6bf1 | 19 | float _b3; |
mwthewsey | 0:d39a06ca6bf1 | 20 | float _b4; |
mwthewsey | 0:d39a06ca6bf1 | 21 | |
mwthewsey | 0:d39a06ca6bf1 | 22 | // A - Denominator coefficients |
mwthewsey | 0:d39a06ca6bf1 | 23 | float _a0; |
mwthewsey | 0:d39a06ca6bf1 | 24 | float _a1; |
mwthewsey | 0:d39a06ca6bf1 | 25 | float _a2; |
mwthewsey | 0:d39a06ca6bf1 | 26 | float _a3; |
mwthewsey | 0:d39a06ca6bf1 | 27 | float _a4; |
mwthewsey | 0:d39a06ca6bf1 | 28 | |
thomasmorris | 11:7efb6e4759cc | 29 | //Filter Parameters |
mwthewsey | 0:d39a06ca6bf1 | 30 | float _G; |
mwthewsey | 0:d39a06ca6bf1 | 31 | float _k; |
mwthewsey | 0:d39a06ca6bf1 | 32 | float _Wo; |
thomasmorris | 11:7efb6e4759cc | 33 | |
thomasmorris | 11:7efb6e4759cc | 34 | //Filter input Variables |
thomasmorris | 11:7efb6e4759cc | 35 | |
thomasmorris | 11:7efb6e4759cc | 36 | float _xn;//Current Filter input valuew |
thomasmorris | 11:7efb6e4759cc | 37 | float _xnm1;//Old filter inputs |
mwthewsey | 0:d39a06ca6bf1 | 38 | float _xnm2; |
mwthewsey | 0:d39a06ca6bf1 | 39 | float _xnm3; |
mwthewsey | 0:d39a06ca6bf1 | 40 | float _xnm4; |
mwthewsey | 0:d39a06ca6bf1 | 41 | |
thomasmorris | 11:7efb6e4759cc | 42 | //Filter Output Variables |
thomasmorris | 11:7efb6e4759cc | 43 | |
thomasmorris | 11:7efb6e4759cc | 44 | float _yn;//Current Filter Output Value |
mwthewsey | 0:d39a06ca6bf1 | 45 | float _ynm1; |
mwthewsey | 0:d39a06ca6bf1 | 46 | float _ynm2; |
mwthewsey | 0:d39a06ca6bf1 | 47 | float _ynm3; |
mwthewsey | 0:d39a06ca6bf1 | 48 | float _ynm4; |
mwthewsey | 0:d39a06ca6bf1 | 49 | |
mwthewsey | 0:d39a06ca6bf1 | 50 | |
mwthewsey | 0:d39a06ca6bf1 | 51 | public: |
thomasmorris | 11:7efb6e4759cc | 52 | FILTER(int Fs, int Fo, double Boost, int Q);//Constuctor |
thomasmorris | 11:7efb6e4759cc | 53 | ~FILTER();//Destuctor |
mwthewsey | 0:d39a06ca6bf1 | 54 | |
thomasmorris | 11:7efb6e4759cc | 55 | void Define_Filter();//Calculates the coefficeints of the filter |
thomasmorris | 11:7efb6e4759cc | 56 | void Print_Filter();//Print Filter Coefficients |
chills | 7:6cb27cce4c50 | 57 | |
mwthewsey | 2:f6e49378dd8a | 58 | //Setters |
thomasmorris | 11:7efb6e4759cc | 59 | |
thomasmorris | 11:7efb6e4759cc | 60 | void setvalue(float RAW_input);//Sets the latest xn sample input value |
thomasmorris | 11:7efb6e4759cc | 61 | void Update_Boost(double Boost_New);//Updates the Boost Value |
thomasmorris | 11:7efb6e4759cc | 62 | void Update_Q(int Q_New);//Sets the Value of Q |
thomasmorris | 11:7efb6e4759cc | 63 | void Update_Fo(int Fo_New);//Update Centre Frequency |
thomasmorris | 13:db76473a3d76 | 64 | |
thomasmorris | 13:db76473a3d76 | 65 | void coeff_update(float _Fo_Current,float _Boost_Current,float _Q_Current); |
thomasmorris | 13:db76473a3d76 | 66 | //void coeff_update();//Update the Filter Coeffiecients |
mwthewsey | 0:d39a06ca6bf1 | 67 | |
mwthewsey | 2:f6e49378dd8a | 68 | //Getters |
thomasmorris | 11:7efb6e4759cc | 69 | float getvalue(void);//returns yn |
thomasmorris | 11:7efb6e4759cc | 70 | double Get_Boost();//Gets the Boost Value |
thomasmorris | 11:7efb6e4759cc | 71 | int Get_Q();//Gets the value of Q |
thomasmorris | 11:7efb6e4759cc | 72 | int Get_Fo(); //Gets the current value of Centre Frequency |
mwthewsey | 0:d39a06ca6bf1 | 73 | }; |
mwthewsey | 0:d39a06ca6bf1 | 74 | |
mwthewsey | 0:d39a06ca6bf1 | 75 | |
thomasmorris | 11:7efb6e4759cc | 76 |