switch source package format to 3.0 quilt
[debian/gnuradio] / gnuradio-examples / python / digital / benchmark_loopback.py
index e9a0f5d5ab6dbcf501361e7d1b8b2dd5246dff7e..47e4f20288a91e23ba5b57fbf7638b2dc217bc0f 100755 (executable)
@@ -1,6 +1,6 @@
 #!/usr/bin/env python
 #
-# Copyright 2005, 2006, 2007 Free Software Foundation, Inc.
+# Copyright 2005, 2006, 2007, 2009 Free Software Foundation, Inc.
 # 
 # This file is part of GNU Radio
 # 
@@ -28,37 +28,8 @@ from optparse import OptionParser
 import random, time, struct, sys, math
 
 # from current dir
-from transmit_path_lb import transmit_path
-from receive_path_lb import receive_path
-import fusb_options
-
-class awgn_channel(gr.hier_block2):
-    def __init__(self, sample_rate, noise_voltage, frequency_offset, seed=False):
-
-       gr.hier_block2.__init__(self, "awgn_channel",
-                               gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature
-                               gr.io_signature(1, 1, gr.sizeof_gr_complex)) # Output signature
-                                       
-        # Create the Gaussian noise source
-        if not seed:
-            self.noise = gr.noise_source_c(gr.GR_GAUSSIAN, noise_voltage)
-        else:
-            rseed = int(time.time())
-            self.noise = gr.noise_source_c(gr.GR_GAUSSIAN, noise_voltage, rseed)
-
-        self.adder =  gr.add_cc()
-
-        # Create the frequency offset
-        self.offset = gr.sig_source_c(1, gr.GR_SIN_WAVE,
-                                      frequency_offset, 1.0, 0.0)
-        self.mixer = gr.multiply_cc()
-
-        # Connect the components
-        self.connect(self, (self.mixer, 0))
-        self.connect(self.offset, (self.mixer, 1))
-        self.connect(self.mixer, (self.adder, 0))
-        self.connect(self.noise, (self.adder, 1))
-       self.connect(self.adder, self)
+from transmit_path import transmit_path
+from receive_path import receive_path
 
 class my_top_block(gr.top_block):
     def __init__(self, mod_class, demod_class, rx_callback, options):
@@ -73,13 +44,17 @@ class my_top_block(gr.top_block):
         noise_power = power_in_signal/SNR
         noise_voltage = math.sqrt(noise_power)
 
+        # With new interface, sps does not get set by default, but
+        # in the loopback, we don't recalculate it; so just force it here
+        if(options.samples_per_symbol == None):
+            options.samples_per_symbol = 2
+
         self.txpath = transmit_path(mod_class, options)
         self.throttle = gr.throttle(gr.sizeof_gr_complex, options.sample_rate)
         self.rxpath = receive_path(demod_class, rx_callback, options)
 
         if channelon:
-            self.channel = awgn_channel(options.sample_rate, noise_voltage,
-                                        frequency_offset, options.seed)
+            self.channel = gr.channel_model(noise_voltage, frequency_offset, 1.01)
 
             if options.discontinuous:
                 z = 20000*[0,]