不韋 呂 / Mbed 2 deprecated UIT2_VariableFIR

Dependencies:   UIT_ACM1602NI UITDSP_ADDA mbed UIT_AQM1602

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers WindowingDesign.hpp Source File

WindowingDesign.hpp

00001 //------------------------------------------------------------------------------
00002 //  Design of FIR filter of 4 type passbands using window method -- Header
00003 //
00004 //  2014/12/07, Copyright (c) 2014 MIKAMI, Naoki
00005 //------------------------------------------------------------------------------
00006 
00007 #ifndef HAMMING_WINDOWING_DESIGN_HPP
00008 #define HAMMING_WINDOWING_DESIGN_HPP
00009 
00010 #include "mbed.h"
00011 
00012 namespace Mikami
00013 {
00014     class WindowingDesign
00015     {
00016     public:
00017         struct Coefs { float a1, a2, b1; };
00018         enum Type { LPF, HPF, BPF, BRF };
00019 
00020         // Constructor
00021         WindowingDesign(int order, float fs);
00022 
00023         //Destructor
00024         ~WindowingDesign()
00025         {
00026             delete[] hm_;
00027             delete[] wn_;
00028         }
00029 
00030         // Execution of design
00031         void Design(int order, Type pb, float fc1, float fc2,
00032                     float hk[]);
00033 
00034     private:
00035         static const float PI_ = 3.1415926536f;
00036         const float FS_;    // Sampling frequency
00037         const float PI_FS_;
00038         
00039         float *hm_;     // For coefficients
00040         float *wn_;     // For Windwo
00041                 
00042         int order_;     // Order
00043         float fC_;      // Cutoff frequency
00044         
00045         // Calculation of coefficients for LPF
00046         void LpfCoefficients();
00047         // Transform LPF to HPF, BPF, or BRF
00048         void Transform(Type pb, float w0);
00049         // Hamming window
00050         void HammWindow();
00051     };
00052 }
00053 #endif  // HAMMING_WINDOWING_DESIGN_HPP