3 from gnuradio import gr, gru, blks2
4 from gnuradio.wxgui import stdgui2, fftsink2
5 from gnuradio.eng_option import eng_option
6 from optparse import OptionParser
11 def make_random_complex_tuple(L, gain=1):
14 result.append(gain * complex(random.gauss(0, 1),random.gauss(0, 1)))
18 def random_noise_c(gain=1):
19 src = gr.vector_source_c(make_random_complex_tuple(32*1024, gain), True)
23 class test_graph (stdgui2.std_top_block):
24 def __init__(self, frame, panel, vbox, argv):
25 stdgui2.std_top_block.__init__(self, frame, panel, vbox, argv)
27 parser = OptionParser (option_class=eng_option)
28 (options, args) = parser.parse_args ()
34 enable = mpoints/2 * [1, 0]
37 taps = gr.firdes.low_pass(1, # gain
39 1.0/mpoints * 0.4, # cutoff
40 1.0/mpoints * 0.1, # trans width
43 synth = blks2.synthesis_filterbank(mpoints, taps)
45 null_source = gr.null_source(gr.sizeof_gr_complex)
48 for i in range(mpoints):
49 s = gr.sig_source_c(sample_rate/mpoints, gr.GR_SIN_WAVE,
50 300e3, ampl * enable[i], 0)
51 self.connect(s, (synth, i))
54 for i in range(mpoints):
56 #s = gr.sig_source_c(sample_rate/mpoints, gr.GR_SIN_WAVE,
57 # 300e3, ampl * enable[i], 0)
58 s = random_noise_c(ampl)
59 self.connect(s, (synth, i))
61 self.connect(null_source, (synth, i))
64 # We add these throttle blocks so that this demo doesn't
65 # suck down all the CPU available. Normally you wouldn't use these.
66 thr = gr.throttle(gr.sizeof_gr_complex, sample_rate)
67 fft = fftsink2.fft_sink_c(frame, fft_size=1024,sample_rate=sample_rate)
68 vbox.Add(fft.win, 1, wx.EXPAND)
70 self.connect(synth, thr, fft)
74 app = stdgui2.stdapp (test_graph, "Test DFT filterbank")
77 if __name__ == '__main__':