Cutoff frequency variable LPF, HPF, BPF, and BRF by FIR 160th-order filter.

Dependencies:   UIT_ACM1602NI UITDSP_ADDA mbed UIT_AQM1602

Revision:
0:ca94cfc90365
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/WindowingDesign/WindowingDesign.hpp	Mon Dec 08 08:14:48 2014 +0000
@@ -0,0 +1,53 @@
+//------------------------------------------------------------------------------
+//  Design of FIR filter of 4 type passbands using window method -- Header
+//
+//  2014/12/07, Copyright (c) 2014 MIKAMI, Naoki
+//------------------------------------------------------------------------------
+
+#ifndef HAMMING_WINDOWING_DESIGN_HPP
+#define HAMMING_WINDOWING_DESIGN_HPP
+
+#include "mbed.h"
+
+namespace Mikami
+{
+    class WindowingDesign
+    {
+    public:
+        struct Coefs { float a1, a2, b1; };
+        enum Type { LPF, HPF, BPF, BRF };
+
+        // Constructor
+        WindowingDesign(int order, float fs);
+
+        //Destructor
+        ~WindowingDesign()
+        {
+            delete[] hm_;
+            delete[] wn_;
+        }
+
+        // Execution of design
+        void Design(int order, Type pb, float fc1, float fc2,
+                    float hk[]);
+
+    private:
+        static const float PI_ = 3.1415926536f;
+        const float FS_;    // Sampling frequency
+        const float PI_FS_;
+        
+        float *hm_;     // For coefficients
+        float *wn_;     // For Windwo
+                
+        int order_;     // Order
+        float fC_;      // Cutoff frequency
+        
+        // Calculation of coefficients for LPF
+        void LpfCoefficients();
+        // Transform LPF to HPF, BPF, or BRF
+        void Transform(Type pb, float w0);
+        // Hamming window
+        void HammWindow();
+    };
+}
+#endif  // HAMMING_WINDOWING_DESIGN_HPP