Skip to content

Commit d12a1df

Browse files
committedSep 25, 2013
filter: Fixing the Hilbert transform and QA.
The hilbert_fc block now takes the type of window as a parameter. Defaults to Hamming to a) maximize sidelobe suppression and b) that's how it's always behaved. The QA codes were fixed to create Hilbert transform taps using Hamming window to account for the previous commits change to the rectangular window.
1 parent b0c7df3 commit d12a1df

File tree

6 files changed

+87
-34
lines changed

6 files changed

+87
-34
lines changed
 

‎gr-filter/grc/filter_hilbert_fc.xml

+56-18
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,60 @@
55
###################################################
66
-->
77
<block>
8-
<name>Hilbert</name>
9-
<key>hilbert_fc</key>
10-
<import>from gnuradio import filter</import>
11-
<make>filter.hilbert_fc($num_taps)</make>
12-
<param>
13-
<name>Num Taps</name>
14-
<key>num_taps</key>
15-
<value>64</value>
16-
<type>int</type>
17-
</param>
18-
<sink>
19-
<name>in</name>
20-
<type>float</type>
21-
</sink>
22-
<source>
23-
<name>out</name>
24-
<type>complex</type>
25-
</source>
8+
<name>Hilbert</name>
9+
<key>hilbert_fc</key>
10+
<import>from gnuradio import filter</import>
11+
<make>filter.hilbert_fc($num_taps, $win, $beta)</make>
12+
<param>
13+
<name>Num Taps</name>
14+
<key>num_taps</key>
15+
<value>65</value>
16+
<type>int</type>
17+
</param>
18+
<param>
19+
<name>Window</name>
20+
<key>win</key>
21+
<value>firdes.WIN_HAMMING</value>
22+
<type>int</type>
23+
<hide>part</hide>
24+
<option>
25+
<name>Hamming</name>
26+
<key>firdes.WIN_HAMMING</key>
27+
</option>
28+
<option>
29+
<name>Hann</name>
30+
<key>firdes.WIN_HANN</key>
31+
</option>
32+
<option>
33+
<name>Blackman</name>
34+
<key>firdes.WIN_BLACKMAN</key>
35+
</option>
36+
<option>
37+
<name>Blackman-harris</name>
38+
<key>firdes.WIN_BLACKMAN_hARRIS</key>
39+
</option>
40+
<option>
41+
<name>Rectangular</name>
42+
<key>firdes.WIN_RECTANGULAR</key>
43+
</option>
44+
<option>
45+
<name>Kaiser</name>
46+
<key>firdes.WIN_KAISER</key>
47+
</option>
48+
</param>
49+
<param>
50+
<name>Beta</name>
51+
<key>beta</key>
52+
<value>6.76</value>
53+
<type>real</type>
54+
<hide>part</hide>
55+
</param>
56+
<sink>
57+
<name>in</name>
58+
<type>float</type>
59+
</sink>
60+
<source>
61+
<name>out</name>
62+
<type>complex</type>
63+
</source>
2664
</block>

‎gr-filter/include/gnuradio/filter/hilbert_fc.h

+8-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#define INCLUDED_FILTER_HILBERT_FC_H
2525

2626
#include <gnuradio/filter/api.h>
27+
#include <gnuradio/filter/firdes.h>
2728
#include <gnuradio/sync_block.h>
2829
#include <gnuradio/types.h>
2930

@@ -47,8 +48,14 @@ namespace gr {
4748

4849
/*!
4950
* Build a Hilbert transformer filter block.
51+
*
52+
* \param ntaps The number of taps for the filter.
53+
* \param window Window type (see firdes::win_type) to use.
54+
* \param beta Beta value for a Kaiser window.
5055
*/
51-
static sptr make(unsigned int ntaps);
56+
static sptr make(unsigned int ntaps,
57+
firdes::win_type window=firdes::WIN_HAMMING,
58+
double beta=6.76);
5259
};
5360

5461
} /* namespace filter */

‎gr-filter/lib/hilbert_fc_impl.cc

+15-9
Original file line numberDiff line numberDiff line change
@@ -25,26 +25,32 @@
2525
#endif
2626

2727
#include "hilbert_fc_impl.h"
28-
#include <gnuradio/filter/firdes.h>
2928
#include <gnuradio/io_signature.h>
3029
#include <volk/volk.h>
3130

3231
namespace gr {
3332
namespace filter {
3433

35-
hilbert_fc::sptr hilbert_fc::make(unsigned int ntaps)
34+
hilbert_fc::sptr
35+
hilbert_fc::make(unsigned int ntaps,
36+
firdes::win_type window,
37+
double beta)
3638
{
37-
return gnuradio::get_initial_sptr(new hilbert_fc_impl(ntaps));
39+
return gnuradio::get_initial_sptr
40+
(new hilbert_fc_impl(ntaps, window, beta));
3841
}
3942

40-
hilbert_fc_impl::hilbert_fc_impl(unsigned int ntaps)
41-
: sync_block ("hilbert_fc",
42-
io_signature::make (1, 1, sizeof(float)),
43-
io_signature::make (1, 1, sizeof(gr_complex))),
43+
hilbert_fc_impl::hilbert_fc_impl(unsigned int ntaps,
44+
firdes::win_type window,
45+
double beta)
46+
: sync_block("hilbert_fc",
47+
io_signature::make(1, 1, sizeof(float)),
48+
io_signature::make(1, 1, sizeof(gr_complex))),
4449
d_ntaps(ntaps | 0x1) // ensure ntaps is odd
4550
{
46-
d_hilb = new kernel::fir_filter_fff(1, firdes::hilbert(d_ntaps));
47-
set_history (d_ntaps);
51+
d_hilb = new kernel::fir_filter_fff(1,
52+
firdes::hilbert(d_ntaps, window, beta));
53+
set_history(d_ntaps);
4854

4955
const int alignment_multiple =
5056
volk_get_alignment() / sizeof(float);

‎gr-filter/lib/hilbert_fc_impl.h

+4-2
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,10 @@ namespace gr {
3737
kernel::fir_filter_fff *d_hilb;
3838

3939
public:
40-
hilbert_fc_impl(unsigned int ntaps);
41-
40+
hilbert_fc_impl(unsigned int ntaps,
41+
firdes::win_type window=firdes::WIN_HAMMING,
42+
double beta=6.76);
43+
4244
~hilbert_fc_impl();
4345

4446
int work(int noutput_items,

‎gr-filter/python/filter/qa_filter_delay_fc.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ def test_001_filter_delay_one_input(self):
118118
dst2 = blocks.vector_sink_c()
119119

120120
# calculate taps
121-
taps = filter.firdes_hilbert(ntaps)
121+
taps = filter.firdes.hilbert(ntaps, filter.firdes.WIN_HAMMING)
122122
hd = filter.filter_delay_fc(taps)
123123

124124
tb.connect(src1, hd)
@@ -209,7 +209,7 @@ def test_002_filter_delay_two_inputs(self):
209209
dst2 = blocks.vector_sink_c()
210210

211211
# calculate taps
212-
taps = filter.firdes_hilbert(ntaps)
212+
taps = filter.firdes.hilbert(ntaps, filter.firdes.WIN_HAMMING)
213213
hd = filter.filter_delay_fc(taps)
214214

215215
tb.connect(src1, (hd,0))
@@ -301,7 +301,7 @@ def test_003_filter_delay_two_inputs(self):
301301
src1 = blocks.vector_source_f(data1)
302302
src2 = blocks.vector_source_f(data2)
303303

304-
taps = filter.firdes_hilbert(ntaps)
304+
taps = filter.firdes.hilbert(ntaps, filter.firdes.WIN_HAMMING)
305305
hd = filter.filter_delay_fc(taps)
306306

307307
dst2 = blocks.vector_sink_c()

‎gr-filter/python/filter/qa_firdes.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ def test_hilbert(self):
172172
0.5732954144477844, 0.0,
173173
0.08335155993700027, 0.0,
174174
0.010056184604763985)
175-
new_taps = filter.firdes.hilbert(11)
175+
new_taps = filter.firdes.hilbert(11, filter.firdes.WIN_HAMMING)
176176
self.assertFloatTuplesAlmostEqual(known_taps, new_taps, 5)
177177

178178
def test_root_raised_cosine(self):

0 commit comments

Comments
 (0)
Please sign in to comment.