Imported Upstream version 3.2.2
[debian/gnuradio] / gnuradio-core / src / lib / general / gr_firdes.i
index a0ea2f453340d12372d46411291f64a2c92208d4..d49434adf06313abef18ff9cdeb994b982a5aefe 100644 (file)
@@ -1,4 +1,24 @@
 /* -*- C++ -*- */
+/*
+ * Copyright 2002,2008 Free Software Foundation, Inc.
+ * 
+ * This file is part of GNU Radio
+ * 
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ * 
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
 
 /*!
  * \brief Finite Impulse Response (FIR) filter design functions.
@@ -14,7 +34,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 variable with beta, google it
+    WIN_KAISER = 4,     // max attenuation variable with beta, google it
+    WIN_BLACKMAN_hARRIS = 5,
   };
 
   // ... class methods ...
@@ -39,7 +60,35 @@ class gr_firdes {
            double cutoff_freq,         // Hz center of transition band
            double transition_width,    // Hz width of transition band
            win_type window = WIN_HAMMING,
-           double beta = 6.76);                // used only with Kaiser
+           double beta = 6.76          // used only with Kaiser
+           ) throw(std::out_of_range);
+
+  /*!
+   * \brief use "window method" to design a low-pass FIR filter
+   *  using alternative design criteria
+   * \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>
+  low_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
+           win_type window = WIN_HAMMING,
+           double beta = 6.76          // used only with Kaiser
+           ) throw(std::out_of_range);
 
   /*!
    * \brief use "window method" to design a high-pass FIR filter
@@ -55,14 +104,44 @@ 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,
             double cutoff_freq,                // Hz center of transition band
             double transition_width,           // Hz width of transition band
             win_type window = WIN_HAMMING,
+            double beta = 6.76                 // used only with Kaiser
+            ) throw(std::out_of_range); 
+
+  /*!
+   * \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
    *
@@ -78,6 +157,7 @@ class gr_firdes {
    *                           maximum attenuation and passband ripple.
    * \p beta:                  parameter for Kaiser window
    */
+
   static std::vector<float>
   band_pass (double gain,
             double sampling_freq,
@@ -85,8 +165,38 @@ class gr_firdes {
             double high_cutoff_freq,           // Hz center of transition band
             double transition_width,           // Hz width of transition band
             win_type window = WIN_HAMMING,
-            double beta = 6.76);               // used only with Kaiser
+            double beta = 6.76                 // used only with Kaiser
+            ) throw(std::out_of_range); 
+
+
+  /*!
+   * \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 band-reject FIR filter
@@ -110,10 +220,40 @@ class gr_firdes {
             double low_cutoff_freq,            // Hz center of transition band
             double high_cutoff_freq,           // Hz center of transition band
             double transition_width,           // Hz width of transition band
+            win_type window = WIN_HAMMING,     // used only with Kaiser
+            double beta = 6.76
+            ) throw(std::out_of_range); 
+
+
+  /*!
+   * \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
    *
@@ -136,6 +276,37 @@ class gr_firdes {
               double low_cutoff_freq,          // Hz center of transition band
               double high_cutoff_freq,         // Hz center of transition band
               double transition_width,         // Hz width of transition band
+              win_type window = WIN_HAMMING,   // used only with Kaiser
+              double beta = 6.76
+              ) throw(std::out_of_range);
+
+
+  /*!
+   * \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
 
@@ -146,9 +317,10 @@ 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);
+          double beta = 6.76
+          ) throw(std::out_of_range);
    
   /*!
    * \brief design a Root Cosine FIR Filter (do we need a window?)
@@ -164,7 +336,7 @@ class gr_firdes {
                      double sampling_freq,
                      double symbol_rate,       // Symbol rate, NOT bitrate (unless BPSK)
                      double alpha,             // Excess Bandwidth Factor
-                     int ntaps);
+                     int ntaps) throw(std::out_of_range);
 
   /*!
    * \brief design a Gaussian filter
@@ -178,10 +350,11 @@ class gr_firdes {
   gaussian (double gain,
            double spb,       
            double bt,              // Bandwidth to bitrate ratio
-           int ntaps);
+           int ntaps) throw(std::out_of_range);
 
   /*!
    * Return window given type, ntaps and optional beta.
    */
-  static std::vector<float> gr_firdes::window (win_type type, int ntaps, double beta);
+  static std::vector<float> gr_firdes::window (win_type type, int ntaps, double beta) 
+    throw(std::runtime_error);
 };