3 from gnuradio import gr, gru, blks2
4 from gnuradio.wxgui import stdgui2, fftsink2, slider
5 from gnuradio.eng_option import eng_option
6 from optparse import OptionParser
9 class test_graph (stdgui2.std_top_block):
10 def __init__(self, frame, panel, vbox, argv):
11 stdgui2.std_top_block.__init__(self, frame, panel, vbox, argv)
13 parser = OptionParser (option_class=eng_option)
14 (options, args) = parser.parse_args ()
24 vbox.Add(slider.slider(panel,
25 -sample_rate/2, sample_rate/2,
26 self.set_lo_freq), 0, wx.ALIGN_CENTER)
29 src = gr.sig_source_c(sample_rate, gr.GR_CONST_WAVE,
32 self.lo = gr.sig_source_c(sample_rate, gr.GR_SIN_WAVE,
35 mixer = gr.multiply_cc()
36 self.connect(src, (mixer, 0))
37 self.connect(self.lo, (mixer, 1))
39 # We add these throttle blocks so that this demo doesn't
40 # suck down all the CPU available. Normally you wouldn't use these.
41 thr = gr.throttle(gr.sizeof_gr_complex, sample_rate)
43 taps = gr.firdes.low_pass(1, # gain
45 1.0/mpoints * 0.4, # cutoff
46 1.0/mpoints * 0.1, # trans width
49 analysis = blks2.analysis_filterbank(mpoints, taps)
51 self.connect(mixer, thr)
52 self.connect(thr, analysis)
54 for i in range(mpoints):
55 fft = fftsink2.fft_sink_c(frame, fft_size=128,
56 sample_rate=sample_rate/mpoints,
59 self.connect((analysis, i), fft)
60 vbox.Add(fft.win, 1, wx.EXPAND)
62 def set_lo_freq(self, freq):
63 self.lo.set_frequency(freq)
68 app = stdgui2.stdapp (test_graph, "Test DFT filterbank")
71 if __name__ == '__main__':