diff options
Diffstat (limited to 'gr-wxgui/src/python/fftsink_gl.py')
-rw-r--r-- | gr-wxgui/src/python/fftsink_gl.py | 37 |
1 files changed, 32 insertions, 5 deletions
diff --git a/gr-wxgui/src/python/fftsink_gl.py b/gr-wxgui/src/python/fftsink_gl.py index 9d683d697..564764487 100644 --- a/gr-wxgui/src/python/fftsink_gl.py +++ b/gr-wxgui/src/python/fftsink_gl.py @@ -27,6 +27,7 @@ import common from gnuradio import gr, blks2 from pubsub import pubsub from constants import * +import math ################################################## # FFT sink block (wrapper for old wxgui) @@ -52,9 +53,20 @@ class _fft_sink_base(gr.hier_block2, common.wxgui_hb): title='', size=fft_window.DEFAULT_WIN_SIZE, peak_hold=False, + emulate_analog=False, + analog_alpha=None, ): #ensure avg alpha if avg_alpha is None: avg_alpha = 2.0/fft_rate + #ensure analog alpha + if analog_alpha is None: + actual_fft_rate=float(sample_rate/fft_size)/float(max(1,int(float((sample_rate/fft_size)/fft_rate)))) + #print "requested_fft_rate ",fft_rate + #print "actual_fft_rate ",actual_fft_rate + analog_cutoff_freq=0.5 # Hertz + #calculate alpha from wanted cutoff freq + analog_alpha = 1.0 - math.exp(-2.0*math.pi*analog_cutoff_freq/actual_fft_rate) + #init gr.hier_block2.__init__( self, @@ -73,6 +85,8 @@ class _fft_sink_base(gr.hier_block2, common.wxgui_hb): ) msgq = gr.msg_queue(2) sink = gr.message_sink(gr.sizeof_float*fft_size, msgq, True) + + #controller self.controller = pubsub() self.controller.subscribe(AVERAGE_KEY, fft.set_average) @@ -100,6 +114,8 @@ class _fft_sink_base(gr.hier_block2, common.wxgui_hb): avg_alpha_key=AVG_ALPHA_KEY, peak_hold=peak_hold, msg_key=MSG_KEY, + emulate_analog=emulate_analog, + analog_alpha=analog_alpha, ) common.register_access_methods(self, self.win) setattr(self.win, 'set_baseband_freq', getattr(self, 'set_baseband_freq')) #BACKWARDS @@ -131,11 +147,14 @@ class test_app_block (stdgui2.std_top_block): fft_size = 256 # build our flow graph - input_rate = 20.48e3 + input_rate = 2048.0e3 + + #Generate some noise + noise =gr.noise_source_c(gr.GR_UNIFORM, 1.0/10) # Generate a complex sinusoid #src1 = gr.sig_source_c (input_rate, gr.GR_SIN_WAVE, 2e3, 1) - src1 = gr.sig_source_c (input_rate, gr.GR_CONST_WAVE, 5.75e3, 1) + src1 = gr.sig_source_c (input_rate, gr.GR_CONST_WAVE, 57.50e3, 1) # We add these throttle blocks so that this demo doesn't # suck down all the CPU available. Normally you wouldn't use these. @@ -146,17 +165,25 @@ class test_app_block (stdgui2.std_top_block): ref_level=0, y_per_div=20, y_divs=10) vbox.Add (sink1.win, 1, wx.EXPAND) - self.connect(src1, thr1, sink1) + combine1=gr.add_cc() + self.connect(src1, (combine1,0)) + self.connect(noise,(combine1,1)) + self.connect(combine1,thr1, sink1) #src2 = gr.sig_source_f (input_rate, gr.GR_SIN_WAVE, 2e3, 1) - src2 = gr.sig_source_f (input_rate, gr.GR_CONST_WAVE, 5.75e3, 1) + src2 = gr.sig_source_f (input_rate, gr.GR_CONST_WAVE, 57.50e3, 1) thr2 = gr.throttle(gr.sizeof_float, input_rate) sink2 = fft_sink_f (panel, title="Real Data", fft_size=fft_size*2, sample_rate=input_rate, baseband_freq=100e3, ref_level=0, y_per_div=20, y_divs=10) vbox.Add (sink2.win, 1, wx.EXPAND) - self.connect(src2, thr2, sink2) + combine2=gr.add_ff() + c2f2=gr.complex_to_float() + + self.connect(src2, (combine2,0)) + self.connect(noise,c2f2,(combine2,1)) + self.connect(combine2, thr2,sink2) def main (): app = stdgui2.stdapp (test_app_block, "FFT Sink Test App") |