3 * Copyright 2002,2008 Free Software Foundation, Inc.
5 * This file is part of GNU Radio
7 * GNU Radio is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3, or (at your option)
12 * GNU Radio is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with GNU Radio; see the file COPYING. If not, write to
19 * the Free Software Foundation, Inc., 51 Franklin Street,
20 * Boston, MA 02110-1301, USA.
24 * \brief Finite Impulse Response (FIR) filter design functions.
27 %rename(firdes) gr_firdes;
33 WIN_HAMMING = 0, // max attenuation 53 dB
34 WIN_HANN = 1, // max attenuation 44 dB
35 WIN_BLACKMAN = 2, // max attenuation 74 dB
37 WIN_KAISER = 4, // max attenuation variable with beta, google it
38 WIN_BLACKMAN_hARRIS = 5,
41 // ... class methods ...
44 * \brief use "window method" to design a low-pass FIR filter
46 * \p gain: overall gain of filter (typically 1.0)
47 * \p sampling_freq: sampling freq (Hz)
48 * \p cutoff_freq: center of transition band (Hz)
49 * \p transition_width: width of transition band (Hz).
50 * The normalized width of the transition
51 * band is what sets the number of taps
52 * required. Narrow --> more taps
53 * \p window_type: What kind of window to use. Determines
54 * maximum attenuation and passband ripple.
55 * \p beta: parameter for Kaiser window
57 static std::vector<float>
58 low_pass (double gain,
60 double cutoff_freq, // Hz center of transition band
61 double transition_width, // Hz width of transition band
62 win_type window = WIN_HAMMING,
63 double beta = 6.76 // used only with Kaiser
64 ) throw(std::out_of_range);
67 * \brief use "window method" to design a low-pass FIR filter
68 * using alternative design criteria
69 * \p gain: overall gain of filter (typically 1.0)
70 * \p sampling_freq: sampling freq (Hz)
71 * \p cutoff_freq: center of transition band (Hz)
72 * \p transition_width: width of transition band (Hz).
73 * \p attenuation_dB out of band attenuation
74 * The normalized width of the transition
75 * band and the required stop band
76 * attenuation is what sets the number of taps
77 * required. Narrow --> more taps
78 * More attenuation --> more taps
79 * \p window_type: What kind of window to use. Determines
80 * maximum attenuation and passband ripple.
81 * \p beta: parameter for Kaiser window
83 static std::vector<float>
84 low_pass_2 (double gain,
86 double cutoff_freq, // Hz center of transition band
87 double transition_width, // Hz width of transition band
88 double attenuation_dB, // out of band attenuation
89 win_type window = WIN_HAMMING,
90 double beta = 6.76 // used only with Kaiser
91 ) throw(std::out_of_range);
94 * \brief use "window method" to design a high-pass FIR filter
96 * \p gain: overall gain of filter (typically 1.0)
97 * \p sampling_freq: sampling freq (Hz)
98 * \p cutoff_freq: center of transition band (Hz)
99 * \p transition_width: width of transition band (Hz).
100 * The normalized width of the transition
101 * band is what sets the number of taps
102 * required. Narrow --> more taps
103 * \p window_type: What kind of window to use. Determines
104 * maximum attenuation and passband ripple.
105 * \p beta: parameter for Kaiser window
108 static std::vector<float>
109 high_pass (double gain,
110 double sampling_freq,
111 double 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 ) throw(std::out_of_range);
118 * \brief use "window method" to design a high-pass FIR filter
120 * \p gain: overall gain of filter (typically 1.0)
121 * \p sampling_freq: sampling freq (Hz)
122 * \p cutoff_freq: center of transition band (Hz)
123 * \p transition_width: width of transition band (Hz).
124 * \p attenuation_dB out of band attenuation
125 * The normalized width of the transition
126 * band and the required stop band
127 * attenuation is what sets the number of taps
128 * required. Narrow --> more taps
129 * More attenuation --> more taps
130 * \p window_type: What kind of window to use. Determines
131 * maximum attenuation and passband ripple.
132 * \p beta: parameter for Kaiser window
135 static std::vector<float>
136 high_pass_2 (double gain,
137 double sampling_freq,
138 double cutoff_freq, // Hz center of transition band
139 double transition_width, // Hz width of transition band
140 double attenuation_dB, // out of band attenuation dB
141 win_type window = WIN_HAMMING,
142 double beta = 6.76); // used only with Kaiser
146 * \brief use "window method" to design a band-pass FIR filter
148 * \p gain: overall gain of filter (typically 1.0)
149 * \p sampling_freq: sampling freq (Hz)
150 * \p low_cutoff_freq: center of transition band (Hz)
151 * \p high_cutoff_freq: center of transition band (Hz)
152 * \p transition_width: width of transition band (Hz).
153 * The normalized width of the transition
154 * band is what sets the number of taps
155 * required. Narrow --> more taps
156 * \p window_type: What kind of window to use. Determines
157 * maximum attenuation and passband ripple.
158 * \p beta: parameter for Kaiser window
161 static std::vector<float>
162 band_pass (double gain,
163 double sampling_freq,
164 double low_cutoff_freq, // Hz center of transition band
165 double high_cutoff_freq, // Hz center of transition band
166 double transition_width, // Hz width of transition band
167 win_type window = WIN_HAMMING,
168 double beta = 6.76 // used only with Kaiser
169 ) throw(std::out_of_range);
173 * \brief use "window method" to design a band-pass FIR filter
175 * \p gain: overall gain of filter (typically 1.0)
176 * \p sampling_freq: sampling freq (Hz)
177 * \p low_cutoff_freq: center of transition band (Hz)
178 * \p high_cutoff_freq: center of transition band (Hz)
179 * \p transition_width: width of transition band (Hz).
180 * \p attenuation_dB out of band attenuation
181 * The normalized width of the transition
182 * band and the required stop band
183 * attenuation is what sets the number of taps
184 * required. Narrow --> more taps
185 * More attenuation --> more taps
186 * \p window_type: What kind of window to use. Determines
187 * maximum attenuation and passband ripple.
188 * \p beta: parameter for Kaiser window
191 static std::vector<float>
192 band_pass_2 (double gain,
193 double sampling_freq,
194 double low_cutoff_freq, // Hz beginning transition band
195 double high_cutoff_freq, // Hz beginning transition band
196 double transition_width, // Hz width of transition band
197 double attenuation_dB, // out of band attenuation dB
198 win_type window = WIN_HAMMING,
199 double beta = 6.76); // used only with Kaiser
202 * \brief use "window method" to design a band-reject FIR filter
204 * \p gain: overall gain of filter (typically 1.0)
205 * \p sampling_freq: sampling freq (Hz)
206 * \p low_cutoff_freq: center of transition band (Hz)
207 * \p high_cutoff_freq: center of transition band (Hz)
208 * \p transition_width: width of transition band (Hz).
209 * The normalized width of the transition
210 * band is what sets the number of taps
211 * required. Narrow --> more taps
212 * \p window_type: What kind of window to use. Determines
213 * maximum attenuation and passband ripple.
214 * \p beta: parameter for Kaiser window
217 static std::vector<gr_complex>
218 complex_band_pass (double gain,
219 double sampling_freq,
220 double low_cutoff_freq, // Hz center of transition band
221 double high_cutoff_freq, // Hz center of transition band
222 double transition_width, // Hz width of transition band
223 win_type window = WIN_HAMMING, // used only with Kaiser
225 ) throw(std::out_of_range);
229 * \brief use "window method" to design a complex band-pass FIR filter
231 * \p gain: overall gain of filter (typically 1.0)
232 * \p sampling_freq: sampling freq (Hz)
233 * \p low_cutoff_freq: center of transition band (Hz)
234 * \p high_cutoff_freq: center of transition band (Hz)
235 * \p transition_width: width of transition band (Hz).
236 * \p attenuation_dB out of band attenuation
237 * The normalized width of the transition
238 * band and the required stop band
239 * attenuation is what sets the number of taps
240 * required. Narrow --> more taps
241 * More attenuation --> more taps
242 * \p window_type: What kind of window to use. Determines
243 * maximum attenuation and passband ripple.
244 * \p beta: parameter for Kaiser window
247 static std::vector<gr_complex>
248 complex_band_pass_2 (double gain,
249 double sampling_freq,
250 double low_cutoff_freq, // Hz beginning transition band
251 double high_cutoff_freq, // Hz beginning transition band
252 double transition_width, // Hz width of transition band
253 double attenuation_dB, // out of band attenuation dB
254 win_type window = WIN_HAMMING,
255 double beta = 6.76); // used only with Kaiser
258 * \brief use "window method" to design a band-reject FIR filter
260 * \p gain: overall gain of filter (typically 1.0)
261 * \p sampling_freq: sampling freq (Hz)
262 * \p low_cutoff_freq: center of transition band (Hz)
263 * \p high_cutoff_freq: center of transition band (Hz)
264 * \p transition_width: width of transition band (Hz).
265 * The normalized width of the transition
266 * band is what sets the number of taps
267 * required. Narrow --> more taps
268 * \p window_type: What kind of window to use. Determines
269 * maximum attenuation and passband ripple.
270 * \p beta: parameter for Kaiser window
273 static std::vector<float>
274 band_reject (double gain,
275 double sampling_freq,
276 double low_cutoff_freq, // Hz center of transition band
277 double high_cutoff_freq, // Hz center of transition band
278 double transition_width, // Hz width of transition band
279 win_type window = WIN_HAMMING, // used only with Kaiser
281 ) throw(std::out_of_range);
285 * \brief use "window method" to design a band-reject FIR filter
287 * \p gain: overall gain of filter (typically 1.0)
288 * \p sampling_freq: sampling freq (Hz)
289 * \p low_cutoff_freq: center of transition band (Hz)
290 * \p high_cutoff_freq: center of transition band (Hz)
291 * \p transition_width: width of transition band (Hz).
292 * \p attenuation_dB out of band attenuation
293 * The normalized width of the transition
294 * band and the required stop band
295 * attenuation is what sets the number of taps
296 * required. Narrow --> more taps
297 * More attenuation --> more taps
298 * \p window_type: What kind of window to use. Determines
299 * maximum attenuation and passband ripple.
300 * \p beta: parameter for Kaiser window
303 static std::vector<float>
304 band_reject_2 (double gain,
305 double sampling_freq,
306 double low_cutoff_freq, // Hz beginning transition band
307 double high_cutoff_freq, // Hz beginning transition band
308 double transition_width, // Hz width of transition band
309 double attenuation_dB, // out of band attenuation dB
310 win_type window = WIN_HAMMING,
311 double beta = 6.76); // used only with Kaiser
313 /*!\brief design a Hilbert Transform Filter
315 * \p ntaps: Number of taps, must be odd
316 * \p window_type: What kind of window to use
317 * \p beta: Only used for Kaiser
319 static std::vector<float>
320 hilbert (unsigned int ntaps = 19,
321 win_type windowtype = WIN_RECTANGULAR,
323 ) throw(std::out_of_range);
326 * \brief design a Root Cosine FIR Filter (do we need a window?)
328 * \p gain: overall gain of filter (typically 1.0)
329 * \p sampling_freq: sampling freq (Hz)
330 * \p symbol rate: symbol rate, must be a factor of sample rate
331 * \p alpha: excess bandwidth factor
332 * \p ntaps: number of taps
334 static std::vector<float>
335 root_raised_cosine (double gain,
336 double sampling_freq,
337 double symbol_rate, // Symbol rate, NOT bitrate (unless BPSK)
338 double alpha, // Excess Bandwidth Factor
339 int ntaps) throw(std::out_of_range);
342 * \brief design a Gaussian filter
344 * \p gain: overall gain of filter (typically 1.0)
345 * \p symbols per bit: symbol rate, must be a factor of sample rate
346 * \p bt: BT bandwidth time product
347 * \p ntaps: number of taps
349 static std::vector<float>
350 gaussian (double gain,
352 double bt, // Bandwidth to bitrate ratio
353 int ntaps) throw(std::out_of_range);
356 * Return window given type, ntaps and optional beta.
358 static std::vector<float> gr_firdes::window (win_type type, int ntaps, double beta)
359 throw(std::runtime_error);