Imported Upstream version 3.0
[debian/gnuradio] / gnuradio-core / src / lib / general / gr_firdes.i
1 /* -*- C++ -*- */
2
3 /*!
4  * \brief Finite Impulse Response (FIR) filter design functions.
5  */
6
7 %rename(firdes) gr_firdes;
8
9 class gr_firdes {
10  public:
11
12   enum win_type {
13     WIN_HAMMING = 0,    // max attenuation 53 dB
14     WIN_HANN = 1,       // max attenuation 44 dB
15     WIN_BLACKMAN = 2,   // max attenuation 74 dB
16     WIN_RECTANGULAR = 3,
17     WIN_KAISER = 4      // max attenuation variable with beta, google it
18   };
19
20   // ... class methods ...
21
22   /*!
23    * \brief use "window method" to design a low-pass FIR filter
24    *
25    * \p gain:                   overall gain of filter (typically 1.0)
26    * \p sampling_freq:          sampling freq (Hz)
27    * \p cutoff_freq:            center of transition band (Hz)
28    * \p transition_width:       width of transition band (Hz).
29    *                            The normalized width of the transition
30    *                            band is what sets the number of taps
31    *                            required.  Narrow --> more taps
32    * \p window_type:            What kind of window to use. Determines
33    *                            maximum attenuation and passband ripple.
34    * \p beta:                   parameter for Kaiser window
35    */
36   static std::vector<float>
37   low_pass (double gain,
38             double sampling_freq,
39             double cutoff_freq,         // Hz center of transition band
40             double transition_width,    // Hz width of transition band
41             win_type window = WIN_HAMMING,
42             double beta = 6.76);                // used only with Kaiser
43
44   /*!
45    * \brief use "window method" to design a high-pass FIR filter
46    *
47    * \p gain:                   overall gain of filter (typically 1.0)
48    * \p sampling_freq:          sampling freq (Hz)
49    * \p cutoff_freq:            center of transition band (Hz)
50    * \p transition_width:       width of transition band (Hz).
51    *                            The normalized width of the transition
52    *                            band is what sets the number of taps
53    *                            required.  Narrow --> more taps
54    * \p window_type:            What kind of window to use. Determines
55    *                            maximum attenuation and passband ripple.
56    * \p beta:                   parameter for Kaiser window
57    */
58   static std::vector<float>
59   high_pass (double gain,
60              double sampling_freq,
61              double cutoff_freq,                // Hz center of transition band
62              double transition_width,           // Hz width of transition band
63              win_type window = WIN_HAMMING,
64              double beta = 6.76);               // used only with Kaiser
65
66   /*!
67    * \brief use "window method" to design a band-pass FIR filter
68    *
69    * \p gain:                   overall gain of filter (typically 1.0)
70    * \p sampling_freq:          sampling freq (Hz)
71    * \p low_cutoff_freq:        center of transition band (Hz)
72    * \p high_cutoff_freq:       center of transition band (Hz)
73    * \p transition_width:       width of transition band (Hz).
74    *                            The normalized width of the transition
75    *                            band is what sets the number of taps
76    *                            required.  Narrow --> more taps
77    * \p window_type:            What kind of window to use. Determines
78    *                            maximum attenuation and passband ripple.
79    * \p beta:                   parameter for Kaiser window
80    */
81   static std::vector<float>
82   band_pass (double gain,
83              double sampling_freq,
84              double low_cutoff_freq,            // Hz center of transition band
85              double high_cutoff_freq,           // Hz center of transition band
86              double transition_width,           // Hz width of transition band
87              win_type window = WIN_HAMMING,
88              double beta = 6.76);               // used only with Kaiser
89
90
91   /*!
92    * \brief use "window method" to design a band-reject FIR filter
93    *
94    * \p gain:                   overall gain of filter (typically 1.0)
95    * \p sampling_freq:          sampling freq (Hz)
96    * \p low_cutoff_freq:        center of transition band (Hz)
97    * \p high_cutoff_freq:       center of transition band (Hz)
98    * \p transition_width:       width of transition band (Hz).
99    *                            The normalized width of the transition
100    *                            band is what sets the number of taps
101    *                            required.  Narrow --> more taps
102    * \p window_type:            What kind of window to use. Determines
103    *                            maximum attenuation and passband ripple.
104    * \p beta:                   parameter for Kaiser window
105    */
106
107   static std::vector<gr_complex>
108   complex_band_pass (double gain,
109              double sampling_freq,
110              double low_cutoff_freq,            // Hz center of transition band
111              double high_cutoff_freq,           // Hz center of transition band
112              double transition_width,           // Hz width of transition band
113              win_type window = WIN_HAMMING,
114              double beta = 6.76);               // used only with Kaiser
115
116
117   /*!
118    * \brief use "window method" to design a band-reject FIR filter
119    *
120    * \p gain:                   overall gain of filter (typically 1.0)
121    * \p sampling_freq:          sampling freq (Hz)
122    * \p low_cutoff_freq:        center of transition band (Hz)
123    * \p high_cutoff_freq:       center of transition band (Hz)
124    * \p transition_width:       width of transition band (Hz).
125    *                            The normalized width of the transition
126    *                            band is what sets the number of taps
127    *                            required.  Narrow --> more taps
128    * \p window_type:            What kind of window to use. Determines
129    *                            maximum attenuation and passband ripple.
130    * \p beta:                   parameter for Kaiser window
131    */
132
133   static std::vector<float>
134   band_reject (double gain,
135                double sampling_freq,
136                double low_cutoff_freq,          // Hz center of transition band
137                double high_cutoff_freq,         // Hz center of transition band
138                double transition_width,         // Hz width of transition band
139                win_type window = WIN_HAMMING,
140                double beta = 6.76);             // used only with Kaiser
141
142   /*!\brief design a Hilbert Transform Filter
143    *
144    * \p ntaps:                  Number of taps, must be odd
145    * \p window_type:            What kind of window to use
146    * \p beta:                   Only used for Kaiser
147    */
148   static std::vector<float>
149   hilbert (unsigned int ntaps,
150            win_type windowtype = WIN_RECTANGULAR,
151            double beta = 6.76);
152    
153   /*!
154    * \brief design a Root Cosine FIR Filter (do we need a window?)
155    *
156    * \p gain:                   overall gain of filter (typically 1.0)
157    * \p sampling_freq:          sampling freq (Hz)
158    * \p symbol rate:            symbol rate, must be a factor of sample rate
159    * \p alpha:                  excess bandwidth factor
160    * \p ntaps:                  number of taps
161    */
162   static std::vector<float>
163   root_raised_cosine (double gain,
164                       double sampling_freq,
165                       double symbol_rate,       // Symbol rate, NOT bitrate (unless BPSK)
166                       double alpha,             // Excess Bandwidth Factor
167                       int ntaps);
168
169   /*!
170    * \brief design a Gaussian filter
171    *
172    * \p gain:                   overall gain of filter (typically 1.0)
173    * \p symbols per bit:        symbol rate, must be a factor of sample rate
174    * \p bt:                     BT bandwidth time product
175    * \p ntaps:                  number of taps
176    */
177   static std::vector<float>
178   gaussian (double gain,
179             double spb,       
180             double bt,              // Bandwidth to bitrate ratio
181             int ntaps);
182
183   /*!
184    * Return window given type, ntaps and optional beta.
185    */
186   static std::vector<float> gr_firdes::window (win_type type, int ntaps, double beta);
187 };