removed some warnings
[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             ) throw(std::out_of_range);
44
45   /*!
46    * \brief use "window method" to design a high-pass FIR filter
47    *
48    * \p gain:                   overall gain of filter (typically 1.0)
49    * \p sampling_freq:          sampling freq (Hz)
50    * \p cutoff_freq:            center of transition band (Hz)
51    * \p transition_width:       width of transition band (Hz).
52    *                            The normalized width of the transition
53    *                            band is what sets the number of taps
54    *                            required.  Narrow --> more taps
55    * \p window_type:            What kind of window to use. Determines
56    *                            maximum attenuation and passband ripple.
57    * \p beta:                   parameter for Kaiser window
58    */
59   static std::vector<float>
60   high_pass (double gain,
61              double sampling_freq,
62              double cutoff_freq,                // Hz center of transition band
63              double transition_width,           // Hz width of transition band
64              win_type window = WIN_HAMMING,
65              double beta = 6.76                 // used only with Kaiser
66              ) throw(std::out_of_range); 
67
68   /*!
69    * \brief use "window method" to design a band-pass FIR filter
70    *
71    * \p gain:                   overall gain of filter (typically 1.0)
72    * \p sampling_freq:          sampling freq (Hz)
73    * \p low_cutoff_freq:        center of transition band (Hz)
74    * \p high_cutoff_freq:       center of transition band (Hz)
75    * \p transition_width:       width of transition band (Hz).
76    *                            The normalized width of the transition
77    *                            band is what sets the number of taps
78    *                            required.  Narrow --> 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
82    */
83   static std::vector<float>
84   band_pass (double gain,
85              double sampling_freq,
86              double low_cutoff_freq,            // Hz center of transition band
87              double high_cutoff_freq,           // Hz center of transition band
88              double transition_width,           // Hz width of transition band
89              win_type window = WIN_HAMMING,
90              double beta = 6.76                 // used only with Kaiser
91              ) throw(std::out_of_range); 
92
93
94   /*!
95    * \brief use "window method" to design a band-reject FIR filter
96    *
97    * \p gain:                   overall gain of filter (typically 1.0)
98    * \p sampling_freq:          sampling freq (Hz)
99    * \p low_cutoff_freq:        center of transition band (Hz)
100    * \p high_cutoff_freq:       center of transition band (Hz)
101    * \p transition_width:       width of transition band (Hz).
102    *                            The normalized width of the transition
103    *                            band is what sets the number of taps
104    *                            required.  Narrow --> more taps
105    * \p window_type:            What kind of window to use. Determines
106    *                            maximum attenuation and passband ripple.
107    * \p beta:                   parameter for Kaiser window
108    */
109
110   static std::vector<gr_complex>
111   complex_band_pass (double gain,
112              double sampling_freq,
113              double low_cutoff_freq,            // Hz center of transition band
114              double high_cutoff_freq,           // Hz center of transition band
115              double transition_width,           // Hz width of transition band
116              win_type window = WIN_HAMMING,     // used only with Kaiser
117              double beta = 6.76
118              ) throw(std::out_of_range); 
119
120
121   /*!
122    * \brief use "window method" to design a band-reject FIR filter
123    *
124    * \p gain:                   overall gain of filter (typically 1.0)
125    * \p sampling_freq:          sampling freq (Hz)
126    * \p low_cutoff_freq:        center of transition band (Hz)
127    * \p high_cutoff_freq:       center of transition band (Hz)
128    * \p transition_width:       width of transition band (Hz).
129    *                            The normalized width of the transition
130    *                            band is what sets the number of taps
131    *                            required.  Narrow --> more taps
132    * \p window_type:            What kind of window to use. Determines
133    *                            maximum attenuation and passband ripple.
134    * \p beta:                   parameter for Kaiser window
135    */
136
137   static std::vector<float>
138   band_reject (double gain,
139                double sampling_freq,
140                double low_cutoff_freq,          // Hz center of transition band
141                double high_cutoff_freq,         // Hz center of transition band
142                double transition_width,         // Hz width of transition band
143                win_type window = WIN_HAMMING,   // used only with Kaiser
144                double beta = 6.76
145                ) throw(std::out_of_range);
146
147   /*!\brief design a Hilbert Transform Filter
148    *
149    * \p ntaps:                  Number of taps, must be odd
150    * \p window_type:            What kind of window to use
151    * \p beta:                   Only used for Kaiser
152    */
153   static std::vector<float>
154   hilbert (unsigned int ntaps = 19,
155            win_type windowtype = WIN_RECTANGULAR,
156            double beta = 6.76
157            ) throw(std::out_of_range);
158    
159   /*!
160    * \brief design a Root Cosine FIR Filter (do we need a window?)
161    *
162    * \p gain:                   overall gain of filter (typically 1.0)
163    * \p sampling_freq:          sampling freq (Hz)
164    * \p symbol rate:            symbol rate, must be a factor of sample rate
165    * \p alpha:                  excess bandwidth factor
166    * \p ntaps:                  number of taps
167    */
168   static std::vector<float>
169   root_raised_cosine (double gain,
170                       double sampling_freq,
171                       double symbol_rate,       // Symbol rate, NOT bitrate (unless BPSK)
172                       double alpha,             // Excess Bandwidth Factor
173                       int ntaps) throw(std::out_of_range);
174
175   /*!
176    * \brief design a Gaussian filter
177    *
178    * \p gain:                   overall gain of filter (typically 1.0)
179    * \p symbols per bit:        symbol rate, must be a factor of sample rate
180    * \p bt:                     BT bandwidth time product
181    * \p ntaps:                  number of taps
182    */
183   static std::vector<float>
184   gaussian (double gain,
185             double spb,       
186             double bt,              // Bandwidth to bitrate ratio
187             int ntaps) throw(std::out_of_range);
188
189   /*!
190    * Return window given type, ntaps and optional beta.
191    */
192   static std::vector<float> gr_firdes::window (win_type type, int ntaps, double beta) 
193     throw(std::runtime_error);
194 };