def __init__(self):
        gr.top_block.__init__(self)

        Rs = 8000
        f1 = 100
        f2 = 200

        npts = 2048

        self.qapp = QtGui.QApplication(sys.argv)

        src1 = gr.sig_source_c(Rs, gr.GR_SIN_WAVE, f1, 0.5, 0)
        src2 = gr.sig_source_c(Rs, gr.GR_SIN_WAVE, f2, 0.5, 0)
        src  = gr.add_cc()
        channel = filter.channel_model(0.001)
        thr = gr.throttle(gr.sizeof_gr_complex, 100*npts)
        self.snk1 = qtgui.const_sink_c(npts, "Constellation Example", 1)

        self.connect(src1, (src,0))
        self.connect(src2, (src,1))
        self.connect(src,  channel, thr, (self.snk1, 0))

        self.ctrl_win = control_box()
        self.ctrl_win.attach_signal1(src1)
        self.ctrl_win.attach_signal2(src2)

        # Get the reference pointer to the SpectrumDisplayForm QWidget
        pyQt  = self.snk1.pyqwidget()

        # Wrap the pointer as a PyQt SIP object
        # This can now be manipulated as a PyQt4.QtGui.QWidget
        pyWin = sip.wrapinstance(pyQt, QtGui.QWidget)

        self.main_box = dialog_box(pyWin, self.ctrl_win)
        self.main_box.show()
Example #2
0
    def __init__(self, frame, panel, vbox, argv):
        stdgui2.std_top_block.__init__ (self, frame, panel, vbox, argv)

        pspectrum_len = 1024

        # build our flow graph
        input_rate = 2e6

        #Generate some noise
        noise = gr.noise_source_c(gr.GR_GAUSSIAN, 1.0/10)

        # Generate a complex sinusoid
        #source = gr.file_source(gr.sizeof_gr_complex, 'foobar2.dat', repeat=True)

        src1 = gr.sig_source_c (input_rate, gr.GR_SIN_WAVE, -500e3, 1)
        src2 = gr.sig_source_c (input_rate, gr.GR_SIN_WAVE, 500e3, 1)
        src3 = gr.sig_source_c (input_rate, gr.GR_SIN_WAVE, -250e3, 2)

        # We add these throttle blocks so that this demo doesn't
        # suck down all the CPU available.  Normally you wouldn't use these.
        thr1 = gr.throttle(gr.sizeof_gr_complex, input_rate)

        sink1 = spectrum_sink_c (panel, title="Spectrum Sink", pspectrum_len=pspectrum_len,
                            sample_rate=input_rate, baseband_freq=0,
                            ref_level=0, y_per_div=20, y_divs=10, m = 70, n = 3, nsamples = 1024)
        vbox.Add (sink1.win, 1, wx.EXPAND)

        combine1=gr.add_cc()
        self.connect(src1,(combine1,0))
        self.connect(src2,(combine1,1))
        self.connect(src3,(combine1,2))
        self.connect(noise, (combine1,3))
        self.connect(combine1,thr1, sink1)
def graph (args):

    nargs = len (args)
    if nargs == 1:
	infile = args[0]
    else:
	sys.stderr.write('usage: interp.py input_file\n')
	sys.exit (1)

    sampling_freq = 6400000

    fg = gr.flow_graph ()

    src0 = gr.file_source (gr.sizeof_gr_complex,infile)
    src1 = gr.sig_source_c (sampling_freq, gr.GR_CONST_WAVE, 1, 0)
    src2 = gr.sig_source_c (sampling_freq, gr.GR_CONST_WAVE, 1, 0)

    interlv = gr.interleave(gr.sizeof_gr_complex)

    lp_coeffs = gr.firdes.low_pass ( 3, 19.2e6, 3.2e6, .5e6, gr.firdes.WIN_HAMMING )
    lp = gr.fir_filter_ccf ( 1, lp_coeffs )

    file = gr.file_sink(gr.sizeof_gr_complex,"/tmp/atsc_pipe_1")

    fg.connect( src0, (interlv, 0) )
    fg.connect( src1, (interlv, 1) )
    fg.connect( src2, (interlv, 2) )
    fg.connect( interlv, lp, file )

    fg.start()
    raw_input ('Head End: Press Enter to stop')
    fg.stop()
    def set_waveform(self, type):
        self.lock()
        self.disconnect_all()
        if type == gr.GR_SIN_WAVE or type == gr.GR_CONST_WAVE:
            self._src = gr.sig_source_c(
                self[SAMP_RATE_KEY],  # Sample rate
                type,  # Waveform type
                self[WAVEFORM_FREQ_KEY],  # Waveform frequency
                self[AMPLITUDE_KEY],  # Waveform amplitude
                self[WAVEFORM_OFFSET_KEY])  # Waveform offset
        elif type == gr.GR_GAUSSIAN or type == gr.GR_UNIFORM:
            self._src = gr.noise_source_c(type, self[AMPLITUDE_KEY])
        elif type == "2tone":
            self._src1 = gr.sig_source_c(self[SAMP_RATE_KEY], gr.GR_SIN_WAVE,
                                         self[WAVEFORM_FREQ_KEY],
                                         self[AMPLITUDE_KEY] / 2.0, 0)
            if (self[WAVEFORM2_FREQ_KEY] is None):
                self[WAVEFORM2_FREQ_KEY] = -self[WAVEFORM_FREQ_KEY]

            self._src2 = gr.sig_source_c(self[SAMP_RATE_KEY], gr.GR_SIN_WAVE,
                                         self[WAVEFORM2_FREQ_KEY],
                                         self[AMPLITUDE_KEY] / 2.0, 0)
            self._src = gr.add_cc()
            self.connect(self._src1, (self._src, 0))
            self.connect(self._src2, (self._src, 1))
        elif type == "sweep":
            # rf freq is center frequency
            # waveform_freq is total swept width
            # waveform2_freq is sweep rate
            # will sweep from (rf_freq-waveform_freq/2) to (rf_freq+waveform_freq/2)
            if self[WAVEFORM2_FREQ_KEY] is None:
                self[WAVEFORM2_FREQ_KEY] = 0.1

            self._src1 = gr.sig_source_f(self[SAMP_RATE_KEY], gr.GR_TRI_WAVE,
                                         self[WAVEFORM2_FREQ_KEY], 1.0, -0.5)
            self._src2 = gr.frequency_modulator_fc(
                self[WAVEFORM_FREQ_KEY] * 2 * math.pi / self[SAMP_RATE_KEY])
            self._src = gr.multiply_const_cc(self[AMPLITUDE_KEY])
            self.connect(self._src1, self._src2, self._src)
        else:
            raise RuntimeError("Unknown waveform type")

        self.connect(self._src, self._u)
        self.unlock()

        if self._verbose:
            print "Set baseband modulation to:", waveforms[type]
            if type == gr.GR_SIN_WAVE:
                print "Modulation frequency: %sHz" % (n2s(
                    self[WAVEFORM_FREQ_KEY]), )
                print "Initial phase:", self[WAVEFORM_OFFSET_KEY]
            elif type == "2tone":
                print "Tone 1: %sHz" % (n2s(self[WAVEFORM_FREQ_KEY]), )
                print "Tone 2: %sHz" % (n2s(self[WAVEFORM2_FREQ_KEY]), )
            elif type == "sweep":
                print "Sweeping across %sHz to %sHz" % (n2s(
                    -self[WAVEFORM_FREQ_KEY] /
                    2.0), n2s(self[WAVEFORM_FREQ_KEY] / 2.0))
                print "Sweep rate: %sHz" % (n2s(self[WAVEFORM2_FREQ_KEY]), )
            print "TX amplitude:", self[AMPLITUDE_KEY]
Example #5
0
	def __init__(self, frame, panel, vbox, argv):
		stdgui2.std_top_block.__init__ (self, frame, panel, vbox, argv)

		data_len = 1024

		# build our flow graph
		input_rate = 2e6

		#Generate some noise
		noise = gr.noise_source_c(gr.GR_GAUSSIAN, 1.0/10)

		# Generate a complex sinusoid
		#source = gr.file_source(gr.sizeof_gr_complex, 'foobar2.dat', repeat=True)

		src1 = gr.sig_source_c (input_rate, gr.GR_SIN_WAVE, -500e3, 1)
		src2 = gr.sig_source_c (input_rate, gr.GR_SIN_WAVE, 500e3, 1)
		src3 = gr.sig_source_c (input_rate, gr.GR_SIN_WAVE, -250e3, 2)

		# We add these throttle blocks so that this demo doesn't
		# suck down all the CPU available.  Normally you wouldn't use these.
		thr1 = gr.throttle(gr.sizeof_gr_complex, input_rate)

		sink1 = plot_sink_f (panel, title="Spectrum Sink", data_len=data_len,
							sample_rate=input_rate,
							ref_level=0, y_per_div=20, y_divs=10)
		vbox.Add (sink1.win, 1, wx.EXPAND)

		combine1=gr.add_cc()
		self.connect(src1,(combine1,0))
		self.connect(src2,(combine1,1))
		self.connect(src3,(combine1,2))
		self.connect(noise, (combine1,3))
		self.connect(combine1,thr1, sink1)
Example #6
0
    def __init__(self):
        gr.top_block.__init__(self)

        parser = OptionParser(option_class=eng_option)
        parser.add_option(
            "-f",
            "--freq1",
            type="eng_float",
            default=1e6,
            help="set waveform frequency to FREQ [default=%default]")
        parser.add_option(
            "-g",
            "--freq2",
            type="eng_float",
            default=1e6,
            help="set waveform frequency to FREQ [default=%default]")
        parser.add_option(
            "-a",
            "--amplitude1",
            type="eng_float",
            default=16e3,
            help="set waveform amplitude to AMPLITUDE [default=%default]",
            metavar="AMPL")
        parser.add_option(
            "-b",
            "--amplitude2",
            type="eng_float",
            default=16e3,
            help="set waveform amplitude to AMPLITUDE [default=%default]",
            metavar="AMPL")

        parser.add_option(
            "-i",
            "--interp",
            type="int",
            default=32,
            help="assume fgpa interpolation rate is INTERP [default=%default]")

        (options, args) = parser.parse_args()
        if len(args) != 0:
            parser.print_help()
            raise SystemExit, 1

        src0 = gr.sig_source_c(master_clock / options.interp, gr.GR_SIN_WAVE,
                               options.freq1, options.amplitude1)
        src1 = gr.sig_source_c(master_clock / options.interp, gr.GR_SIN_WAVE,
                               options.freq2, options.amplitude2)

        adder = gr.add_cc()

        c2s = gr.complex_to_interleaved_short()

        stdout_sink = gr.file_descriptor_sink(gr.sizeof_short, 1)

        self.connect(src0, (adder, 0))
        self.connect(src1, (adder, 1))
        self.connect(adder, c2s, stdout_sink)
Example #7
0
    def __init__(self):
        gr.top_block.__init__(self)

        Rs = 8000
        f1 = 100
        f2 = 200

        npts = 2048

        self.qapp = QtGui.QApplication(sys.argv)

        src1 = gr.sig_source_c(Rs, gr.GR_SIN_WAVE, f1, 0.1, 0)
        src2 = gr.sig_source_c(Rs, gr.GR_SIN_WAVE, f2, 0.1, 0)
        src  = gr.add_cc()
        channel = filter.channel_model(0.01)
        thr = gr.throttle(gr.sizeof_gr_complex, 100*npts)
        self.snk1 = qtgui.time_sink_c(npts, Rs,
                                      "Complex Time Example", 1)

        self.connect(src1, (src,0))
        self.connect(src2, (src,1))
        self.connect(src,  channel, thr, (self.snk1, 0))
        #self.connect(src1, (self.snk1, 1))
        #self.connect(src2, (self.snk1, 2))

        self.ctrl_win = control_box()
        self.ctrl_win.attach_signal1(src1)
        self.ctrl_win.attach_signal2(src2)

        # Get the reference pointer to the SpectrumDisplayForm QWidget
        pyQt  = self.snk1.pyqwidget()

        # Wrap the pointer as a PyQt SIP object
        # This can now be manipulated as a PyQt4.QtGui.QWidget
        pyWin = sip.wrapinstance(pyQt, QtGui.QWidget)

        # Example of using signal/slot to set the title of a curve
        pyWin.connect(pyWin, QtCore.SIGNAL("setTitle(int, QString)"),
                      pyWin, QtCore.SLOT("setTitle(int, QString)"))
        pyWin.emit(QtCore.SIGNAL("setTitle(int, QString)"), 0, "Re{sum}")
        self.snk1.set_title(1, "Im{Sum}")
        #self.snk1.set_title(2, "Re{src1}")
        #self.snk1.set_title(3, "Im{src1}")
        #self.snk1.set_title(4, "Re{src2}")
        #self.snk1.set_title(5, "Im{src2}")

        # Can also set the color of a curve
        #self.snk1.set_color(5, "blue")

        self.snk1.set_update_time(0.5)

        #pyWin.show()
        self.main_box = dialog_box(pyWin, self.ctrl_win)
        self.main_box.show()
Example #8
0
    def __init__(self):
        gr.top_block.__init__(self)

        Rs = 8000
        f1 = 100
        f2 = 200

        npts = 2048

        self.qapp = QtGui.QApplication(sys.argv)
        
        src1 = gr.sig_source_c(Rs, gr.GR_SIN_WAVE, f1, 0.1, 0)
        src2 = gr.sig_source_c(Rs, gr.GR_SIN_WAVE, f2, 0.1, 0)
        src  = gr.add_cc()
        channel = gr.channel_model(0.01)
        thr = gr.throttle(gr.sizeof_gr_complex, 100*npts)
        self.snk1 = qtgui.time_sink_c(npts, Rs,
                                      "Complex Time Example", 3)

        self.connect(src1, (src,0))
        self.connect(src2, (src,1))
        self.connect(src,  channel, thr, (self.snk1, 0))
        self.connect(src1, (self.snk1, 1))
        self.connect(src2, (self.snk1, 2))

        self.ctrl_win = control_box()
        self.ctrl_win.attach_signal1(src1)
        self.ctrl_win.attach_signal2(src2)

        # Get the reference pointer to the SpectrumDisplayForm QWidget
        pyQt  = self.snk1.pyqwidget()

        # Wrap the pointer as a PyQt SIP object
        # This can now be manipulated as a PyQt4.QtGui.QWidget
        pyWin = sip.wrapinstance(pyQt, QtGui.QWidget)

        # Example of using signal/slot to set the title of a curve
        pyWin.connect(pyWin, QtCore.SIGNAL("setTitle(int, QString)"),
                      pyWin, QtCore.SLOT("setTitle(int, QString)"))
        pyWin.emit(QtCore.SIGNAL("setTitle(int, QString)"), 0, "Re{sum}")
        self.snk1.set_title(1, "Im{Sum}")
        self.snk1.set_title(2, "Re{src1}")
        self.snk1.set_title(3, "Im{src1}")
        self.snk1.set_title(4, "Re{src2}")
        self.snk1.set_title(5, "Im{src2}")

        # Can also set the color of a curve
        #self.snk1.set_color(5, "blue")

        #pyWin.show()
        self.main_box = dialog_box(pyWin, self.ctrl_win)
        self.main_box.show()
Example #9
0
    def __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 ()

        sample_rate = 16e3
        mpoints = 4
        ampl = 1000
        freq = 0

        lo_freq = 1e6
        lo_ampl = 1
        
        vbox.Add(slider.slider(panel,
                               -sample_rate/2, sample_rate/2,
                               self.set_lo_freq), 0, wx.ALIGN_CENTER)


        src = gr.sig_source_c(sample_rate, gr.GR_CONST_WAVE,
                              freq, ampl, 0)

        self.lo = gr.sig_source_c(sample_rate, gr.GR_SIN_WAVE,
                                  lo_freq, lo_ampl, 0)

        mixer = gr.multiply_cc()
        self.connect(src, (mixer, 0))
        self.connect(self.lo, (mixer, 1))
        
        # 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)

        taps = gr.firdes.low_pass(1,   # gain
                                  1,   # rate
                                  1.0/mpoints * 0.4,  # cutoff
                                  1.0/mpoints * 0.1,  # trans width
                                  gr.firdes.WIN_HANN)
        print len(taps)
        analysis = blks2.analysis_filterbank(mpoints, taps)
        
        self.connect(mixer, thr)
        self.connect(thr, analysis)

        for i in range(mpoints):
            fft = fftsink2.fft_sink_c(frame, fft_size=128,
                                     sample_rate=sample_rate/mpoints,
                                     fft_rate=5,
                                     title="Ch %d" % (i,))
            self.connect((analysis, i), fft)
            vbox.Add(fft.win, 1, wx.EXPAND)
Example #10
0
    def __init__(self, frame, panel, vbox, argv):
        stdgui2.std_top_block.__init__(self, frame, panel, vbox, argv)

        default_input_rate = 1e6
        if len(argv) > 1:
            input_rate = int(argv[1])
        else:
            input_rate = default_input_rate

        if len(argv) > 2:
            v_scale = float(argv[2])  # start up at this v_scale value
        else:
            v_scale = None  # start up in autorange mode, default

        if len(argv) > 3:
            t_scale = float(argv[3])  # start up at this t_scale value
        else:
            t_scale = .00003 * default_input_rate / input_rate  # old behavior

        print "input rate %s  v_scale %s  t_scale %s" % (input_rate, v_scale,
                                                         t_scale)

        # Generate a complex sinusoid
        ampl = 1.0e3
        self.src0 = gr.sig_source_c(input_rate, gr.GR_SIN_WAVE,
                                    25.1e3 * input_rate / default_input_rate,
                                    ampl)
        self.noise = gr.sig_source_c(
            input_rate, gr.GR_SIN_WAVE,
            11.1 * 25.1e3 * input_rate / default_input_rate, ampl / 10)
        #self.noise =gr.noise_source_c(gr.GR_GAUSSIAN, ampl/10)
        self.combine = gr.add_cc()

        # We add this throttle block so that this demo doesn't suck down
        # all the CPU available.  You normally wouldn't use it...
        self.thr = gr.throttle(gr.sizeof_gr_complex, input_rate)

        scope = scope_sink_c(panel,
                             "Secret Data",
                             sample_rate=input_rate,
                             v_scale=v_scale,
                             t_scale=t_scale)
        vbox.Add(scope.win, 1, wx.EXPAND)

        # Ultimately this will be
        # self.connect("src0 throttle scope")
        self.connect(self.src0, (self.combine, 0))
        self.connect(self.noise, (self.combine, 1))
        self.connect(self.combine, self.thr, scope)
Example #11
0
    def __init__(self):
        gr.top_block.__init__(self)

        parser = OptionParser(option_class=eng_option)
        parser.add_option(
            "-f", "--freq1", type="eng_float", default=1e6, help="set waveform frequency to FREQ [default=%default]"
        )
        parser.add_option(
            "-g", "--freq2", type="eng_float", default=1e6, help="set waveform frequency to FREQ [default=%default]"
        )
        parser.add_option(
            "-a",
            "--amplitude1",
            type="eng_float",
            default=16e3,
            help="set waveform amplitude to AMPLITUDE [default=%default]",
            metavar="AMPL",
        )
        parser.add_option(
            "-b",
            "--amplitude2",
            type="eng_float",
            default=16e3,
            help="set waveform amplitude to AMPLITUDE [default=%default]",
            metavar="AMPL",
        )

        parser.add_option(
            "-i", "--interp", type="int", default=32, help="assume fgpa interpolation rate is INTERP [default=%default]"
        )

        (options, args) = parser.parse_args()
        if len(args) != 0:
            parser.print_help()
            raise SystemExit, 1

        src0 = gr.sig_source_c(master_clock / options.interp, gr.GR_SIN_WAVE, options.freq1, options.amplitude1)
        src1 = gr.sig_source_c(master_clock / options.interp, gr.GR_SIN_WAVE, options.freq2, options.amplitude2)

        adder = gr.add_cc()

        c2s = gr.complex_to_interleaved_short()

        stdout_sink = gr.file_descriptor_sink(gr.sizeof_short, 1)

        self.connect(src0, (adder, 0))
        self.connect(src1, (adder, 1))
        self.connect(adder, c2s, stdout_sink)
Example #12
0
    def __init__(self, filename, lo_freq, audio_rate, if_rate):

        gr.hier_block2.__init__(self, "pipeline",
                                gr.io_signature(0, 0, 0),
                                gr.io_signature(1, 1, gr.sizeof_gr_complex))

        try:
            src = gr.file_source (gr.sizeof_float, filename, True)
        except RuntimeError:
            sys.stderr.write(("\nError: Could not open file '%s'\n\n" % \
                                  filename))
            sys.exit(1)
            
        print audio_rate, if_rate
        fmtx = blks2.nbfm_tx (audio_rate, if_rate, max_dev=5e3, tau=75e-6)
        
        # Local oscillator
        lo = gr.sig_source_c (if_rate,        # sample rate
                              gr.GR_SIN_WAVE, # waveform type
                              lo_freq,        #frequency
                              1.0,            # amplitude
                              0)              # DC Offset
        mixer = gr.multiply_cc ()
    
        self.connect (src, fmtx, (mixer, 0))
        self.connect (lo, (mixer, 1))
        self.connect (mixer, self)
Example #13
0
    def __init__(self, fftl):
        """
        docstring
	    """
        gr.hier_block2.__init__(self, "hier_freq_estimate_cc",
				gr.io_signature(1,1, gr.sizeof_gr_complex),  # Input signature
				gr.io_signature(1,1, gr.sizeof_gr_complex)) # Output signature

        # Define blocks
        waveform = gr.GR_COS_WAVE
        wave_freq = 0.0
        ampl = 1.0
        offset = 0.0
        cpl = 144 * fftl / 2048
        cpl0 = 160 * fftl / 2048
        slotl = 7 * fftl + 6 * cpl + cpl0
        samp_rate = slotl / 0.0005
        #print fftl
        #print cpl
        #print cpl0
        #print slotl
        #print samp_rate
        self.sig   = gr.sig_source_c(samp_rate, waveform,wave_freq,ampl,offset)
        self.multi = gr.multiply_cc(1)
        self.est   = lte_swig.freq_estimate_c(self.sig,fftl)
        
        self.connect(self,(self.multi,0),self)
        self.connect(self.sig,(self.multi,1) )
        self.connect(self.multi,self.est ) 
Example #14
0
    def __init__(self, vocoder, lo_freq, audio_rate, if_rate):

        gr.hier_block2.__init__(self, "pipeline",
                                gr.io_signature(0, 0, 0),                    # Input signature
                                gr.io_signature(1, 1, gr.sizeof_gr_complex)) # Output signature

        c4fm = op25_c4fm_mod.p25_mod_bf(output_sample_rate=audio_rate,
                                 log=False,
                                 verbose=True)
        interp_factor = if_rate / audio_rate

        low_pass = 2.88e3
        interp_taps = gr.firdes.low_pass(1.0, if_rate, low_pass, low_pass * 0.1, gr.firdes.WIN_HANN)

        interpolator = gr.interp_fir_filter_fff (int(interp_factor), interp_taps)

        max_dev = 12.5e3
        k = 2 * math.pi * max_dev / if_rate

        adjustment = 1.5   # adjust for proper c4fm deviation level

        modulator = gr.frequency_modulator_fc (k * adjustment)

        # Local oscillator
        lo = gr.sig_source_c (if_rate,        # sample rate
                              gr.GR_SIN_WAVE, # waveform type
                              lo_freq,        #frequency
                              1.0,            # amplitude
                              0)              # DC Offset
        mixer = gr.multiply_cc ()

        self.connect (vocoder, c4fm, interpolator, modulator, (mixer, 0))
        self.connect (lo, (mixer, 1))
        self.connect (mixer, self)
Example #15
0
    def __init__(self):
        gr.top_block.__init__(self)
        parser = OptionParser(option_class=eng_option)

        parser.add_option("-c", "--calibration", type="eng_float", default=0, help="freq offset")
        parser.add_option("-g", "--gain", type="eng_float", default=1)
        parser.add_option("-i", "--input-file", type="string", default="in.dat", help="specify the input file")
        parser.add_option("-o", "--output-file", type="string", default="out.dat", help="specify the output file")
        parser.add_option("-r", "--new-sample-rate", type="int", default=96000, help="output sample rate")
        parser.add_option("-s", "--sample-rate", type="int", default=48000, help="input sample rate")
        (options, args) = parser.parse_args()
 
        sample_rate = options.sample_rate
        new_sample_rate = options.new_sample_rate

        IN = gr.file_source(gr.sizeof_gr_complex, options.input_file)
        OUT = gr.file_sink(gr.sizeof_gr_complex, options.output_file)

        LO = gr.sig_source_c(sample_rate, gr.GR_COS_WAVE, options.calibration, 1.0, 0)
        MIXER = gr.multiply_cc()

        AMP = gr.multiply_const_cc(options.gain)

        nphases = 32
        frac_bw = 0.05
        p1 = frac_bw
        p2 = frac_bw
        rs_taps = gr.firdes.low_pass(nphases, nphases, p1, p2)
        #RESAMP = blks2.pfb_arb_resampler_ccf(float(sample_rate) / float(new_sample_rate), (rs_taps), nphases, )
        RESAMP = blks2.pfb_arb_resampler_ccf(float(new_sample_rate) / float(sample_rate), (rs_taps), nphases, )

        self.connect(IN, (MIXER, 0))
        self.connect(LO, (MIXER, 1))

        self.connect(MIXER, AMP, RESAMP, OUT)
    def __init__(self, noise_voltage=0.0, frequency_offset=0.0, epsilon=1.0, taps=[1.0,0.0], noise_seed=3021):
        ''' Creates a channel model that includes:
          - AWGN noise power in terms of noise voltage
          - A frequency offest in the channel in ratio
          - A timing offset ratio to model clock difference (epsilon)
          - Multipath taps
          '''
	gr.hier_block2.__init__(self, "channel_model",
				gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature
				gr.io_signature(1, 1, gr.sizeof_gr_complex)) # Output signature

        #print epsilon
        self.timing_offset = gr.fractional_interpolator_cc(0, epsilon)
        
        self.multipath = gr.fir_filter_ccc(1, taps)
        
        self.noise_adder = gr.add_cc()
        self.noise = gr.noise_source_c(gr.GR_GAUSSIAN, noise_voltage, noise_seed)
        self.freq_offset = gr.sig_source_c(1, gr.GR_SIN_WAVE, frequency_offset, 1.0, 0.0)
        self.mixer_offset = gr.multiply_cc()

        self.connect(self, self.timing_offset, self.multipath)
        self.connect(self.multipath, (self.mixer_offset,0))
        self.connect(self.freq_offset,(self.mixer_offset,1))
        self.connect(self.mixer_offset, (self.noise_adder,1))
        self.connect(self.noise, (self.noise_adder,0))
        self.connect(self.noise_adder, self)
Example #17
0
    def test_000(self):
        N = 1000  # number of samples to use
        fs = 1000  # baseband sampling rate
        freq = 100

        signal = gr.sig_source_c(fs, gr.GR_SIN_WAVE, freq, 1)
        head = gr.head(gr.sizeof_gr_complex, N)
        op = filter.channel_model(0.0, 0.0, 1.0, [
            1,
        ], 0)
        snk = gr.vector_sink_c()
        snk1 = gr.vector_sink_c()

        op.set_noise_voltage(0.0)
        op.set_frequency_offset(0.0)
        op.set_taps([
            1,
        ])
        op.set_timing_offset(1.0)

        self.tb.connect(signal, head, op, snk)
        self.tb.connect(op, snk1)
        self.tb.run()

        dst_data = snk.data()
        exp_data = snk1.data()
        self.assertComplexTuplesAlmostEqual(exp_data, dst_data, 5)
    def __init__(self, fg, noise_voltage=0.0, frequency_offset=0.0, epsilon=1.0, taps=[1.0,0.0]):
        ''' Creates a channel model that includes:
          - AWGN noise power in terms of noise voltage
          - A frequency offest in the channel in ratio
          - A timing offset ratio to model clock difference (epsilon)
          - Multipath taps
          '''

        print epsilon
        self.timing_offset = gr.fractional_interpolator_cc(0, epsilon)
        
        self.multipath = gr.fir_filter_ccc(1, taps)
        
        self.noise_adder = gr.add_cc()
        self.noise = gr.noise_source_c(gr.GR_GAUSSIAN,noise_voltage)
        self.freq_offset = gr.sig_source_c(1, gr.GR_SIN_WAVE, frequency_offset, 1.0, 0.0)
        self.mixer_offset = gr.multiply_cc()

        fg.connect(self.timing_offset, self.multipath)
        fg.connect(self.multipath, (self.mixer_offset,0))
        fg.connect(self.freq_offset,(self.mixer_offset,1))
        fg.connect(self.mixer_offset, (self.noise_adder,1))
        fg.connect(self.noise, (self.noise_adder,0))
        
        gr.hier_block.__init__(self, fg, self.timing_offset, self.noise_adder)
Example #19
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Top Block")
        _icon_path = "/home/pfb/.local/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 32000

        ##################################################
        # Blocks
        ##################################################
        self.gr_sig_source_x_0 = gr.sig_source_c(samp_rate, gr.GR_COS_WAVE,
                                                 1000, 1, 0)
        self.wxgui_scopesink2_0 = scopesink2.scope_sink_c(
            self.GetWin(),
            title="Scope Plot",
            sample_rate=samp_rate,
            v_scale=0,
            v_offset=0,
            t_scale=0,
            ac_couple=False,
            xy_mode=False,
            num_inputs=1,
        )
        self.Add(self.wxgui_scopesink2_0.win)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.gr_sig_source_x_0, 0), (self.wxgui_scopesink2_0, 0))
    def __init__(self, frame, panel, vbox, argv):
        stdgui.gui_flow_graph.__init__ (self, frame, panel, vbox, argv)

        #number_size = 256

        # build our flow graph
        input_rate = 20.48e3

        # 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)

        # We add these throttle blocks so that this demo doesn't
        # suck down all the CPU available.  Normally you wouldn't use these.
        thr1 = gr.throttle(gr.sizeof_gr_complex, input_rate)

        #sink1 = number_sink_c (self, panel, label="Complex Data", number_size=number_size,
        #                    sample_rate=input_rate, base_value=100e3,
        #                    ref_level=0, decimal_places=3)
        #vbox.Add (sink1.win, 1, wx.EXPAND)
        #self.connect (src1, 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)
        thr2 = gr.throttle(gr.sizeof_float, input_rate)
        sink2 = number_sink_f (self, panel, unit='Hz',label="Real Data", avg_alpha=0.001,#number_size=number_size*2,
                            sample_rate=input_rate, base_value=100e3,
                            ref_level=0, decimal_places=3)
        vbox.Add (sink2.win, 1, wx.EXPAND)
        sink3 = number_sink_c (self, panel, unit='V',label="Complex Data", avg_alpha=0.001,#number_size=number_size*2,
                            sample_rate=input_rate, base_value=0,
                            ref_level=0, decimal_places=3)
        vbox.Add (sink3.win, 1, wx.EXPAND)
        self.connect (src2, thr2, sink2)
        self.connect (src1, thr1, sink3)
Example #21
0
    def test_000(self):
        N = 1000         # number of samples to use
        M = 5            # Number of channels
        fs = 1000        # baseband sampling rate
        ifs = M*fs       # input samp rate to decimator

        #taps = filter.firdes.low_pass_2(M, ifs, fs/2, fs/10,
        #                                attenuation_dB=80,
        #                                window=filter.firdes.WIN_BLACKMAN_hARRIS)
        from pfb_interpolator_taps import taps

        freq = 100
        signal = gr.sig_source_c(fs, gr.GR_COS_WAVE, freq, 1)
        head = gr.head(gr.sizeof_gr_complex, N)
        pfb = filter.pfb_interpolator_ccf(M, taps)
        snk = gr.vector_sink_c()

        self.tb.connect(signal, head, pfb)
        self.tb.connect(pfb, snk)

        self.tb.run() 

        Ntest = 50
        L = len(snk.data())
        t = map(lambda x: float(x)/ifs, xrange(L))

        # Create known data as complex sinusoids at freq
        # of the channel at the interpolated rate.
        phase = 0.62833
        expected_data = map(lambda x: math.cos(2.*math.pi*freq*x+phase) + \
                                1j*math.sin(2.*math.pi*freq*x+phase), t)

        dst_data = snk.data()

        self.assertComplexTuplesAlmostEqual(expected_data[-Ntest:], dst_data[-Ntest:], 4)
Example #22
0
    def __init__(self, port, gain, usrp_rate, lo_freq):
        gr.hier_block2.__init__(self, "tx_channel_usrp",
                                gr.io_signature(0, 0, 0),
                                gr.io_signature(1, 1, gr.sizeof_gr_complex))

        msg_queue = gr.msg_queue(2)
        do_imbe = 1
        do_float = 0
        do_complex = 1
        decim = MAX_COMPLEX_RATE / usrp_rate
        # per-channel GR source block including these steps:
        # - receive audio chunks from asterisk via UDP
        # - imbe encode
        # - generate phase-modulated complex output stream (table lookup method)
        # - generates no power while no input received
        self.chan = repeater.chan_usrp(port, do_imbe, do_complex, do_float,
                                       gain, int(decim), msg_queue)

        # Local oscillator
        lo = gr.sig_source_c(
            usrp_rate,  # sample rate
            gr.GR_SIN_WAVE,  # waveform type
            lo_freq,  #frequency
            1.0,  # amplitude
            0)  # DC Offset
        self.mixer = gr.multiply_cc()
        self.connect(self.chan, (self.mixer, 0))
        self.connect(lo, (self.mixer, 1))
        self.connect(self.mixer, self)
Example #23
0
    def __init__(self):
        gr.top_block.__init__(self, "am modulator")

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 44100
        self.freq = freq = 8000

        ##################################################
        # Blocks
        ##################################################
        self.gr_complex_to_float_0 = gr.complex_to_float(1)
        self.gr_float_to_complex_0 = gr.float_to_complex()
        self.gr_multiply_vxx_0 = gr.multiply_vcc(1)
        self.gr_sig_source_x_0 = gr.sig_source_c(samp_rate, gr.GR_COS_WAVE, freq, 1, 0)
        self.gr_wavfile_sink_0 = gr.wavfile_sink("8k.wav", 2, samp_rate, 16)
        self.gr_wavfile_source_0 = gr.wavfile_source("orig.wav", False)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.gr_sig_source_x_0, 0), (self.gr_multiply_vxx_0, 0))
        self.connect((self.gr_wavfile_source_0, 0), (self.gr_float_to_complex_0, 0))
        self.connect((self.gr_float_to_complex_0, 0), (self.gr_multiply_vxx_0, 1))
        self.connect((self.gr_wavfile_source_0, 1), (self.gr_float_to_complex_0, 1))
        self.connect((self.gr_multiply_vxx_0, 0), (self.gr_complex_to_float_0, 0))
        self.connect((self.gr_complex_to_float_0, 0), (self.gr_wavfile_sink_0, 0))
        self.connect((self.gr_complex_to_float_0, 1), (self.gr_wavfile_sink_0, 1))
    def test_ccf_000(self):
        N = 1000  # number of samples to use
        fs = 1000  # baseband sampling rate
        rrate = 1.123  # resampling rate

        nfilts = 32

        freq = 100
        signal = gr.sig_source_c(fs, gr.GR_SIN_WAVE, freq, 1)
        head = gr.head(gr.sizeof_gr_complex, N)
        pfb = filter.pfb_arb_resampler_ccf(rrate, taps)
        snk = gr.vector_sink_c()

        self.tb.connect(signal, head, pfb, snk)
        self.tb.run()

        Ntest = 50
        L = len(snk.data())
        t = map(lambda x: float(x) / (fs * rrate), xrange(L))

        phase = 0.53013
        expected_data = map(lambda x: math.cos(2.*math.pi*freq*x+phase) + \
                                1j*math.sin(2.*math.pi*freq*x+phase), t)

        dst_data = snk.data()
        self.assertComplexTuplesAlmostEqual(expected_data[-Ntest:],
                                            dst_data[-Ntest:], 3)
Example #25
0
    def __init__(self, frame, panel, vbox, argv):
        stdgui2.std_top_block.__init__ (self, frame, panel, vbox, argv)

        # build our flow graph
        input_rate = 20.48e3

        # Generate a real and complex sinusoids
        src1 = gr.sig_source_f (input_rate, gr.GR_SIN_WAVE, 2.21e3, 1)
        src2 = gr.sig_source_c (input_rate, gr.GR_SIN_WAVE, 2.21e3, 1)

        # We add these throttle blocks so that this demo doesn't
        # suck down all the CPU available.  Normally you wouldn't use these.
        thr1 = gr.throttle(gr.sizeof_float, input_rate)
        thr2 = gr.throttle(gr.sizeof_gr_complex, input_rate)

        sink1 = number_sink_f (panel, unit='V',label="Real Data", avg_alpha=0.001,
                            sample_rate=input_rate, minval=-1, maxval=1,
                            ref_level=0, decimal_places=3)
        vbox.Add (sink1.win, 1, wx.EXPAND)
        sink2 = number_sink_c (panel, unit='V',label="Complex Data", avg_alpha=0.001,
                            sample_rate=input_rate, minval=-1, maxval=1,
                            ref_level=0, decimal_places=3)
        vbox.Add (sink2.win, 1, wx.EXPAND)

        self.connect (src1, thr1, sink1)
        self.connect (src2, thr2, sink2)
Example #26
0
    def setUp(self):
        self.tb = gr.top_block()

        fftl = 512
        waveform = gr.GR_SIN_WAVE
        freq = 0.0
        ampl = 1.0
        offset = 0.0
        cpl = 144 * fftl / 2048
        cpl0 = 160 * fftl / 2048
        slotl = 7 * fftl + 6 * cpl + cpl0
        samp_rate = slotl / 0.0005

        self.sig = gr.sig_source_c(samp_rate, waveform, freq, ampl, offset)
        self.head = gr.head(gr.sizeof_gr_complex, 100000)

        print "amplitude\t" + str(self.sig.amplitude())
        print "frequency\t" + str(self.sig.frequency())
        print "name\t" + str(self.sig.name())
        print "offset\t" + str(self.sig.offset())
        print "samp_rate\t" + str(self.sig.sampling_freq())
        print "waveform\t" + str(self.sig.waveform())

        #print type(self.sig)

        self.est = lte_swig.freq_estimate_c(self.sig, fftl)

        self.tb.connect(self.sig, self.head, self.est)
Example #27
0
    def test_007(self):
        vlen = 128
        syms = 4
        bin1 = vlen / 2 + 2
        bin1_val = 1.0

        expec = numpy.array(numpy.zeros(vlen), numpy.complex)
        expec[bin1] = bin1_val
        expec = concatenate([expec] * syms)

        epsilon = [0.5]
        frame_trigger = numpy.concatenate([[1], [0] * (syms - 1)])

        freq_shift = ofdm.frequency_shift_vcc(vlen, 1.0 / vlen)

        fft = gr.fft_vcc(vlen, True, [], True)  # natural order, dc = vlen / 2
        fft_scale = gr.multiply_const_vcc([1.0 / vlen] * vlen)

        src = gr.sig_source_c(vlen, gr.GR_COS_WAVE, 1.5, 1.0, 0.0)
        # bin vlen/2 + 1.5
        dst = gr.vector_sink_c()
        s2v = gr.stream_to_vector(gr.sizeof_gr_complex, vlen)
        v2s = gr.vector_to_stream(gr.sizeof_gr_complex, vlen)

        eps = gr.vector_source_f(epsilon)
        trig = gr.vector_source_b(frame_trigger.tolist())

        self.fg.connect(src, s2v, (freq_shift, 0))
        self.fg.connect(eps, (freq_shift, 1))
        self.fg.connect(trig, (freq_shift, 2))
        self.fg.connect(freq_shift, fft, fft_scale, v2s, dst)
        self.fg.run()

        self.assertComplexTuplesAlmostEqual2(expec, dst.data(), 1e-5, 1e-5)
Example #28
0
    def __init__(self, filename, lo_freq, audio_rate, if_rate):

        gr.hier_block2.__init__(self, "pipeline",
                                gr.io_signature(0, 0, 0),
                                gr.io_signature(1, 1, gr.sizeof_gr_complex))

        try:
            src = gr.file_source (gr.sizeof_float, filename, True)
        except RuntimeError:
            sys.stderr.write(("\nError: Could not open file '%s'\n\n" % \
                                  filename))
            sys.exit(1)

        print audio_rate, if_rate
        fmtx = blks2.nbfm_tx (audio_rate, if_rate, max_dev=5e3, tau=75e-6)

        # Local oscillator
        lo = gr.sig_source_c (if_rate,        # sample rate
                              gr.GR_SIN_WAVE, # waveform type
                              lo_freq,        #frequency
                              1.0,            # amplitude
                              0)              # DC Offset
        mixer = gr.multiply_cc ()

        self.connect (src, fmtx, (mixer, 0))
        self.connect (lo, (mixer, 1))
        self.connect (mixer, self)
Example #29
0
    def __init__(self, n_sinusoids = 1, SNR = 10, samp_rate = 32e3, nsamples = 2048):
        gr.hier_block2.__init__(self, "ESPRIT/MUSIC signal generator",
                                gr.io_signature(0, 0, gr.sizeof_float),
                                gr.io_signature(1, 1, gr.sizeof_gr_complex))
        sigampl = 10.0**(SNR/10.0) # noise power is 1
        self.srcs = list()

        self.n_sinusoids = n_sinusoids
        self.samp_rate = samp_rate
        # create our signals ...
        for s in range(n_sinusoids):
            self.srcs.append(gr.sig_source_c(samp_rate,
                gr.GR_SIN_WAVE,1000 * s + 2000,
                numpy.sqrt(sigampl/n_sinusoids)))

        seed = ord(os.urandom(1))
        self.noise = gr.noise_source_c(gr.GR_GAUSSIAN, 1, seed)
        self.add = gr.add_cc()
        self.head = gr.head(gr.sizeof_gr_complex, nsamples)
        self.sink = gr.vector_sink_f(vlen=n_sinusoids)
        # wire it up ... 
        for s in range(n_sinusoids):
            self.connect(self.srcs[s], (self.add, s))
        # Additive noise
        self.connect(self.noise, (self.add, n_sinusoids))
        self.connect(self.add, self.head, self)
Example #30
0
	def __init__(self):
		gr.top_block.__init__(self, "Panthro Tx")

		##################################################
		# Variables
		##################################################
		self.samp_rate = samp_rate = 32000

		##################################################
		# Blocks
		##################################################
		self.uhd_usrp_sink_0 = uhd.usrp_sink(
			device_addr="serial=E4R11Y0B1",
			stream_args=uhd.stream_args(
				cpu_format="fc32",
				channels=range(1),
			),
		)
		self.uhd_usrp_sink_0.set_samp_rate(samp_rate)
		self.uhd_usrp_sink_0.set_center_freq(500e6, 0)
		self.uhd_usrp_sink_0.set_gain(5, 0)
		self.uhd_usrp_sink_0.set_bandwidth(100e3, 0)
		self.gr_sig_source_x_0 = gr.sig_source_c(samp_rate, gr.GR_COS_WAVE, 1000, 1, 0)

		##################################################
		# Connections
		##################################################
		self.connect((self.gr_sig_source_x_0, 0), (self.uhd_usrp_sink_0, 0))
Example #31
0
    def test_002_cc(self):
        N = 10000        # number of samples to use
        fs = 1000        # baseband sampling rate
        rrate = 1.123    # resampling rate

        freq = 10
        signal = gr.sig_source_c(fs, gr.GR_SIN_WAVE, freq, 1)
        head = gr.head(gr.sizeof_gr_complex, N)
        op = filter.fractional_interpolator_cc(0.0, rrate)
        snk = gr.vector_sink_c()

        self.tb.connect(signal, head, op, snk)
        self.tb.run() 

        Ntest = 5000
        L = len(snk.data())
        t = map(lambda x: float(x)/(fs/rrate), xrange(L))

        phase = 0.1884
        expected_data = map(lambda x: math.cos(2.*math.pi*freq*x+phase) + \
                                1j*math.sin(2.*math.pi*freq*x+phase), t)

        dst_data = snk.data()

        self.assertComplexTuplesAlmostEqual(expected_data[-Ntest:], dst_data[-Ntest:], 3)
Example #32
0
    def __init__(self, frame, panel, vbox, argv):
        stdgui2.std_top_block.__init__ (self, frame, panel, vbox, argv)

        fft_size = 256

        # build our flow graph
        input_rate = 20.000e3

        # Generate a complex sinusoid
        src1 = gr.sig_source_c (input_rate, gr.GR_SIN_WAVE, 5.75e3, 1000)
        #src1 = gr.sig_source_c (input_rate, gr.GR_CONST_WAVE, 5.75e3, 1000)

        # We add these throttle blocks so that this demo doesn't
        # suck down all the CPU available.  Normally you wouldn't use these.
        thr1 = gr.throttle(gr.sizeof_gr_complex, input_rate)

        sink1 = ra_fft_sink_c (panel, title="Complex Data", fft_size=fft_size,
                            sample_rate=input_rate, baseband_freq=100e3,
                            ref_level=60, y_per_div=10)
        vbox.Add (sink1.win, 1, wx.EXPAND)
        self.connect (src1, thr1, sink1)

        src2 = gr.sig_source_f (input_rate, gr.GR_SIN_WAVE, 5.75e3, 1000)
        #src2 = gr.sig_source_f (input_rate, gr.GR_CONST_WAVE, 5.75e3, 1000)
        thr2 = gr.throttle(gr.sizeof_float, input_rate)
        sink2 = ra_fft_sink_f (panel, title="Real Data", fft_size=fft_size*2,
                            sample_rate=input_rate, baseband_freq=100e3,
                            ref_level=60, y_per_div=10)
        vbox.Add (sink2.win, 1, wx.EXPAND)
        self.connect (src2, thr2, sink2)
Example #33
0
    def __init__(self):
        gr.top_block.__init__(self, "FFT Sink Test")

        fft_size = 256

        # build our flow graph
        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, 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.
        thr1 = gr.throttle(gr.sizeof_gr_complex, input_rate)

        test_fft = zmq_fft_sink_c(title="Complex Data", fft_size=fft_size,
                            sample_rate=input_rate, baseband_freq=100e3,
                            ref_level=0, y_per_div=20, y_divs=10)

        combine1 = gr.add_cc()
        #self.connect(src1, (combine1, 0))
        #self.connect(noise,(combine1, 1))
        self.connect(src1, thr1, test_fft)
    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)
Example #35
0
    def __init__(self):
        gr.top_block.__init__(self)

        parser = OptionParser(option_class=eng_option)
        parser.add_option("-r", "--sample-rate", type="eng_float", default=1000000,
                          help="set sample rate to RATE [default=%default]")
        parser.add_option("-f", "--freq", type="eng_float", default=650000000,
                          help="set RF frequency [default=%default]")
        parser.add_option("", "--sin_freq", type="eng_float", default=100000,
                          help="set sinusoid frequency [default=%default]")
        parser.add_option("-a", "--amp", type="eng_float", default=.8,
		                  help="set sinusoid amplitude, 0<=amp<=1 [default=%default]")
                          
        (options, args) = parser.parse_args ()
        if len(args) != 0:
            parser.print_help()
            raise SystemExit, 1

        sample_rate = int(options.sample_rate)
        ampl = options.amp

        src0 = gr.sig_source_c (sample_rate, gr.GR_CONST_WAVE, options.sin_freq, ampl)
        dst =  uhd.usrp_sink(device_addr="", io_type=uhd.io_type.COMPLEX_FLOAT32, num_channels=1)
        dst.set_samp_rate(sample_rate) 
        dst.set_center_freq(options.freq, 0)
        dst.set_gain(dst.get_gain_range().stop()/2, 0)

        self.connect (src0, dst)
Example #36
0
    def __init__(self, frame, panel, vbox, argv):
        stdgui2.std_top_block.__init__ (self, frame, panel, vbox, argv)

        fft_size = 512

        # build our flow graph
        input_rate = 20.000e3

        # Generate a complex sinusoid
        self.src1 = gr.sig_source_c (input_rate, gr.GR_SIN_WAVE, 5.75e3, 1000)
        #src1 = gr.sig_source_c (input_rate, gr.GR_CONST_WAVE, 5.75e3, 1000)

        # We add these throttle blocks so that this demo doesn't
        # suck down all the CPU available.  Normally you wouldn't use these.
        self.thr1 = gr.throttle(gr.sizeof_gr_complex, input_rate)

        sink1 = waterfall_sink_c (panel, title="Complex Data", fft_size=fft_size,
                                  sample_rate=input_rate, baseband_freq=100e3)
	self.connect(self.src1, self.thr1, sink1)
        vbox.Add (sink1.win, 1, wx.EXPAND)

        # generate a real sinusoid
        self.src2 = gr.sig_source_f (input_rate, gr.GR_SIN_WAVE, 5.75e3, 1000)
        self.thr2 = gr.throttle(gr.sizeof_float, input_rate)
        sink2 = waterfall_sink_f (panel, title="Real Data", fft_size=fft_size,
                                  sample_rate=input_rate, baseband_freq=100e3)
	self.connect(self.src2, self.thr2, sink2)
        vbox.Add (sink2.win, 1, wx.EXPAND)
	def __init__(self):
		grc_wxgui.top_block_gui.__init__(self, title="Transmit900")

		##################################################
		# Variables
		##################################################
		self.samp_rate = samp_rate = 320000

		##################################################
		# Blocks
		##################################################
		self.uhd_usrp_sink_0 = uhd.usrp_sink(
			device_addr="",
			stream_args=uhd.stream_args(
				cpu_format="fc32",
				channels=range(1),
			),
		)
		self.uhd_usrp_sink_0.set_samp_rate(samp_rate)
		self.uhd_usrp_sink_0.set_center_freq(900000000, 0)
		self.uhd_usrp_sink_0.set_gain(100, 0)
		self.gr_sig_source_x_0 = gr.sig_source_c(samp_rate, gr.GR_SIN_WAVE, 1000, 1, 0)
		self.gr_multiply_const_vxx_0 = gr.multiply_const_vcc((16384, ))

		##################################################
		# Connections
		##################################################
		self.connect((self.gr_sig_source_x_0, 0), (self.gr_multiply_const_vxx_0, 0))
		self.connect((self.gr_multiply_const_vxx_0, 0), (self.uhd_usrp_sink_0, 0))
Example #38
0
def build_block (tx_enable, rx_enable):
    max_usb_rate = 8e6                  # 8 MS/sec
    dac_freq = 128e6
    adc_freq =  64e6
    
    tx_nchan = 2
    tx_mux = 0x0000ba98
    tx_interp =  int (dac_freq / (max_usb_rate/2 * tx_nchan)) # 16
    
    rx_nchan = 2
    rx_mux = 0x00003210
    rx_decim = int ((adc_freq * rx_nchan) / (max_usb_rate/2)) # 32
    
    tb = gr.top_block ()

    if tx_enable:
        tx_src0 = gr.sig_source_c (dac_freq/tx_interp, gr.GR_CONST_WAVE, 0, 16e3, 0)
        usrp_tx = usrp.sink_c (0, tx_interp, tx_nchan, tx_mux)
        usrp_tx.set_tx_freq (0, 10e6)
        usrp_tx.set_tx_freq (1,  9e6)
        tb.connect (tx_src0, usrp_tx)

    if rx_enable:
        usrp_rx = usrp.source_c (0, rx_decim, rx_nchan, rx_mux)
        usrp_rx.set_rx_freq (0, 5.5e6)
        usrp_rx.set_rx_freq (1, 6.5e6)
        rx_dst0 = gr.null_sink (gr.sizeof_gr_complex)
        tb.connect (usrp_rx, rx_dst0)

    return tb
Example #39
0
    def __init__(self, fs_in, fs_out, fc, N=10000):
        gr.top_block.__init__(self)

        rerate = float(fs_out) / float(fs_in)
        print "Resampling from %f to %f by %f " % (fs_in, fs_out, rerate)

        # Creating our own taps
        taps = gr.firdes.low_pass_2(32, 32, 0.25, 0.1, 80)

        self.src = gr.sig_source_c(fs_in, gr.GR_SIN_WAVE, fc, 1)
        #self.src = gr.noise_source_c(gr.GR_GAUSSIAN, 1)
        self.head = gr.head(gr.sizeof_gr_complex, N)

        # A resampler with our taps
        self.resamp_0 = blks2.pfb_arb_resampler_ccf(rerate, taps, flt_size=32)

        # A resampler that just needs a resampling rate.
        # Filter is created for us and designed to cover
        # entire bandwidth of the input signal.
        # An optional atten=XX rate can be used here to
        # specify the out-of-band rejection (default=80).
        self.resamp_1 = blks2.pfb_arb_resampler_ccf(rerate)

        self.snk_in = gr.vector_sink_c()
        self.snk_0 = gr.vector_sink_c()
        self.snk_1 = gr.vector_sink_c()

        self.connect(self.src, self.head, self.snk_in)
        self.connect(self.head, self.resamp_0, self.snk_0)
        self.connect(self.head, self.resamp_1, self.snk_1)
Example #40
0
    def setUp (self):
        self.tb = gr.top_block ()
        
        
        fftl = 512
        waveform = gr.GR_SIN_WAVE
        freq = 0.0
        ampl = 1.0
        offset = 0.0
        cpl = 144 * fftl / 2048
        cpl0 = 160 * fftl / 2048
        slotl = 7 * fftl + 6 * cpl + cpl0
        samp_rate = slotl / 0.0005

        self.sig = gr.sig_source_c(samp_rate,waveform,freq,ampl,offset)
        self.head = gr.head(gr.sizeof_gr_complex, 100000)
        
        print "amplitude\t" + str(self.sig.amplitude())
        print "frequency\t" + str(self.sig.frequency())
        print "name\t" + str(self.sig.name())
        print "offset\t" + str(self.sig.offset())
        print "samp_rate\t" + str(self.sig.sampling_freq())
        print "waveform\t" + str(self.sig.waveform())
        
        #print type(self.sig)
        
        self.est = lte_swig.freq_estimate_c(self.sig,fftl)
        
        self.tb.connect(self.sig,self.head,self.est)
Example #41
0
    def __init__(self, frame, panel, vbox, argv):
        stdgui2.std_top_block	.__init__ (self, frame, panel, vbox, argv)

        fac_size = 256

        # build our flow graph
        input_rate = 20.48e3

        # 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)

        # We add these throttle blocks so that this demo doesn't
        # suck down all the CPU available.  Normally you wouldn't use these.
        thr1 = gr.throttle(gr.sizeof_gr_complex, input_rate)

        sink1 = fac_sink_c (panel, title="Complex Data", fac_size=fac_size,
                            sample_rate=input_rate, baseband_freq=100e3,
                            ref_level=0, y_per_div=20)
        vbox.Add (sink1.win, 1, wx.EXPAND)
        self.connect (src1, 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)
        thr2 = gr.throttle(gr.sizeof_float, input_rate)
        sink2 = fac_sink_f (panel, title="Real Data", fac_size=fac_size*2,
                            sample_rate=input_rate, baseband_freq=100e3,
                            ref_level=0, y_per_div=20)
        vbox.Add (sink2.win, 1, wx.EXPAND)
        self.connect (src2, thr2, sink2)
    def test_ccf_000(self):
        N = 1000         # number of samples to use
        fs = 1000        # baseband sampling rate
        rrate = 1.123    # resampling rate

        nfilts = 32

        freq = 100
        signal = gr.sig_source_c(fs, gr.GR_SIN_WAVE, freq, 1)
        head = gr.head(gr.sizeof_gr_complex, N)
        pfb = filter.pfb_arb_resampler_ccf(rrate, taps)
        snk = gr.vector_sink_c()

        self.tb.connect(signal, head, pfb, snk)
        self.tb.run() 

        Ntest = 50
        L = len(snk.data())
        t = map(lambda x: float(x)/(fs*rrate), xrange(L))

        phase = 0.53013
        expected_data = map(lambda x: math.cos(2.*math.pi*freq*x+phase) + \
                                1j*math.sin(2.*math.pi*freq*x+phase), t)

        dst_data = snk.data()
        self.assertComplexTuplesAlmostEqual(expected_data[-Ntest:], dst_data[-Ntest:], 3)
    def __init__(self, atten=0, fd=50, fadeMode=0):
        gr.top_block.__init__(self,
                              "Static RF or Single Path Rayleigh Faded RF")

        ##################################################
        # Parameters
        ##################################################
        self.atten = atten
        self.fd = fd
        self.fadeMode = fadeMode

        ##################################################
        # Variables
        ##################################################
        self.usrpRate = usrpRate = 250e3
        self.fdTs = fdTs = fd * (1.0 / usrpRate)
        self.centreFreq = centreFreq = 1e6
        self.baseband_multiplier = baseband_multiplier = 0.25

        ##################################################
        # Blocks
        ##################################################
        self.xmlrpc_server_0 = SimpleXMLRPCServer.SimpleXMLRPCServer(
            ("0.0.0.0", 1234), allow_none=True)
        self.xmlrpc_server_0.register_instance(self)
        threading.Thread(target=self.xmlrpc_server_0.serve_forever).start()
        self.uhd_usrp_sink_0_0_0 = uhd.usrp_sink(
            device_addr="",
            stream_args=uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ),
        )
        self.uhd_usrp_sink_0_0_0.set_subdev_spec("A:AB", 0)
        self.uhd_usrp_sink_0_0_0.set_samp_rate(usrpRate)
        self.uhd_usrp_sink_0_0_0.set_center_freq(centreFreq, 0)
        self.uhd_usrp_sink_0_0_0.set_gain(0, 0)
        self.rccBlocks_channelModel_cc_0 = rccBlocks.channelModel_cc(
            randint(-10000, 0), fdTs, 1.0, False, bool(fadeMode))
        self.rccBlocks_VNXLabBrick_0 = rccBlocks.VNXLabBrick(atten)
        self.const_source_x_0_0 = gr.sig_source_f(0, gr.GR_CONST_WAVE, 0, 0,
                                                  1.0)
        self.const_source_x_0 = gr.sig_source_c(0, gr.GR_CONST_WAVE, 0, 0,
                                                1.0 + 1j)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_float * 1, usrpRate)
        self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vcc(
            (baseband_multiplier, ))

        ##################################################
        # Connections
        ##################################################
        self.connect((self.const_source_x_0, 0),
                     (self.rccBlocks_channelModel_cc_0, 0))
        self.connect((self.blocks_multiply_const_vxx_1, 0),
                     (self.uhd_usrp_sink_0_0_0, 0))
        self.connect((self.const_source_x_0_0, 0), (self.blocks_throttle_0, 0))
        self.connect((self.blocks_throttle_0, 0),
                     (self.rccBlocks_VNXLabBrick_0, 0))
        self.connect((self.rccBlocks_channelModel_cc_0, 0),
                     (self.blocks_multiply_const_vxx_1, 0))
Example #44
0
	def __init__(self):
		grc_wxgui.top_block_gui.__init__(self, title="Top Block")
		_icon_path = "/home/pfb/.local/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
		self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

		##################################################
		# Variables
		##################################################
		self.samp_rate = samp_rate = 32000

		##################################################
		# Blocks
		##################################################
		self.gr_sig_source_x_0 = gr.sig_source_c(samp_rate, gr.GR_COS_WAVE, 1000, 1, 0)
		self.wxgui_scopesink2_0 = scopesink2.scope_sink_c(
			self.GetWin(),
			title="Scope Plot",
			sample_rate=samp_rate,
			v_scale=0,
			v_offset=0,
			t_scale=0,
			ac_couple=False,
			xy_mode=False,
			num_inputs=1,
		)
		self.Add(self.wxgui_scopesink2_0.win)

		##################################################
		# Connections
		##################################################
		self.connect((self.gr_sig_source_x_0, 0), (self.wxgui_scopesink2_0, 0))
Example #45
0
    def __init__(self, fs_in, fs_out, fc, N=10000):
        gr.top_block.__init__(self)
        
        rerate = float(fs_out) / float(fs_in)
        print "Resampling from %f to %f by %f " %(fs_in, fs_out, rerate)

        # Creating our own taps
        taps = gr.firdes.low_pass_2(32, 32, 0.25, 0.1, 80)

        self.src = gr.sig_source_c(fs_in, gr.GR_SIN_WAVE, fc, 1)
        #self.src = gr.noise_source_c(gr.GR_GAUSSIAN, 1)
        self.head = gr.head(gr.sizeof_gr_complex, N)

        # A resampler with our taps
        self.resamp_0 = blks2.pfb_arb_resampler_ccf(rerate, taps,
                                                    flt_size=32)

        # A resampler that just needs a resampling rate.
        # Filter is created for us and designed to cover
        # entire bandwidth of the input signal.
        # An optional atten=XX rate can be used here to 
        # specify the out-of-band rejection (default=80).
        self.resamp_1 = blks2.pfb_arb_resampler_ccf(rerate)

        self.snk_in = gr.vector_sink_c()
        self.snk_0 = gr.vector_sink_c()
        self.snk_1 = gr.vector_sink_c()

        self.connect(self.src, self.head, self.snk_in)
        self.connect(self.head, self.resamp_0, self.snk_0)
        self.connect(self.head, self.resamp_1, self.snk_1)
Example #46
0
	def __init__(self):
		gr.top_block.__init__(self, "Spec Analyzer")

		##################################################
		# Variables
		##################################################
		self.samp_rate = samp_rate = 125e3

		##################################################
		# Blocks
		##################################################
		self.uhd_usrp_sink_0 = uhd.usrp_sink(
			device_addr="",
			stream_args=uhd.stream_args(
				cpu_format="fc32",
				channels=range(1),
			),
		)
		self.uhd_usrp_sink_0.set_samp_rate(samp_rate)
		self.uhd_usrp_sink_0.set_center_freq(925e6, 0)
		self.uhd_usrp_sink_0.set_gain(0, 0)
		self.uhd_usrp_sink_0.set_antenna("TX/RX", 0)
		self.const_source_x_0 = gr.sig_source_c(0, gr.GR_CONST_WAVE, 0, 0, .02)

		##################################################
		# Connections
		##################################################
		self.connect((self.const_source_x_0, 0), (self.uhd_usrp_sink_0, 0))
Example #47
0
    def __init__(self, port, gain, usrp_rate, lo_freq):
        gr.hier_block2.__init__(self, "tx_channel_usrp",
                                gr.io_signature(0, 0, 0),
                                gr.io_signature(1, 1, gr.sizeof_gr_complex))

        msg_queue = gr.msg_queue(2)
        do_imbe = 1
        do_float = 0
        do_complex = 1
        decim = MAX_COMPLEX_RATE / usrp_rate
        # per-channel GR source block including these steps:
        # - receive audio chunks from asterisk via UDP
        # - imbe encode
        # - generate phase-modulated complex output stream (table lookup method)
        # - generates no power while no input received
        self.chan = repeater.chan_usrp(port, do_imbe, do_complex, do_float, gain, int(decim), msg_queue)

        # Local oscillator
        lo = gr.sig_source_c (usrp_rate,      # sample rate
                              gr.GR_SIN_WAVE, # waveform type
                              lo_freq,        #frequency
                              1.0,            # amplitude
                              0)              # DC Offset
        self.mixer = gr.multiply_cc ()
        self.connect (self.chan, (self.mixer, 0))
        self.connect (lo, (self.mixer, 1))
        self.connect (self.mixer, self)
Example #48
0
    def test_000(self):
        N = 10000  # number of samples to use
        M = 5  # Number of channels
        fs = 1000  # baseband sampling rate
        ofs = M * fs  # input samp rate to decimator

        taps = filter.firdes.low_pass_2(
            M,
            ofs,
            fs / 2,
            fs / 10,
            attenuation_dB=80,
            window=filter.firdes.WIN_BLACKMAN_hARRIS)

        signals = list()
        freqs = [0, 100, 200, -200, -100]
        for i in xrange(len(freqs)):
            signals.append(gr.sig_source_c(fs, gr.GR_SIN_WAVE, freqs[i], 1))

        head = gr.head(gr.sizeof_gr_complex, N)
        pfb = filter.pfb_synthesizer_ccf(M, taps)
        snk = gr.vector_sink_c()

        for i in xrange(M):
            self.tb.connect(signals[i], (pfb, i))

        self.tb.connect(pfb, head, snk)

        self.tb.run()

        Ntest = 1000
        L = len(snk.data())
        t = map(lambda x: float(x) / ofs, xrange(L))

        # Create known data as sum of complex sinusoids at freqs
        # of the output channels.
        freqs = [-2200, -1100, 0, 1100, 2200]
        expected_data = len(t) * [
            0,
        ]
        for i in xrange(len(t)):
            expected_data[i] = math.cos(2.*math.pi*freqs[0]*t[i]) + \
                            1j*math.sin(2.*math.pi*freqs[0]*t[i]) + \
                               math.cos(2.*math.pi*freqs[1]*t[i]) + \
                            1j*math.sin(2.*math.pi*freqs[1]*t[i]) + \
                               math.cos(2.*math.pi*freqs[2]*t[i]) + \
                            1j*math.sin(2.*math.pi*freqs[2]*t[i]) + \
                               math.cos(2.*math.pi*freqs[3]*t[i]) + \
                            1j*math.sin(2.*math.pi*freqs[3]*t[i]) + \
                               math.cos(2.*math.pi*freqs[4]*t[i]) + \
                            1j*math.sin(2.*math.pi*freqs[4]*t[i])
        dst_data = snk.data()

        offset = 25
        self.assertComplexTuplesAlmostEqual(
            expected_data[2000 - offset:2000 - offset + Ntest],
            dst_data[2000:2000 + Ntest], 4)
Example #49
0
    def __init__(self):
        gr.top_block.__init__(self)

        self._N = 2000000  # number of samples to use
        self._fs = 1000  # initial sampling rate
        self._M = M = 9  # Number of channels to channelize
        self._ifs = M * self._fs  # initial sampling rate

        # Create a set of taps for the PFB channelizer
        self._taps = filter.firdes.low_pass_2(
            1,
            self._ifs,
            475.50,
            50,
            attenuation_dB=100,
            window=filter.firdes.WIN_BLACKMAN_hARRIS)

        # Calculate the number of taps per channel for our own information
        tpc = scipy.ceil(float(len(self._taps)) / float(self._M))
        print "Number of taps:     ", len(self._taps)
        print "Number of channels: ", self._M
        print "Taps per channel:   ", tpc

        # Create a set of signals at different frequencies
        #   freqs lists the frequencies of the signals that get stored
        #   in the list "signals", which then get summed together
        self.signals = list()
        self.add = gr.add_cc()
        freqs = [-70, -50, -30, -10, 10, 20, 40, 60, 80]
        for i in xrange(len(freqs)):
            f = freqs[i] + (M / 2 - M + i + 1) * self._fs
            self.signals.append(
                gr.sig_source_c(self._ifs, gr.GR_SIN_WAVE, f, 1))
            self.connect(self.signals[i], (self.add, i))

        self.head = gr.head(gr.sizeof_gr_complex, self._N)

        # Construct the channelizer filter
        self.pfb = filter.pfb.channelizer_ccf(self._M, self._taps, 1)

        # Construct a vector sink for the input signal to the channelizer
        self.snk_i = gr.vector_sink_c()

        # Connect the blocks
        self.connect(self.add, self.head, self.pfb)
        self.connect(self.add, self.snk_i)

        # Use this to play with the channel mapping
        #self.pfb.set_channel_map([5,6,7,8,0,1,2,3,4])

        # Create a vector sink for each of M output channels of the filter and connect it
        self.snks = list()
        for i in xrange(self._M):
            self.snks.append(gr.vector_sink_c())
            self.connect((self.pfb, i), self.snks[i])
    def __init__(self, sample_rate):
        gr.hier_block2.__init__(self, "example_signal_1",
                                gr.io_signature(0, 0, 0),                    # Input signature
                                gr.io_signature(1, 1, gr.sizeof_gr_complex)) # Output signature

        src0 = gr.sig_source_c (sample_rate,    # sample rate
                                gr.GR_SIN_WAVE, # waveform type
                                350,            # frequency
                                1.0,            # amplitude
                                0)              # DC Offset

        src1 = gr.sig_source_c (sample_rate,    # sample rate
                                gr.GR_SIN_WAVE, # waveform type
                                440,            # frequency
                                1.0,            # amplitude
                                0)              # DC Offset
        sum = gr.add_cc()
        self.connect(src0, (sum, 0))
        self.connect(src1, (sum, 1))
        self.connect(sum, self)
 def test_tri_c (self):
     tb = self.tb
     expected_result = (1+.5j, .75+.75j, .5+1j, .25+.75j, 0+.5j, .25+.25j, .5+0j, .75+.25j, 1+.5j)
     src1 = gr.sig_source_c (8, gr.GR_TRI_WAVE, 1.0, 1.0)
     op = gr.head (gr.sizeof_gr_complex, 9)
     dst1 = gr.vector_sink_c ()
     tb.connect (src1, op)
     tb.connect (op, dst1)
     tb.run ()
     dst_data = dst1.data ()
     self.assertComplexTuplesAlmostEqual (expected_result, dst_data, 5)
 def test_sqr_c (self):
     tb = self.tb						#arg6 is a bit before -PI/2
     expected_result = (1j, 1j, 0, 0, 1, 1, 1+0j, 1+1j, 1j)
     src1 = gr.sig_source_c (8, gr.GR_SQR_WAVE, 1.0, 1.0)
     op = gr.head (gr.sizeof_gr_complex, 9)
     dst1 = gr.vector_sink_c ()
     tb.connect (src1, op)
     tb.connect (op, dst1)
     tb.run ()
     dst_data = dst1.data ()
     self.assertEqual (expected_result, dst_data)
Example #53
0
    def test_001_t(self):
        # set up fg
        sample_rate = 256000
        source = gr.sig_source_c(sample_rate, gr.GR_COS_WAVE, 0.0, 1, 0)

        d = doppler.doppler_c(
            '1 35935U 09051E   13214.30935178  .00000351  00000-0  95268-4 0  2690',
            '2 35935  98.3696 322.5545 0007075 281.7840  78.2562 14.53379957204541',
            437.0e6, sample_rate, 52.44332, -0.10982, 10.0, 2013, 8, 3, 13, 39,
            0, 0)

        self.tb.run()
Example #54
0
    def __init__(self, frame, panel, vbox, argv):
        stdgui2.std_top_block.__init__(self, frame, panel, vbox, argv)

        fft_size = 256

        # build our flow graph
        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, 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.
        thr1 = gr.throttle(gr.sizeof_gr_complex, input_rate)

        sink1 = fft_sink_c(panel,
                           title="Complex Data",
                           fft_size=fft_size,
                           sample_rate=input_rate,
                           baseband_freq=100e3,
                           ref_level=0,
                           y_per_div=20,
                           y_divs=10)
        vbox.Add(sink1.win, 1, wx.EXPAND)

        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, 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)

        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)