summaryrefslogtreecommitdiff
path: root/gr-wxgui/src/python/fftsink_gl.py
diff options
context:
space:
mode:
authorJohnathan Corgan2010-05-13 12:29:59 -0700
committerJohnathan Corgan2010-05-13 12:29:59 -0700
commit331542fc51eb47a65161ab6d41c6dc8fd1dd1f22 (patch)
tree98ac608fdb3349afdc8019fbdd9f7dcf49326b46 /gr-wxgui/src/python/fftsink_gl.py
parent467678259c56fab32a326690cc01eac1dbcb48ca (diff)
parent49fa13f9fce2037d176c86bf326a7e25a78b72a5 (diff)
downloadgnuradio-331542fc51eb47a65161ab6d41c6dc8fd1dd1f22.tar.gz
gnuradio-331542fc51eb47a65161ab6d41c6dc8fd1dd1f22.tar.bz2
gnuradio-331542fc51eb47a65161ab6d41c6dc8fd1dd1f22.zip
Merge remote branch 'nldudok1/gr-wxgui_emulate_analog' into master
* nldudok1/gr-wxgui_emulate_analog: Add analog CRT screen afterglow emulation for gr-wxgui Conflicts: gr-wxgui/src/python/fftsink_gl.py gr-wxgui/src/python/fftsink_nongl.py
Diffstat (limited to 'gr-wxgui/src/python/fftsink_gl.py')
-rw-r--r--gr-wxgui/src/python/fftsink_gl.py37
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 8ddea9a8e..0d725ea14 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)
@@ -53,10 +54,21 @@ class _fft_sink_base(gr.hier_block2, common.wxgui_hb):
size=fft_window.DEFAULT_WIN_SIZE,
peak_hold=False,
win=None,
+ emulate_analog=False,
+ analog_alpha=None,
**kwargs #do not end with a comma
):
#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,
@@ -76,6 +88,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)
@@ -103,6 +117,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
@@ -134,11 +150,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.
@@ -149,17 +168,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")