Imported Upstream version 3.2.2
[debian/gnuradio] / gnuradio-core / src / lib / general / gr_firdes.h
index 831c0ee688a766bb3304eada42fd8fb8941c0dd6..de775bd0719e054f9678fc70d67ad0c6623440ca 100644 (file)
@@ -1,6 +1,6 @@
 /* -*- c++ -*- */
 /*
- * Copyright 2002 Free Software Foundation, Inc.
+ * Copyright 2002,2008 Free Software Foundation, Inc.
  * 
  * This file is part of GNU Radio
  * 
@@ -29,6 +29,7 @@
 
 /*!
  * \brief Finite Impulse Response (FIR) filter design functions.
+ * \ingroup filter_design
  */
 
 class gr_firdes {
@@ -39,7 +40,8 @@ class gr_firdes {
     WIN_HANN = 1,      // max attenuation 44 dB
     WIN_BLACKMAN = 2,  // max attenuation 74 dB
     WIN_RECTANGULAR = 3,
-    WIN_KAISER = 4      // max attenuation a function of beta, google it
+    WIN_KAISER = 4,     // max attenuation a function of beta, google it
+    WIN_BLACKMAN_hARRIS = 5,
   };
 
 
@@ -67,6 +69,33 @@ class gr_firdes {
            win_type window = WIN_HAMMING,
            double beta = 6.76);                // used only with Kaiser
 
+  /*!
+   * \brief use "window method" to design a low-pass FIR filter
+   *
+   * \p gain:                  overall gain of filter (typically 1.0)
+   * \p sampling_freq:         sampling freq (Hz)
+   * \p cutoff_freq:           center of transition band (Hz)
+   * \p transition_width:      width of transition band (Hz).
+   * \p attenuation_dB          required stopband attenuation
+   *                           The normalized width of the transition
+   *                           band and the required stop band
+   *                            attenuation is what sets the number of taps
+   *                           required.  Narrow --> more taps
+   *                            More attenuatin --> more taps
+   * \p window_type:           What kind of window to use. Determines
+   *                           maximum attenuation and passband ripple.
+   * \p beta:                  parameter for Kaiser window
+   */
+
+  static std::vector<float>
+  low_pass_2 (double gain,
+           double sampling_freq,
+           double cutoff_freq,         // Hz beginning transition band
+           double transition_width,    // Hz width of transition band
+           double attenuation_dB,      // out of band attenuation dB
+           win_type window = WIN_HAMMING,
+           double beta = 6.76);                // used only with Kaiser
+
   /*!
    * \brief use "window method" to design a high-pass FIR filter
    *
@@ -81,6 +110,7 @@ class gr_firdes {
    *                           maximum attenuation and passband ripple.
    * \p beta:                  parameter for Kaiser window
    */
+
   static std::vector<float>
   high_pass (double gain,
             double sampling_freq,
@@ -89,6 +119,33 @@ class gr_firdes {
             win_type window = WIN_HAMMING,
             double beta = 6.76);               // used only with Kaiser
 
+  /*!
+   * \brief use "window method" to design a high-pass FIR filter
+   *
+   * \p gain:                  overall gain of filter (typically 1.0)
+   * \p sampling_freq:         sampling freq (Hz)
+   * \p cutoff_freq:           center of transition band (Hz)
+   * \p transition_width:      width of transition band (Hz).
+   * \p attenuation_dB          out of band attenuation
+   *                           The normalized width of the transition
+   *                           band and the required stop band
+   *                            attenuation is what sets the number of taps
+   *                           required.  Narrow --> more taps
+   *                            More attenuation --> more taps
+   * \p window_type:           What kind of window to use. Determines
+   *                           maximum attenuation and passband ripple.
+   * \p beta:                  parameter for Kaiser window
+   */
+
+  static std::vector<float>
+  high_pass_2 (double gain,
+            double sampling_freq,
+            double cutoff_freq,                // Hz center of transition band
+            double transition_width,           // Hz width of transition band
+            double attenuation_dB,             // out of band attenuation dB
+            win_type window = WIN_HAMMING,
+            double beta = 6.76);               // used only with Kaiser
+
   /*!
    * \brief use "window method" to design a band-pass FIR filter
    *
@@ -113,6 +170,34 @@ class gr_firdes {
             win_type window = WIN_HAMMING,
             double beta = 6.76);               // used only with Kaiser
 
+  /*!
+   * \brief use "window method" to design a band-pass FIR filter
+   *
+   * \p gain:                  overall gain of filter (typically 1.0)
+   * \p sampling_freq:         sampling freq (Hz)
+   * \p low_cutoff_freq:       center of transition band (Hz)
+   * \p high_cutoff_freq:      center of transition band (Hz)
+   * \p transition_width:      width of transition band (Hz).
+   * \p attenuation_dB          out of band attenuation
+   *                           The normalized width of the transition
+   *                           band and the required stop band
+   *                            attenuation is what sets the number of taps
+   *                           required.  Narrow --> more taps
+   *                            More attenuation --> more taps
+   * \p window_type:           What kind of window to use. Determines
+   *                           maximum attenuation and passband ripple.
+   * \p beta:                  parameter for Kaiser window
+   */
+
+  static std::vector<float>
+  band_pass_2 (double gain,
+            double sampling_freq,
+            double low_cutoff_freq,            // Hz beginning transition band
+            double high_cutoff_freq,           // Hz beginning transition band
+            double transition_width,           // Hz width of transition band
+            double attenuation_dB,             // out of band attenuation dB
+            win_type window = WIN_HAMMING,
+            double beta = 6.76);               // used only with Kaiser
 
   /*!
    * \brief use "window method" to design a complex band-pass FIR filter
@@ -139,6 +224,34 @@ class gr_firdes {
             win_type window = WIN_HAMMING,
             double beta = 6.76);               // used only with Kaiser
 
+  /*!
+   * \brief use "window method" to design a complex band-pass FIR filter
+   *
+   * \p gain:                  overall gain of filter (typically 1.0)
+   * \p sampling_freq:         sampling freq (Hz)
+   * \p low_cutoff_freq:       center of transition band (Hz)
+   * \p high_cutoff_freq:      center of transition band (Hz)
+   * \p transition_width:      width of transition band (Hz).
+   * \p attenuation_dB          out of band attenuation
+   *                           The normalized width of the transition
+   *                           band and the required stop band
+   *                            attenuation is what sets the number of taps
+   *                           required.  Narrow --> more taps
+   *                            More attenuation --> more taps
+   * \p window_type:           What kind of window to use. Determines
+   *                           maximum attenuation and passband ripple.
+   * \p beta:                  parameter for Kaiser window
+   */
+
+  static std::vector<gr_complex>
+  complex_band_pass_2 (double gain,
+            double sampling_freq,
+            double low_cutoff_freq,            // Hz beginning transition band
+            double high_cutoff_freq,           // Hz beginning transition band
+            double transition_width,           // Hz width of transition band
+            double attenuation_dB,             // out of band attenuation dB
+            win_type window = WIN_HAMMING,
+            double beta = 6.76);               // used only with Kaiser
 
   /*!
    * \brief use "window method" to design a band-reject FIR filter
@@ -165,6 +278,35 @@ class gr_firdes {
               win_type window = WIN_HAMMING,
               double beta = 6.76);             // used only with Kaiser
 
+  /*!
+   * \brief use "window method" to design a band-reject FIR filter
+   *
+   * \p gain:                  overall gain of filter (typically 1.0)
+   * \p sampling_freq:         sampling freq (Hz)
+   * \p low_cutoff_freq:       center of transition band (Hz)
+   * \p high_cutoff_freq:      center of transition band (Hz)
+   * \p transition_width:      width of transition band (Hz).
+   * \p attenuation_dB          out of band attenuation
+   *                           The normalized width of the transition
+   *                           band and the required stop band
+   *                            attenuation is what sets the number of taps
+   *                           required.  Narrow --> more taps
+   *                            More attenuation --> more taps
+   * \p window_type:           What kind of window to use. Determines
+   *                           maximum attenuation and passband ripple.
+   * \p beta:                  parameter for Kaiser window
+   */
+
+  static std::vector<float>
+  band_reject_2 (double gain,
+              double sampling_freq,
+              double low_cutoff_freq,          // Hz beginning transition band
+              double high_cutoff_freq,         // Hz beginning transition band
+              double transition_width,         // Hz width of transition band
+              double attenuation_dB,           // out of band attenuation dB
+              win_type window = WIN_HAMMING,
+              double beta = 6.76);             // used only with Kaiser
+
   /*!\brief design a Hilbert Transform Filter
    *
    * \p ntaps:                  Number of taps, must be odd
@@ -172,7 +314,7 @@ class gr_firdes {
    * \p beta:                   Only used for Kaiser
    */
   static std::vector<float>
-  hilbert (unsigned int ntaps,
+  hilbert (unsigned int ntaps = 19,
           win_type windowtype = WIN_RECTANGULAR,
           double beta = 6.76);
    
@@ -220,6 +362,10 @@ private:
   static int compute_ntaps (double sampling_freq,
                            double transition_width,
                            win_type window_type, double beta);
+
+  static int compute_ntaps_windes (double sampling_freq,
+                                  double transition_width,
+                                  double attenuation_dB);
 };
 
 #endif