3 from gnuradio import gr, gru, blks
4 from gnuradio.wxgui import stdgui, fftsink
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 (stdgui.gui_flow_graph):
24 def __init__(self, frame, panel, vbox, argv):
25 stdgui.gui_flow_graph.__init__(self, frame, panel, vbox, argv)
27 parser = OptionParser (option_class=eng_option)
28 (options, args) = parser.parse_args ()
34 enable = mpoints * [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 = blks.synthesis_filterbank(self, 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 = fftsink.fft_sink_c(self, frame, fft_size=1024,
68 sample_rate=sample_rate)
69 vbox.Add(fft.win, 1, wx.EXPAND)
71 self.connect(synth, thr, fft)
75 app = stdgui.stdapp (test_graph, "Test DFT filterbank")
78 if __name__ == '__main__':