From d830a4547256be3096db83118f6e9ffe299f8ecf Mon Sep 17 00:00:00 2001 From: jcorgan Date: Sat, 19 Jan 2008 19:16:31 +0000 Subject: [PATCH] Fixes ticket:229. Fixed code in synthesis filterbank, restored test programs from limbo and upgraded to use blks2. git-svn-id: http://gnuradio.org/svn/gnuradio/trunk@7476 221aa14e-8319-0410-a670-987f0aec2ac5 --- .../python/gnuradio/blks2impl/filterbank.py | 5 ++-- gnuradio-examples/python/usrp/Makefile.am | 2 ++ .../usrp/{limbo => }/test_dft_analysis.py | 14 +++++----- .../python/usrp/{limbo => }/test_dft_synth.py | 27 +++++++++---------- 4 files changed, 25 insertions(+), 23 deletions(-) rename gnuradio-examples/python/usrp/{limbo => }/test_dft_analysis.py (84%) rename gnuradio-examples/python/usrp/{limbo => }/test_dft_synth.py (72%) diff --git a/gnuradio-core/src/python/gnuradio/blks2impl/filterbank.py b/gnuradio-core/src/python/gnuradio/blks2impl/filterbank.py index c1284565..16adc451 100644 --- a/gnuradio-core/src/python/gnuradio/blks2impl/filterbank.py +++ b/gnuradio-core/src/python/gnuradio/blks2impl/filterbank.py @@ -107,7 +107,7 @@ class synthesis_filterbank(gr.hier_block2): for i in range(mpoints): self.connect((self, i), (self.ss2v, i)) - self.connect(self.ss2v, self.ifft, self.v2ss, self) + self.connect(self.ss2v, self.ifft, self.v2ss) # build mpoints fir filters... for i in range(mpoints): @@ -115,7 +115,8 @@ class synthesis_filterbank(gr.hier_block2): self.connect((self.v2ss, i), f) self.connect(f, (self.ss2s, i)) - + self.connect(self.ss2s, self) + class analysis_filterbank(gr.hier_block2): """ Uniformly modulated polyphase DFT filter bank: analysis diff --git a/gnuradio-examples/python/usrp/Makefile.am b/gnuradio-examples/python/usrp/Makefile.am index f0be2bce..17ca7389 100644 --- a/gnuradio-examples/python/usrp/Makefile.am +++ b/gnuradio-examples/python/usrp/Makefile.am @@ -25,6 +25,8 @@ EXTRA_DIST = \ fm_tx_2_daughterboards.py \ fm_tx4.py \ max_power.py \ + test_dft_analysis.py \ + test_dft_synth.py \ usrp_benchmark_usb.py \ usrp_nbfm_ptt.py \ usrp_nbfm_rcv.py \ diff --git a/gnuradio-examples/python/usrp/limbo/test_dft_analysis.py b/gnuradio-examples/python/usrp/test_dft_analysis.py similarity index 84% rename from gnuradio-examples/python/usrp/limbo/test_dft_analysis.py rename to gnuradio-examples/python/usrp/test_dft_analysis.py index a1d9eda4..49db6bf2 100755 --- a/gnuradio-examples/python/usrp/limbo/test_dft_analysis.py +++ b/gnuradio-examples/python/usrp/test_dft_analysis.py @@ -1,14 +1,14 @@ #!/usr/bin/env python -from gnuradio import gr, gru, blks -from gnuradio.wxgui import stdgui, fftsink, slider +from gnuradio import gr, gru, blks2 +from gnuradio.wxgui import stdgui2, fftsink2, slider from gnuradio.eng_option import eng_option from optparse import OptionParser import wx -class test_graph (stdgui.gui_flow_graph): +class test_graph (stdgui2.std_top_block): def __init__(self, frame, panel, vbox, argv): - stdgui.gui_flow_graph.__init__(self, frame, panel, vbox, argv) + stdgui2.std_top_block.__init__(self, frame, panel, vbox, argv) parser = OptionParser (option_class=eng_option) (options, args) = parser.parse_args () @@ -46,13 +46,13 @@ class test_graph (stdgui.gui_flow_graph): 1.0/mpoints * 0.1, # trans width gr.firdes.WIN_HANN) print len(taps) - analysis = blks.analysis_filterbank(self, mpoints, taps) + analysis = blks2.analysis_filterbank(mpoints, taps) self.connect(mixer, thr) self.connect(thr, analysis) for i in range(mpoints): - fft = fftsink.fft_sink_c(self, frame, fft_size=128, + fft = fftsink2.fft_sink_c(frame, fft_size=128, sample_rate=sample_rate/mpoints, fft_rate=5, title="Ch %d" % (i,)) @@ -65,7 +65,7 @@ class test_graph (stdgui.gui_flow_graph): def main (): - app = stdgui.stdapp (test_graph, "Test DFT filterbank") + app = stdgui2.stdapp (test_graph, "Test DFT filterbank") app.MainLoop () if __name__ == '__main__': diff --git a/gnuradio-examples/python/usrp/limbo/test_dft_synth.py b/gnuradio-examples/python/usrp/test_dft_synth.py similarity index 72% rename from gnuradio-examples/python/usrp/limbo/test_dft_synth.py rename to gnuradio-examples/python/usrp/test_dft_synth.py index 60a49e3b..99b1c492 100755 --- a/gnuradio-examples/python/usrp/limbo/test_dft_synth.py +++ b/gnuradio-examples/python/usrp/test_dft_synth.py @@ -1,7 +1,7 @@ #!/usr/bin/env python -from gnuradio import gr, gru, blks -from gnuradio.wxgui import stdgui, fftsink +from gnuradio import gr, gru, blks2 +from gnuradio.wxgui import stdgui2, fftsink2 from gnuradio.eng_option import eng_option from optparse import OptionParser import wx @@ -20,9 +20,9 @@ def random_noise_c(gain=1): return src -class test_graph (stdgui.gui_flow_graph): +class test_graph (stdgui2.std_top_block): def __init__(self, frame, panel, vbox, argv): - stdgui.gui_flow_graph.__init__(self, frame, panel, vbox, argv) + stdgui2.std_top_block.__init__(self, frame, panel, vbox, argv) parser = OptionParser (option_class=eng_option) (options, args) = parser.parse_args () @@ -31,7 +31,7 @@ class test_graph (stdgui.gui_flow_graph): mpoints = 16 ampl = 1000 - enable = mpoints * [0] + enable = mpoints/2 * [1, 0] enable[0] = 1 taps = gr.firdes.low_pass(1, # gain @@ -40,11 +40,11 @@ class test_graph (stdgui.gui_flow_graph): 1.0/mpoints * 0.1, # trans width gr.firdes.WIN_HANN) - synth = blks.synthesis_filterbank(self, mpoints, taps) + synth = blks2.synthesis_filterbank(mpoints, taps) null_source = gr.null_source(gr.sizeof_gr_complex) - if 0: + if 1: for i in range(mpoints): s = gr.sig_source_c(sample_rate/mpoints, gr.GR_SIN_WAVE, 300e3, ampl * enable[i], 0) @@ -52,10 +52,10 @@ class test_graph (stdgui.gui_flow_graph): else: for i in range(mpoints): - if i == 0: - s = gr.sig_source_c(sample_rate/mpoints, gr.GR_SIN_WAVE, - 300e3, ampl * enable[i], 0) - #s = random_noise_c(ampl) + if i == 1: + #s = gr.sig_source_c(sample_rate/mpoints, gr.GR_SIN_WAVE, + # 300e3, ampl * enable[i], 0) + s = random_noise_c(ampl) self.connect(s, (synth, i)) else: self.connect(null_source, (synth, i)) @@ -64,15 +64,14 @@ class test_graph (stdgui.gui_flow_graph): # We add these throttle blocks so that this demo doesn't # suck down all the CPU available. Normally you wouldn't use these. thr = gr.throttle(gr.sizeof_gr_complex, sample_rate) - fft = fftsink.fft_sink_c(self, frame, fft_size=1024, - sample_rate=sample_rate) + fft = fftsink2.fft_sink_c(frame, fft_size=1024,sample_rate=sample_rate) vbox.Add(fft.win, 1, wx.EXPAND) self.connect(synth, thr, fft) def main (): - app = stdgui.stdapp (test_graph, "Test DFT filterbank") + app = stdgui2.stdapp (test_graph, "Test DFT filterbank") app.MainLoop () if __name__ == '__main__': -- 2.47.2