def build_graph():
    sample_rate = 8000
    scale_factor = 32000

    tb = gr.top_block()
    src = audio.source(sample_rate, "plughw:0,0")
    src_scale = blocks.multiply_const_ff(scale_factor)

    interp = filter.rational_resampler_fff(8, 1)
    f2s = blocks.float_to_short()

    enc = vocoder.cvsd_encode_sb()
    dec = vocoder.cvsd_decode_bs()

    s2f = blocks.short_to_float()
    decim = filter.rational_resampler_fff(1, 8)

    sink_scale = blocks.multiply_const_ff(1.0/scale_factor)
    sink = audio.sink(sample_rate, "plughw:0,0")

    tb.connect(src, src_scale, interp, f2s, enc)
    tb.connect(enc, dec, s2f, decim, sink_scale, sink)

    if 0: # debug
        tb.conect(src, blocks.file_sink(gr.sizeof_float, "source.dat"))
        tb.conect(src_scale, blocks.file_sink(gr.sizeof_float, "src_scale.dat"))
        tb.conect(interp, blocks.file_sink(gr.sizeof_float, "interp.dat"))
        tb.conect(f2s, blocks.file_sink(gr.sizeof_short, "f2s.dat"))
        tb.conect(enc, blocks.file_sink(gr.sizeof_char,  "enc.dat"))
        tb.conect(dec, blocks.file_sink(gr.sizeof_short, "dec.dat"))
        tb.conect(s2f, blocks.file_sink(gr.sizeof_float, "s2f.dat"))
        tb.conect(decim, blocks.file_sink(gr.sizeof_float, "decim.dat"))
        tb.conect(sink_scale, blocks.file_sink(gr.sizeof_float, "sink_scale.dat"))

    return tb
Exemple #2
0
    def __init__(self):
        gr.top_block.__init__(self, "Dttsprx")

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 8000000

        ##################################################
        # Blocks
        ##################################################
        self.low_pass_filter_0 = filter.fir_filter_ccf(int(samp_rate/48000), firdes.low_pass(
        	1, samp_rate, 48000, 1000, firdes.WIN_HAMMING, 6.76))
        self.blocks_interleaved_char_to_complex_0 = blocks.interleaved_char_to_complex(False)
        self.blocks_file_source_0 = blocks.file_source(gr.sizeof_char*1, "/tmp/iqdata", False)
        self.blocks_complex_to_float_0 = blocks.complex_to_float(1)
        self.audio_sink_0 = audio.sink(48000, "", True)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_complex_to_float_0, 1), (self.audio_sink_0, 1))    
        self.connect((self.blocks_complex_to_float_0, 0), (self.audio_sink_0, 0))    
        self.connect((self.blocks_file_source_0, 0), (self.blocks_interleaved_char_to_complex_0, 0))    
        self.connect((self.blocks_interleaved_char_to_complex_0, 0), (self.low_pass_filter_0, 0))    
        self.connect((self.low_pass_filter_0, 0), (self.blocks_complex_to_float_0, 0))    
Exemple #3
0
    def __init__(self):
        gr.top_block.__init__(self, "Top Block")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Top Block")
        try:
             self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
             pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

        self.settings = Qt.QSettings("GNU Radio", "top_block")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Blocks
        ##################################################
        self.audio_sink_0 = audio.sink(48000, "", True)
        self.analog_sig_source_x_0 = analog.sig_source_f(48000, analog.GR_COS_WAVE, 1000, 1, 0)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_sig_source_x_0, 0), (self.audio_sink_0, 0))    
Exemple #4
0
 def __init__(self, controller, muted=True):
     #   ------------------------------------------------------------------------
     super(AudioSinkAdapter, self).__init__()
     self.controller = controller
     self.samprate = controller.samprate
     self.mute = gr.mute_ff(muted)
     self.sink = audio.sink(self.samprate, "", True)
    def __init__(self):
        gr.top_block.__init__(self)

        parser = OptionParser(option_class=eng_option)
        parser.add_option("-O", "--audio-output", type="string", default="",
                          help="pcm output device name.  E.g., hw:0,0 or /dev/dsp")
        parser.add_option("-i", "--input-rate", type="eng_float", default=8000,
                          help="set input sample rate to RATE (%default)")
        parser.add_option("-o", "--output-rate", type="eng_float", default=48000,
                          help="set output sample rate to RATE (%default)")
        (options, args) = parser.parse_args()
        if len(args) != 0:
            parser.print_help()
            raise SystemExit, 1

        input_rate = int(options.input_rate)
        output_rate = int(options.output_rate)

        interp = gru.lcm(input_rate, output_rate) / input_rate
        decim = gru.lcm(input_rate, output_rate) / output_rate

        print "interp =", interp
        print "decim  =", decim

        ampl = 0.1
        src0 = analog.sig_source_f(input_rate, analog.GR_SIN_WAVE, 650, ampl)
        rr = filter.rational_resampler_fff(interp, decim)
        dst = audio.sink(output_rate, options.audio_output)
        self.connect(src0, rr, (dst, 0))
Exemple #6
0
    def __init__(self):
        gr.top_block.__init__(self)

        parser = OptionParser(option_class=eng_option)
        parser.add_option("-I", "--audio-input", type="string", default="",
                          help="pcm input device name.  E.g., hw:0,0 or /dev/dsp")
        parser.add_option("-O", "--audio-output", type="string", default="",
                          help="pcm output device name.  E.g., hw:0,0 or /dev/dsp")
        parser.add_option("-r", "--sample-rate", type="eng_float", default=8000,
                          help="set sample rate to RATE (8000)")
        (options, args) = parser.parse_args ()
        if len(args) != 0:
            parser.print_help()
            raise SystemExit, 1

        sample_rate = int(options.sample_rate)
        src = audio.source (sample_rate, options.audio_input)
        dst = audio.sink (sample_rate, options.audio_output)

	vec1 = [1, -1]
	vsource = gr.vector_source_f(vec1, True)
	multiply = gr.multiply_ff()

	self.connect(src, (multiply, 0))
	self.connect(vsource, (multiply, 1))
	self.connect(multiply, dst)
Exemple #7
0
 def xInit(self, signals, noises, sinks):
 #   ------------------------------------------------------------------------
     self.sources = {}
     self.mutes = {}
     self.amps = {}
     
     #sources
     for signal in signals:
         self.sources[signal] = gr.sig_source_f(
             self.samprate, gr.GR_SIN_WAVE, 440, 0.25, 0)
         self.mutes[signal] = gr.mute_ff(True)
         self.amps[signal] = gr.multiply_const_ff(0.25)
     for noise in noises:
         self.sources[noise] = analog.noise_source_f(
             analog.GR_LAPLACIAN, 1, 0)
         self.mutes[noise] = gr.mute_ff(True)
         self.amps[noise] = gr.multiply_const_ff(0.25)
     #mixer
     if len(self.sources) > 1:
         self.adder = self.add = gr.add_vff(1)
     else:
         self.adder = gr.multiply_const_vff((1, ))
     self.level = gr.multiply_const_ff(1)
     
     #sinks
     self.sinks = sinks
         
     self.audiomute = gr.mute_ff(True)
     self.audio = audio.sink(self.samprate, "", True)
     self.udp = gr.null_sink(gr.sizeof_float)
     self.rawfile = gr.null_sink(gr.sizeof_float)
     self.wavefile = gr.null_sink(gr.sizeof_float)
	def __init__(self, center_freq, offset_freq, decimate_am=1, play_audio=False):
		"""Configure the RTL-SDR and GNU Radio"""
		super(rtlsdr_am_stream, self).__init__()
		
		audio_rate = 44100
		device_rate = audio_rate * 25
		output_rate = audio_rate / float(decimate_am)
		self.rate = output_rate

		self.osmosdr_source = osmosdr.source_c("")
		self.osmosdr_source.set_center_freq(freq)
		self.osmosdr_source.set_sample_rate(device_rate)

		taps = firdes.low_pass(1, device_rate, 40000, 5000, firdes.WIN_HAMMING, 6.76)
		self.freq_filter = gr.freq_xlating_fir_filter_ccc(25, taps, -freq_offs, device_rate)

		self.am_demod = blks2.am_demod_cf(
			channel_rate=audio_rate,
			audio_decim=1,
			audio_pass=5000,
			audio_stop=5500,
		)
		self.resampler = blks2.rational_resampler_fff(
			interpolation=1,
			decimation=decimate_am,
		)
		self.sink = gr_queue.queue_sink_f()
		
		self.connect(self.osmosdr_source, self.freq_filter, self.am_demod)
		self.connect(self.am_demod, self.resampler, self.sink)
		
		if play_audio:
			self.audio_sink = audio.sink(audio_rate, "", True)
			self.connect(self.am_demod, self.audio_sink)
Exemple #9
0
    def __init__(self, options):
        gr.top_block.__init__(self, "mhp")

        self.lfsr = lfsr.p25p2_lfsr(options.nac, options.sysid, options.wacn)
        xor_mask = ''
        for c in self.lfsr.xorsyms:
            xor_mask += chr(c)

        IN = blocks.file_source(gr.sizeof_char, options.input_file)

        slotid = options.tdma_slotid
        msgq = gr.msg_queue(2)
        do_msgq  = False

        wireshark_host = ''
        udp_port = 0
        verbosity = 100
        do_imbe = 1
        do_output = 1
        do_msgq = 0
        rx_q = gr.msg_queue(1)
        do_audio_output = 1
        phase2_tdma = 1
        
        FRAMER = op25_repeater.p25_frame_assembler(wireshark_host, udp_port, verbosity, do_imbe, do_output, do_msgq, rx_q, do_audio_output, phase2_tdma)
        FRAMER.set_xormask(xor_mask)

        S2F = blocks.short_to_float()
        M = blocks.multiply_const_ff(1.0 / 32767.0)

        SINK = audio.sink(8000, 'plughw:0,0')
        
        self.connect(IN, FRAMER, S2F, M, SINK)
Exemple #10
0
	def __init__(self,
			device_name,
			sample_rate,
			quadrature_as_stereo):
		self.__device_name = device_name
		self.__sample_rate = sample_rate
		self.__quadrature_as_stereo = quadrature_as_stereo
		
		self.__signal_type = SignalType(
			# TODO: type should be able to be LSB
			kind='IQ' if quadrature_as_stereo else 'USB',
			sample_rate=self.__sample_rate)
		
		gr.hier_block2.__init__(
			self, type(self).__name__,
			gr.io_signature(1, 1, gr.sizeof_gr_complex * 1),
			gr.io_signature(0, 0, 0),
		)
		
		sink = audio.sink(
			self.__sample_rate,
			device_name=self.__device_name,
			ok_to_block=True)
		
		split = blocks.complex_to_float(1)
		self.connect(self, split, (sink, 0))
		self.connect((split, 1), (sink, 1))
Exemple #11
0
    def __init__(self):
        gr.top_block.__init__(self)
        parser = OptionParser(option_class=eng_option)
        parser.add_option("-a", "--audio-input", type="string", default="")
        parser.add_option("-A", "--audio-output", type="string", default="")
        parser.add_option("-f", "--factor", type="eng_float", default=1)
        parser.add_option("-i", "--do-interp", action="store_true", default=False, help="enable output interpolator")
        parser.add_option("-s", "--sample-rate", type="int", default=48000, help="input sample rate")
        parser.add_option("-S", "--stretch", type="int", default=0, help="flex amt")
        parser.add_option("-y", "--symbol-rate", type="int", default=4800, help="input symbol rate")
        parser.add_option("-v", "--verbose", action="store_true", default=False, help="dump demodulation data")
        (options, args) = parser.parse_args()
 
        sample_rate = options.sample_rate
        symbol_rate = options.symbol_rate

        IN = audio.source(sample_rate, options.audio_input)
        audio_output_rate = 8000
        if options.do_interp:
            audio_output_rate = 48000
        OUT = audio.sink(audio_output_rate, options.audio_output)

        symbol_decim = 1
        symbol_coeffs = gr.firdes.root_raised_cosine(1.0,	# gain
                                          sample_rate ,	# sampling rate
                                          symbol_rate,  # symbol rate
                                          0.2,     	# width of trans. band
                                          500) 		# filter type 
        SYMBOL_FILTER = gr.fir_filter_fff (symbol_decim, symbol_coeffs)
        AMP = gr.multiply_const_ff(options.factor)
        msgq = gr.msg_queue(2)
        FSK4 = op25.fsk4_demod_ff(msgq, sample_rate, symbol_rate)
        levels = levels = [-2.0, 0.0, 2.0, 4.0]
        SLICER = repeater.fsk4_slicer_fb(levels)
        framer_msgq = gr.msg_queue(2)
        DECODE = repeater.p25_frame_assembler('',	# udp hostname
                                              0,	# udp port no.
                                              options.verbose,	#debug
                                              True,	# do_imbe
                                              True,	# do_output
                                              False,	# do_msgq
                                              framer_msgq)
        IMBE = repeater.vocoder(False,                 # 0=Decode,True=Encode
                                  options.verbose,      # Verbose flag
                                  options.stretch,      # flex amount
                                  "",                   # udp ip address
                                  0,                    # udp port
                                  False)                # dump raw u vectors

        CVT = gr.short_to_float()
        if options.do_interp:
            interp_taps = gr.firdes.low_pass(1.0, 48000, 4000, 4000 * 0.1, gr.firdes.WIN_HANN)
            INTERP = gr.interp_fir_filter_fff(48000 // 8000, interp_taps)
        AMP2 = gr.multiply_const_ff(1.0 / 32767.0)

        self.connect(IN, AMP, SYMBOL_FILTER, FSK4, SLICER, DECODE, IMBE, CVT, AMP2)
        if options.do_interp:
            self.connect(AMP2, INTERP, OUT)
        else:
            self.connect(AMP2, OUT)
Exemple #12
0
    def __init__(self):
        gr.top_block.__init__(self)

        parser = OptionParser(option_class=eng_option)
        parser.add_option("-O", "--audio-output", type="string", default="",
                          help="pcm output device name")
        parser.add_option("-r", "--sample-rate", type="eng_float", default=192000,
                          help="set sample rate to RATE (192000)")
        parser.add_option("-f", "--frequency", type="eng_float", default=1000)
        parser.add_option("-a", "--amplitude", type="eng_float", default=0.5)

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

        sample_rate = int(options.sample_rate)
        ampl = float(options.amplitude)
        pulse_freq = 1.0 # 1Hz
        pulse_dc = 0.1 # Low DC value to give high/low value rather than on/off
        if ampl > 1.0: ampl = 1.0

        osc = gr.sig_source_f (sample_rate, gr.GR_SIN_WAVE, options.frequency, ampl)
        pulse =  gr.sig_source_f (sample_rate, gr.GR_SQR_WAVE, pulse_freq, .8, pulse_dc)
        mixer = gr.multiply_ff ()
        self.connect (osc, (mixer, 0))
        self.connect (pulse, (mixer, 1))
        dst = audio.sink (sample_rate, options.audio_output, True)
        self.connect (mixer, dst)
Exemple #13
0
    def __init__(self):
        gr.top_block.__init__(self, "Top Block")

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 80000

        ##################################################
        # Blocks
        ##################################################
        self.test1_dds_fpga_0 = test1.dds_fpga(8192*2, "/dev/iqram")
	
	self.fir_filter_xxx_0 = filter.rational_resampler_ccc(
	        interpolation=1, decimation=1, taps=None,
	       fractional_bw = None,
        )

        self.audio_sink_0 = audio.sink(samp_rate/5, "", True)
        self.analog_wfm_rcv_0 = analog.wfm_rcv(
        	quad_rate=samp_rate,
        	audio_decimation=5
        )
        #self.analog_wfm_rcv_0.set_max_output_buffer(4096)

        ##################################################
        # Connections
        ##################################################
        #self.connect((self.test1_dds_fpga_0, 0), (self.analog_wfm_rcv_0, 0))
        #self.connect((self.analog_wfm_rcv_0, 0), (self.audio_sink_0, 0))
        self.connect((self.test1_dds_fpga_0, 0), (self.fir_filter_xxx_0, 0))
        self.connect((self.fir_filter_xxx_0, 0), (self.analog_wfm_rcv_0, 0))
        self.connect((self.analog_wfm_rcv_0, 0), (self.audio_sink_0, 0))
Exemple #14
0
    def __init__(self):
        gr.top_block.__init__(self)

        parser = OptionParser(option_class=eng_option)
        parser.add_option("-O", "--audio-output", type="string", default="",
                          help="pcm output device name.  E.g., hw:0,0 or /dev/dsp")
        parser.add_option("-r", "--sample-rate", type="eng_float", default=48000,
                          help="set sample rate to RATE (48000)")
        parser.add_option("-D", "--dont-block", action="store_false", default=True,
                          dest="ok_to_block")

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

        sample_rate = int(options.sample_rate)
        ampl = 0.1

        src0 = analog.sig_source_f(sample_rate, analog.GR_SIN_WAVE, 650, ampl)

        dst = audio.sink(sample_rate,
                         options.audio_output,
                         options.ok_to_block)

        self.connect (src0, (dst, 0))
Exemple #15
0
    def __init__(self):
        gr.top_block.__init__(self)

        parser = OptionParser(option_class=eng_option)
        parser.add_option("-I", "--audio-input", type="string", default="",
                          help="pcm input device name.  E.g., hw:0,0 or /dev/dsp")
        parser.add_option("-O", "--audio-output", type="string", default="",
                          help="pcm output device name")
        parser.add_option("-r", "--sample-rate", type="eng_float", default=192000,
                          help="set sample rate to RATE (192000)")
        parser.add_option("-f", "--frequency", type="eng_float", default=45000)
        parser.add_option("-a", "--amplitude", type="eng_float", default=0.5)

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

        sample_rate = int(options.sample_rate)
        ampl = float(options.amplitude)
        if ampl > 1.0: ampl = 1.0

        to_real = blocks.complex_to_real()
        to_imag = blocks.complex_to_imag()

        src = audio.source (sample_rate, options.audio_input)
        firdes_taps = filter.firdes.low_pass_2(1, 1, 0.2, 0.1, 60)
        converter = filter.freq_xlating_fir_filter_fcf ( 1, firdes_taps, 0, sample_rate )
        converter.set_center_freq(0 - options.frequency)
        dst = audio.sink (sample_rate, options.audio_output, True)

        #self.connect(src, converter, to_real, dst)
        self.connect(src, converter)
        self.connect(converter, to_real, (dst,0))
        self.connect(converter, to_imag, (dst,1))
    def __init__(self):
        gr.top_block.__init__(self)

        parser = OptionParser(option_class=eng_option)
        parser.add_option("-I", "--audio-input", type="string", default="",
                          help="pcm input device name.  E.g., hw:0,0 or /dev/dsp")
        parser.add_option("-O", "--audio-output", type="string", default="",
                          help="pcm output device name.  E.g., hw:0,0 or /dev/dsp")
        parser.add_option("-r", "--sample-rate", type="eng_float", default=48000,
                          help="set sample rate to RATE (48000)")
        (options, args) = parser.parse_args ()
        if len(args) != 0:
            parser.print_help()
            raise SystemExit, 1

        sample_rate = int(options.sample_rate)
        src = audio.source (sample_rate, options.audio_input)
        dst = audio.sink (sample_rate, options.audio_output)

        # Determine the maximum number of outputs on the source and
        # maximum number of inputs on the sink, then connect together
        # the most channels we can without overlap
        nchan = min (src.output_signature().max_streams(),
                     dst.input_signature().max_streams())

        for i in range (nchan):
            self.connect ((src, i), (dst, i))
Exemple #17
0
  def __init__(self, carrier=8000, samp_rate=192000, amp=0.1):
    gr.top_block.__init__(self, "Top Block")

    analog_sig_source_x_0 = analog.sig_source_f(samp_rate, analog.GR_COS_WAVE, carrier, amp, 0)
    audio_sink_0 = audio.sink(samp_rate, "")

    self.connect((analog_sig_source_x_0, 0), (audio_sink_0, 0))
Exemple #18
0
    def __init__(self):
        gr.top_block.__init__(self)

        parser = OptionParser(option_class=eng_option)
        parser.add_option("-O", "--audio-output",
			  type="string",
			  default="",
                          help="audio output device name. E.g., hw:0,0 or /dev/dsp")
        parser.add_option("-I", "--audio-input",
			  type="string",
			  default="",
                          help="audio input device name.  E.g., hw:0,0 or /dev/dsp")
        parser.add_option("-r", "--sample-rate",
			  type="eng_float",
			  default=48000,
                          help="set sample rate to RATE (48000)")
        (options, args) = parser.parse_args ()
        if len(args) != 0:
            parser.print_help()
            raise SystemExit, 1

        sample_rate = int(options.sample_rate)
        src = audio.source (sample_rate, options.audio_output)
        dst = audio.sink (sample_rate, options.audio_output)

        max_chan = max (src.output_signature().max_streams(),
			dst.output_signature().max_streams())

	for i in range (max_chan):
		self.connect ((src, i), (dst, i))
Exemple #19
0
    def __init__(self):
        gr.top_block.__init__(self, "Acoust Out")

        ##################################################
        # Variables
        ##################################################
        self.transistion = transistion = 100
        self.sps = sps = 2
        self.sideband_rx = sideband_rx = 1000
        self.sideband = sideband = 1000
        self.samp_rate = samp_rate = 48000
        self.payload = payload = 20
        self.interpolation = interpolation = 200
        self.fd = fd = 0
        self.carrier = carrier = 13000

        ##################################################
        # Blocks
        ##################################################
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
                interpolation=interpolation,
                decimation=1,
                taps=None,
                fractional_bw=None,
        )
        self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(1, (firdes.band_pass (0.50,samp_rate,carrier-sideband,carrier+sideband,transistion)), -carrier, samp_rate)
        self.digital_gfsk_mod_0 = digital.gfsk_mod(
        	samples_per_symbol=sps,
        	sensitivity=1.0,
        	bt=0.35,
        	verbose=False,
        	log=False,
        )
        self.blocks_complex_to_real_0 = blocks.complex_to_real(1)
        self.blks2_tcp_source_0 = grc_blks2.tcp_source(
        	itemsize=gr.sizeof_char*1,
        	addr="127.0.0.1",
        	port=9000,
        	server=True,
        )
        self.blks2_packet_encoder_0 = grc_blks2.packet_mod_b(grc_blks2.packet_encoder(
        		samples_per_symbol=sps,
        		bits_per_symbol=1,
        		preamble="",
        		access_code="",
        		pad_for_usrp=False,
        	),
        	payload_length=payload,
        )
        self.audio_sink_0 = audio.sink(48000, "", True)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_complex_to_real_0, 0), (self.audio_sink_0, 0))
        self.connect((self.digital_gfsk_mod_0, 0), (self.rational_resampler_xxx_0, 0))
        self.connect((self.blks2_packet_encoder_0, 0), (self.digital_gfsk_mod_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.blocks_complex_to_real_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0))
        self.connect((self.blks2_tcp_source_0, 0), (self.blks2_packet_encoder_0, 0))
Exemple #20
0
    def __init__(self):
        gr.top_block.__init__(self, "P25 Wav Decode")

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

        ##################################################
        # Blocks
        ##################################################
        self.rational_resampler_xxx_0 = filter.rational_resampler_fff(
                interpolation=48000,
                decimation=8000,
                taps=None,
                fractional_bw=None,
        )
        self.dsd_block_ff_0 = dsd.block_ff(dsd.dsd_FRAME_AUTO_DETECT,dsd.dsd_MOD_AUTO_SELECT,3,True,2)
        self.blocks_wavfile_source_0 = blocks.wavfile_source("p25_raw_unencrypted_edf.wav", True)
        self.audio_sink_0 = audio.sink(48000, "", True)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_wavfile_source_0, 0), (self.dsd_block_ff_0, 0))    
        self.connect((self.dsd_block_ff_0, 0), (self.rational_resampler_xxx_0, 0))    
        self.connect((self.rational_resampler_xxx_0, 0), (self.audio_sink_0, 0))    
Exemple #21
0
	def __init__(self):
		gr.top_block.__init__(self)
		
		# standard quality sample rate and amplitude value
		sample_rate = 32000
		ampl = 0.1
		startFreq0 = 350
		startFreq1 = 440
		# We create two sine waves with the same amplitude and sameple rate
		# from above.

		src0 = analog.sig_source_f(sample_rate, analog.GR_SIN_WAVE, startFreq0, ampl)
		src1 = analog.sig_source_f(sample_rate, analog.GR_SIN_WAVE, startFreq1, ampl)
		
		# dst is the "destination" or audio sink block
		dst = audio.sink(sample_rate, "")

		# We then connect the two sine waves to the destination block
		self.connect(src0, (dst, 0))
		self.connect(src1, (dst, 1))
		
		for a in range(1000):
			src0.set_frequency(startFreq0 + a)
			src1.set_frequency(startFreq1 + a)
			time.sleep(0.5)
Exemple #22
0
    def __init__(self):
        gr.top_block.__init__(self)

        parser = OptionParser(option_class=eng_option)
        parser.add_option("-I", "--audio-input", type="string", default="",
                          help="pcm input device name.  E.g., hw:0,0 or /dev/dsp")
        parser.add_option("-O", "--audio-output", type="string", default="",
                          help="pcm output device name")
        parser.add_option("-r", "--sample-rate", type="eng_float", default=192000,
                          help="set sample rate to RATE (192000)")
        parser.add_option("-f", "--frequency", type="eng_float", default=45000)
        parser.add_option("-a", "--amplitude", type="eng_float", default=0.5)

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

        sample_rate = int(options.sample_rate)
        ampl = float(options.amplitude)
        if ampl > 1.0: ampl = 1.0

       # osc = analog.sig_source_f (sample_rate, analog.GR_SIN_WAVE, options.frequency, ampl)
        src = audio.source (sample_rate, options.audio_input)
       # mixer = blocks.multiply_ff ()
       # self.connect (osc, (mixer, 0))
       # self.connect (src, (mixer, 1))
        dst = audio.sink (sample_rate, options.audio_output, True)
        self.connect (src, dst)
Exemple #23
0
    def __init__(self):
        gr.top_block.__init__(self)

        parser = ArgumentParser()
        parser.add_argument("-O", "--audio-output", default="",
                          help="pcm output device name.  E.g., hw:0,0 or /dev/dsp")
        parser.add_argument("-i", "--input-rate", type=eng_float, default=8000,
                          help="set input sample rate to RATE %(default)r")
        parser.add_argument("-o", "--output-rate", type=eng_float, default=48000,
                          help="set output sample rate to RATE %(default)r")
        args = parser.parse_args()
        input_rate = int(args.input_rate)
        output_rate = int(args.output_rate)

        interp = gru.lcm(input_rate / output_rate, input_rate)
        decim = gru.lcm(input_rate / output_rate, output_rate)

        print("interp =", interp)
        print("decim  =", decim)

        ampl = 0.1
        src0 = analog.sig_source_f(input_rate, analog.GR_SIN_WAVE, 650, ampl)
        rr = filter.rational_resampler_fff(interp, decim)
        dst = audio.sink(output_rate, args.audio_output)
        self.connect(src0, rr, (dst, 0))
Exemple #24
0
def main():
    parser = OptionParser(option_class=eng_option)
    parser.add_option("-I", "--audio-input", type="string", default="",
                      help="pcm input device name.  E.g., hw:0,0 or /dev/dsp")
    parser.add_option("-O", "--audio-output", type="string", default="",
                      help="pcm output device name.  E.g., hw:0,0 or /dev/dsp")
    parser.add_option("-r", "--sample-rate", type="eng_float", default="32000",
                      help="Audio sampling rate [defaul=%default]")
    parser.add_option("-S", "--resample-rate", type="int", default="8",
                      help="Resampling rate in CVSD [default=%default]")
    (options, args) = parser.parse_args ()

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

    tb = gr.top_block()

    src = audio.source(int(options.sample_rate), options.audio_input)
    tx = blks2.cvsd_encode(options.resample_rate)

    # todo: add noise

    rx = blks2.cvsd_decode(options.resample_rate)
    dst = audio.sink(int(options.sample_rate), options.audio_output)
    
    tb.connect(src, tx, rx, dst)    
    tb.run()
Exemple #25
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Receptor")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 44100
        self.fcdemod = fcdemod = 0
        self.fc = fc = 0

        ##################################################
        # Blocks
        ##################################################
        self.uhd_usrp_source_0 = uhd.usrp_source(
        	device_addr="",
        	stream_args=uhd.stream_args(
        		cpu_format="fc32",
        		channels=range(1),
        	),
        )
        self.uhd_usrp_source_0.set_clock_source("gpsdo", 0)
        self.uhd_usrp_source_0.set_samp_rate(samp_rate)
        self.uhd_usrp_source_0.set_center_freq(fc, 0)
        self.uhd_usrp_source_0.set_gain(0, 0)
        self.digital_psk_demod_0 = digital.psk.psk_demod(
          constellation_points=4,
          differential=True,
          samples_per_symbol=2,
          excess_bw=0.35,
          phase_bw=6.28/100.0,
          timing_bw=6.28/100.0,
          mod_code="gray",
          verbose=False,
          log=False,
          )
        self.blocks_multiply_xx_0_0 = blocks.multiply_vcc(1)
        self.blocks_multiply_const_vxx_0_0_0 = blocks.multiply_const_vff((0.007874016, ))
        self.blocks_char_to_float_1 = blocks.char_to_float(1, 1)
        self.blks2_packet_decoder_0 = grc_blks2.packet_demod_b(grc_blks2.packet_decoder(
        		access_code="",
        		threshold=-1,
        		callback=lambda ok, payload: self.blks2_packet_decoder_0.recv_pkt(ok, payload),
        	),
        )
        self.audio_sink_0 = audio.sink(samp_rate, "", True)
        self.analog_sig_source_x_0_0_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, fcdemod, 1, 0)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.digital_psk_demod_0, 0), (self.blks2_packet_decoder_0, 0))
        self.connect((self.blocks_multiply_xx_0_0, 0), (self.digital_psk_demod_0, 0))
        self.connect((self.analog_sig_source_x_0_0_0, 0), (self.blocks_multiply_xx_0_0, 1))
        self.connect((self.blocks_char_to_float_1, 0), (self.blocks_multiply_const_vxx_0_0_0, 0))
        self.connect((self.blks2_packet_decoder_0, 0), (self.blocks_char_to_float_1, 0))
        self.connect((self.uhd_usrp_source_0, 0), (self.blocks_multiply_xx_0_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0_0_0, 0), (self.audio_sink_0, 0))
Exemple #26
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Lab 3")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = int(48e3)
        self.freq = freq = 1e3

        ##################################################
        # Blocks
        ##################################################
        _freq_sizer = wx.BoxSizer(wx.VERTICAL)
        self._freq_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_freq_sizer,
        	value=self.freq,
        	callback=self.set_freq,
        	label="Frequency",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._freq_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_freq_sizer,
        	value=self.freq,
        	callback=self.set_freq,
        	minimum=0,
        	maximum=16e3,
        	num_steps=1000,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.Add(_freq_sizer)
        self.wxgui_scopesink2_0 = scopesink2.scope_sink_f(
        	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,
        	trig_mode=wxgui.TRIG_MODE_AUTO,
        	y_axis_label="Counts",
        )
        self.Add(self.wxgui_scopesink2_0.win)
        self.audio_sink_0 = audio.sink(samp_rate, "", True)
        self.analog_sig_source_x_0 = analog.sig_source_f(samp_rate, analog.GR_COS_WAVE, freq, 0.7, 0)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_sig_source_x_0, 0), (self.audio_sink_0, 0))    
        self.connect((self.analog_sig_source_x_0, 0), (self.wxgui_scopesink2_0, 0))    
Exemple #27
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Top Block")

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 125e6

        ##################################################
        # Blocks
        ##################################################
        self.wxgui_waterfallsink2_0 = waterfallsink2.waterfall_sink_c(
        	self.GetWin(),
        	baseband_freq=500e6,
        	dynamic_range=40,
        	ref_level=0,
        	ref_scale=2.0,
        	sample_rate=samp_rate,
        	fft_size=512,
        	fft_rate=15,
        	average=False,
        	avg_alpha=None,
        	title="Waterfall Plot",
        )
        self.Add(self.wxgui_waterfallsink2_0.win)
        self.rational_resampler_xxx_0_0 = filter.rational_resampler_ccc(
                interpolation=3,
                decimation=125,
                taps=None,
                fractional_bw=None,
        )
        self.rational_resampler_xxx_0 = filter.rational_resampler_fff(
                interpolation=48,
                decimation=30,
                taps=None,
                fractional_bw=None,
        )
        self.low_pass_filter_0 = filter.fir_filter_ccf(10, firdes.low_pass(
        	1, 3e6, 5e3, 8e3, firdes.WIN_HAMMING, 6.76))
        self.blocks_interleaved_short_to_complex_0 = blocks.interleaved_short_to_complex(False, False)
        self.blocks_file_source_0 = blocks.file_source(gr.sizeof_short*1, "/dev/langford", True)
        self.audio_sink_0 = audio.sink(48000, "", True)
        self.analog_nbfm_rx_0 = analog.nbfm_rx(
        	audio_rate=30000,
        	quad_rate=300000,
        	tau=75e-6,
        	max_dev=5e3,
        )

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_file_source_0, 0), (self.blocks_interleaved_short_to_complex_0, 0))
        self.connect((self.low_pass_filter_0, 0), (self.analog_nbfm_rx_0, 0))
        self.connect((self.analog_nbfm_rx_0, 0), (self.rational_resampler_xxx_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0), (self.audio_sink_0, 0))
        self.connect((self.blocks_interleaved_short_to_complex_0, 0), (self.wxgui_waterfallsink2_0, 0))
        self.connect((self.blocks_interleaved_short_to_complex_0, 0), (self.rational_resampler_xxx_0_0, 0))
        self.connect((self.rational_resampler_xxx_0_0, 0), (self.low_pass_filter_0, 0))
Exemple #28
0
    def __init__(self,
                 dest           = _def_dest,
                 do_imbe	= _def_do_imbe,
                 num_ambe	= _def_num_ambe,
                 wireshark_host	= _def_wireshark_host,
                 udp_port	= _def_udp_port,
                 do_msgq	= False,
                 msgq		= None,
                 audio_output	= _def_audio_output,
                 debug		= _def_debug):
        """
	Hierarchical block for P25 decoding.

        @param debug: debug level
        @type debug: int
	"""

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

        assert 0 <= num_ambe <= _def_max_tdma_timeslots
        assert not (num_ambe > 1 and dest != 'wav')

        self.debug = debug
        self.dest = dest
        do_output = 1
        do_audio_output = True

        if msgq is None:
            msgq = gr.msg_queue(1)

        self.p25_decoders = []
        self.audio_s2f = []
        self.scaler = []
        self.audio_sink = []
        self.xorhash = []
        num_decoders = 1
        if num_ambe > 1:
           num_decoders += num_ambe - 1
        for slot in xrange(num_decoders):
            self.p25_decoders.append(op25_repeater.p25_frame_assembler(wireshark_host, udp_port, debug, do_imbe, do_output, do_msgq, msgq, do_audio_output, True))
            self.p25_decoders[slot].set_slotid(slot)

            self.audio_s2f.append(blocks.short_to_float()) # another ridiculous conversion
            self.scaler.append(blocks.multiply_const_ff(1 / 32768.0))
            self.xorhash.append('')

            if dest == 'wav':
                filename = 'default-%f-%d.wav' % (time.time(), slot)
                n_channels = 1
                sample_rate = 8000
                bits_per_sample = 16
                self.audio_sink.append(blocks.wavfile_sink(filename, n_channels, sample_rate, bits_per_sample))
            elif dest == 'audio':
                self.audio_sink.append(audio.sink(_def_audio_rate, audio_output, True))

            self.connect(self, self.p25_decoders[slot], self.audio_s2f[slot], self.scaler[slot], self.audio_sink[slot])
Exemple #29
0
 def __init__(self):
   gr.top_block.__init__(self)
   sample_rate = 32000
   ampl = 0.1
   src0 = analog.sig_source_f(sample_rate, analog.GR_SIN_WAVE, 350, ampl)
   src1 = analog.sig_source_f(sample_rate, analog.GR_SIN_WAVE, 440, ampl)
   dst = audio.sink (sample_rate, "")
   self.connect (src0, (dst, 0))
   self.connect (src1, (dst, 1))
  def __init__( self, sample_rate, default_signal ):

    self.sample_rate = sample_rate

    try:
      self.sink = audio.sink( self.sample_rate )
    except Exception, ex:
      print repr(ex)
      raise RuntimeError,"Could not access audio device"
Exemple #31
0
    def __init__(self):
        gr.top_block.__init__(self, "Top Block")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Top Block")
        qtgui.util.check_set_qss()
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

        self.settings = Qt.QSettings("GNU Radio", "top_block")

        if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"):
            self.restoreGeometry(self.settings.value("geometry").toByteArray())
        else:
            self.restoreGeometry(
                self.settings.value("geometry", type=QtCore.QByteArray))

        ##################################################
        # Variables
        ##################################################
        self.sps = sps = 45
        self.nfilts = nfilts = 25
        self.samp_rate = samp_rate = 44.1E3
        self.rrc_taps = rrc_taps = firdes.root_raised_cosine(
            nfilts, nfilts, 1.0 / float(sps), 0.35, 45 * nfilts)
        self.fc_slider = fc_slider = 2200

        self.BPSK = BPSK = digital.constellation_bpsk().base()

        ##################################################
        # Blocks
        ##################################################
        self._fc_slider_range = Range(0, 18200, 200, 2200, 150)
        self._fc_slider_win = RangeWidget(self._fc_slider_range,
                                          self.set_fc_slider, 'fc',
                                          "counter_slider", float)
        self.top_layout.addWidget(self._fc_slider_win)
        self.qtgui_time_sink_x_0_1 = qtgui.time_sink_f(
            1024,  #size
            100000000,  #samp_rate
            'Sinal BPKS real',  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_0_1.set_update_time(0.10)
        self.qtgui_time_sink_x_0_1.set_y_axis(-1, 1)

        self.qtgui_time_sink_x_0_1.set_y_label('Amplitude', "")

        self.qtgui_time_sink_x_0_1.enable_tags(-1, True)
        self.qtgui_time_sink_x_0_1.set_trigger_mode(qtgui.TRIG_MODE_FREE,
                                                    qtgui.TRIG_SLOPE_POS, 0.0,
                                                    0, 0, "")
        self.qtgui_time_sink_x_0_1.enable_autoscale(False)
        self.qtgui_time_sink_x_0_1.enable_grid(False)
        self.qtgui_time_sink_x_0_1.enable_axis_labels(True)
        self.qtgui_time_sink_x_0_1.enable_control_panel(False)
        self.qtgui_time_sink_x_0_1.enable_stem_plot(False)

        if not True:
            self.qtgui_time_sink_x_0_1.disable_legend()

        labels = ['', '', '', '', '', '', '', '', '', '']
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "green", "black", "cyan", "magenta", "yellow",
            "dark red", "dark green", "blue"
        ]
        styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]

        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_time_sink_x_0_1.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_0_1.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_0_1.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_0_1.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_0_1.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_0_1.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_0_1.set_line_alpha(i, alphas[i])

        self._qtgui_time_sink_x_0_1_win = sip.wrapinstance(
            self.qtgui_time_sink_x_0_1.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_time_sink_x_0_1_win)
        self.qtgui_time_sink_x_0 = qtgui.time_sink_f(
            1024,  #size
            samp_rate,  #samp_rate
            'Sinal modulado AM',  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0.set_y_axis(-1, 1)

        self.qtgui_time_sink_x_0.set_y_label('Amplitude', "")

        self.qtgui_time_sink_x_0.enable_tags(-1, True)
        self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE,
                                                  qtgui.TRIG_SLOPE_POS, 0.0, 0,
                                                  0, "")
        self.qtgui_time_sink_x_0.enable_autoscale(False)
        self.qtgui_time_sink_x_0.enable_grid(False)
        self.qtgui_time_sink_x_0.enable_axis_labels(True)
        self.qtgui_time_sink_x_0.enable_control_panel(False)
        self.qtgui_time_sink_x_0.enable_stem_plot(False)

        if not True:
            self.qtgui_time_sink_x_0.disable_legend()

        labels = ['', '', '', '', '', '', '', '', '', '']
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "green", "black", "cyan", "magenta", "yellow",
            "dark red", "dark green", "blue"
        ]
        styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]

        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_time_sink_x_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_0.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_0.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i])

        self._qtgui_time_sink_x_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_time_sink_x_0_win)
        self.digital_constellation_modulator_0 = digital.generic_mod(
            constellation=BPSK,
            differential=True,
            samples_per_symbol=sps,
            pre_diff_code=True,
            excess_bw=0.25,
            verbose=True,
            log=False,
        )
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_complex_to_real_1_0 = blocks.complex_to_real(1)
        self.blocks_complex_to_real_1 = blocks.complex_to_real(1)
        self.blks2_tcp_source_0 = grc_blks2.tcp_source(
            itemsize=gr.sizeof_char * 1,
            addr='127.0.0.1',
            port=5000,
            server=True,
        )
        self.blks2_packet_encoder_0 = grc_blks2.packet_mod_b(
            grc_blks2.packet_encoder(
                samples_per_symbol=1,
                bits_per_symbol=1,
                preamble='',
                access_code='',
                pad_for_usrp=False,
            ),
            payload_length=1,
        )
        self.audio_sink_0 = audio.sink(44100, '', True)
        self.analog_sig_source_x_0 = analog.sig_source_c(
            samp_rate, analog.GR_COS_WAVE, fc_slider, 1, 0)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_sig_source_x_0, 0),
                     (self.blocks_multiply_xx_0, 1))
        self.connect((self.blks2_packet_encoder_0, 0),
                     (self.digital_constellation_modulator_0, 0))
        self.connect((self.blks2_tcp_source_0, 0),
                     (self.blks2_packet_encoder_0, 0))
        self.connect((self.blocks_complex_to_real_1, 0),
                     (self.audio_sink_0, 0))
        self.connect((self.blocks_complex_to_real_1, 0),
                     (self.qtgui_time_sink_x_0, 0))
        self.connect((self.blocks_complex_to_real_1_0, 0),
                     (self.qtgui_time_sink_x_0_1, 0))
        self.connect((self.blocks_multiply_xx_0, 0),
                     (self.blocks_complex_to_real_1, 0))
        self.connect((self.digital_constellation_modulator_0, 0),
                     (self.blocks_complex_to_real_1_0, 0))
        self.connect((self.digital_constellation_modulator_0, 0),
                     (self.blocks_multiply_xx_0, 0))
Exemple #32
0
    def __init__(self):
        gr.top_block.__init__(self, "Top Block")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Top Block")
        qtgui.util.check_set_qss()
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

        self.settings = Qt.QSettings("GNU Radio", "top_block")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 250000
        self.gain = gain = 40
        self.audio_rate = audio_rate = 48000
        self.audio_interp = audio_interp = 4

        ##################################################
        # Blocks
        ##################################################
        self.uhd_usrp_source_0 = uhd.usrp_source(
            ",".join(("", "")),
            uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ),
        )
        self.uhd_usrp_source_0.set_samp_rate(samp_rate)
        self.uhd_usrp_source_0.set_center_freq(0, 0)
        self.uhd_usrp_source_0.set_gain(0, 0)
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
            interpolation=1,
            decimation=1,
            taps=None,
            fractional_bw=None,
        )
        self.qtgui_sink_x_0 = qtgui.sink_c(
            1024,  #fftsize
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate,  #bw
            "",  #name
            True,  #plotfreq
            True,  #plotwaterfall
            True,  #plottime
            True,  #plotconst
        )
        self.qtgui_sink_x_0.set_update_time(1.0 / 10)
        self._qtgui_sink_x_0_win = sip.wrapinstance(
            self.qtgui_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_sink_x_0_win)

        self.qtgui_sink_x_0.enable_rf_freq(False)

        self._gain_range = Range(0, 74, 1, 40, 200)
        self._gain_win = RangeWidget(self._gain_range, self.set_gain, 'gain',
                                     "counter_slider", float)
        self.top_grid_layout.addWidget(self._gain_win)
        self.audio_sink_0 = audio.sink(samp_rate, '', True)
        self.analog_wfm_rcv_0 = analog.wfm_rcv(
            quad_rate=192000,
            audio_decimation=4,
        )

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_wfm_rcv_0, 0), (self.audio_sink_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.analog_wfm_rcv_0, 0))
        self.connect((self.uhd_usrp_source_0, 0), (self.qtgui_sink_x_0, 0))
        self.connect((self.uhd_usrp_source_0, 0),
                     (self.rational_resampler_xxx_0, 0))
Exemple #33
0
    def __init__(self, frame, panel, vbox, argv):
        stdgui2.std_top_block.__init__(self, frame, panel, vbox, argv)

        parser = OptionParser(option_class=eng_option)
        parser.add_option("-a",
                          "--args",
                          type="string",
                          default="",
                          help="UHD device address args [default=%default]")
        parser.add_option("",
                          "--spec",
                          type="string",
                          default=None,
                          help="Subdevice of UHD device where appropriate")
        parser.add_option("-A",
                          "--antenna",
                          type="string",
                          default=None,
                          help="select Rx Antenna where appropriate")
        parser.add_option(
            "-s",
            "--samp-rate",
            type="eng_float",
            default=1e6,
            help="set sample rate (bandwidth) [default=%default]")
        parser.add_option("-f",
                          "--freq",
                          type="eng_float",
                          default=1008.0e3,
                          help="set frequency to FREQ",
                          metavar="FREQ")
        parser.add_option(
            "-I",
            "--use-if-freq",
            action="store_true",
            default=False,
            help=
            "use intermediate freq (compensates DC problems in quadrature boards)"
        )
        parser.add_option("-g",
                          "--gain",
                          type="eng_float",
                          default=None,
                          help="set gain in dB (default is maximum)")
        parser.add_option("-V",
                          "--volume",
                          type="eng_float",
                          default=None,
                          help="set volume (default is midpoint)")
        parser.add_option(
            "-O",
            "--audio-output",
            type="string",
            default="",
            help="pcm device name.  E.g., hw:0,0 or surround51 or /dev/dsp")

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

        self.frame = frame
        self.panel = panel
        self.use_IF = options.use_if_freq
        if self.use_IF:
            self.IF_freq = 64000.0
        else:
            self.IF_freq = 0.0

        self.vol = 0
        self.state = "FREQ"
        self.freq = 0

        # build graph
        self.u = uhd.usrp_source(device_addr=options.args,
                                 stream_args=uhd.stream_args('fc32'))

        # Set the subdevice spec
        if (options.spec):
            self.u.set_subdev_spec(options.spec, 0)

        # Set the antenna
        if (options.antenna):
            self.u.set_antenna(options.antenna, 0)

        usrp_rate = 256e3
        demod_rate = 64e3
        audio_rate = 32e3
        chanfilt_decim = int(usrp_rate // demod_rate)
        audio_decim = int(demod_rate // audio_rate)

        self.u.set_samp_rate(usrp_rate)
        dev_rate = self.u.get_samp_rate()

        # Resample signal to exactly self.usrp_rate
        # FIXME: make one of the follow-on filters an arb resampler
        rrate = usrp_rate / dev_rate
        self.resamp = blks2.pfb_arb_resampler_ccf(rrate)

        chan_filt_coeffs = gr.firdes.low_pass_2(
            1,  # gain
            usrp_rate,  # sampling rate
            8e3,  # passband cutoff
            4e3,  # transition bw
            60)  # stopband attenuation

        if self.use_IF:
            # Turn If to baseband and filter.
            self.chan_filt = gr.freq_xlating_fir_filter_ccf(
                chanfilt_decim, chan_filt_coeffs, self.IF_freq, usrp_rate)
        else:
            self.chan_filt = gr.fir_filter_ccf(chanfilt_decim,
                                               chan_filt_coeffs)

        self.agc = gr.agc_cc(0.1, 1, 1, 100000)
        self.am_demod = gr.complex_to_mag()
        self.volume_control = gr.multiply_const_ff(self.vol)

        audio_filt_coeffs = gr.firdes.low_pass_2(
            1,  # gain
            demod_rate,  # sampling rate
            8e3,  # passband cutoff
            2e3,  # transition bw
            60)  # stopband attenuation
        self.audio_filt = gr.fir_filter_fff(audio_decim, audio_filt_coeffs)

        # sound card as final sink
        self.audio_sink = audio.sink(int(audio_rate), options.audio_output,
                                     False)  # ok_to_block

        # now wire it all together
        self.connect(self.u, self.resamp, self.chan_filt, self.agc,
                     self.am_demod, self.audio_filt, self.volume_control,
                     self.audio_sink)

        self._build_gui(vbox, usrp_rate, demod_rate, audio_rate)

        if options.gain is None:
            g = self.u.get_gain_range()
            if True:
                # if no gain was specified, use the mid gain
                options.gain = (g.start() + g.stop()) / 2.0
                options.gain = g.stop()

        if options.volume is None:
            v = self.volume_range()
            options.volume = float(v[0] * 3 + v[1]) / 4.0

        if abs(options.freq) < 1e3:
            options.freq *= 1e3

        # set initial values

        self.set_gain(options.gain)
        self.set_vol(options.volume)
        if not (self.set_freq(options.freq)):
            self._set_status_msg("Failed to set initial frequency")
Exemple #34
0
    def __init__(self):
        gr.top_block.__init__(self, "Top Block")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Top Block")
        qtgui.util.check_set_qss()
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

        self.settings = Qt.QSettings("GNU Radio", "top_block")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.center_sdr_hardware_f = center_sdr_hardware_f = 99e6
        self.sdr_hardware_f_slider = sdr_hardware_f_slider = center_sdr_hardware_f
        self.low_pass_filter_cutoff_f = low_pass_filter_cutoff_f = 70e3
        self.if_slider = if_slider = -1.50e6
        self.volume_slider = volume_slider = 0.6
        self.squelch_slider = squelch_slider = -60
        self.samp_rate = samp_rate = 4.8e6
        self.low_pass_trans_width_slider = low_pass_trans_width_slider = 20e3
        self.low_pass_filter_cutoff_f_slider = low_pass_filter_cutoff_f_slider = low_pass_filter_cutoff_f
        self.curr_f_label = curr_f_label = sdr_hardware_f_slider - if_slider

        ##################################################
        # Blocks
        ##################################################
        self._volume_slider_range = Range(0.2, 3, 0.2, 0.6, 200)
        self._volume_slider_win = RangeWidget(self._volume_slider_range,
                                              self.set_volume_slider, 'Volume',
                                              "counter_slider", float)
        self.top_grid_layout.addWidget(self._volume_slider_win)
        self._squelch_slider_range = Range(-80, -30, 5, -60, 200)
        self._squelch_slider_win = RangeWidget(self._squelch_slider_range,
                                               self.set_squelch_slider,
                                               'Squelch', "counter_slider",
                                               float)
        self.top_grid_layout.addWidget(self._squelch_slider_win)
        self._sdr_hardware_f_slider_range = Range(93e6, 106e6, 50e3,
                                                  center_sdr_hardware_f, 200)
        self._sdr_hardware_f_slider_win = RangeWidget(
            self._sdr_hardware_f_slider_range, self.set_sdr_hardware_f_slider,
            'SDR frequency', "counter_slider", float)
        self.top_grid_layout.addWidget(self._sdr_hardware_f_slider_win)
        self._low_pass_trans_width_slider_range = Range(
            5e3, 50e3, 5e3, 20e3, 200)
        self._low_pass_trans_width_slider_win = RangeWidget(
            self._low_pass_trans_width_slider_range,
            self.set_low_pass_trans_width_slider, 'Filter trans width fr',
            "counter_slider", float)
        self.top_grid_layout.addWidget(self._low_pass_trans_width_slider_win)
        self._low_pass_filter_cutoff_f_slider_range = Range(
            low_pass_filter_cutoff_f - 40e3, low_pass_filter_cutoff_f + 40e3,
            5e3, low_pass_filter_cutoff_f, 200)
        self._low_pass_filter_cutoff_f_slider_win = RangeWidget(
            self._low_pass_filter_cutoff_f_slider_range,
            self.set_low_pass_filter_cutoff_f_slider, 'Filter cutoff freq',
            "counter_slider", float)
        self.top_grid_layout.addWidget(
            self._low_pass_filter_cutoff_f_slider_win)
        self._if_slider_range = Range(-5e6, 5e6, 50e3, -1.50e6, 200)
        self._if_slider_win = RangeWidget(self._if_slider_range,
                                          self.set_if_slider, 'IF frequency',
                                          "counter_slider", float)
        self.top_grid_layout.addWidget(self._if_slider_win)
        self.qtgui_freq_sink_x_0_0_0 = qtgui.freq_sink_f(
            1024,  #size
            firdes.WIN_RECTANGULAR,  #wintype
            sdr_hardware_f_slider - if_slider,  #fc
            0,  #bw
            "FFT audio",  #name
            1  #number of inputs
        )
        self.qtgui_freq_sink_x_0_0_0.set_update_time(0.10)
        self.qtgui_freq_sink_x_0_0_0.set_y_axis(-140, 10)
        self.qtgui_freq_sink_x_0_0_0.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_0_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE,
                                                      0.0, 0, "")
        self.qtgui_freq_sink_x_0_0_0.enable_autoscale(False)
        self.qtgui_freq_sink_x_0_0_0.enable_grid(False)
        self.qtgui_freq_sink_x_0_0_0.set_fft_average(0.2)
        self.qtgui_freq_sink_x_0_0_0.enable_axis_labels(True)
        self.qtgui_freq_sink_x_0_0_0.enable_control_panel(False)

        if not True:
            self.qtgui_freq_sink_x_0_0_0.disable_legend()

        if "float" == "float" or "float" == "msg_float":
            self.qtgui_freq_sink_x_0_0_0.set_plot_pos_half(not True)

        labels = ['', '', '', '', '', '', '', '', '', '']
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "green", "black", "cyan", "magenta", "yellow",
            "dark red", "dark green", "dark blue"
        ]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_freq_sink_x_0_0_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_freq_sink_x_0_0_0.set_line_label(i, labels[i])
            self.qtgui_freq_sink_x_0_0_0.set_line_width(i, widths[i])
            self.qtgui_freq_sink_x_0_0_0.set_line_color(i, colors[i])
            self.qtgui_freq_sink_x_0_0_0.set_line_alpha(i, alphas[i])

        self._qtgui_freq_sink_x_0_0_0_win = sip.wrapinstance(
            self.qtgui_freq_sink_x_0_0_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_0_0_win)
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c(
            1024,  #size
            firdes.WIN_RECTANGULAR,  #wintype
            sdr_hardware_f_slider - if_slider,  #fc
            0,  #bw
            "FFT before filter",  #name
            1  #number of inputs
        )
        self.qtgui_freq_sink_x_0.set_update_time(0.10)
        self.qtgui_freq_sink_x_0.set_y_axis(-140, 10)
        self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0,
                                                  "")
        self.qtgui_freq_sink_x_0.enable_autoscale(False)
        self.qtgui_freq_sink_x_0.enable_grid(False)
        self.qtgui_freq_sink_x_0.set_fft_average(0.2)
        self.qtgui_freq_sink_x_0.enable_axis_labels(True)
        self.qtgui_freq_sink_x_0.enable_control_panel(False)

        if not True:
            self.qtgui_freq_sink_x_0.disable_legend()

        if "complex" == "float" or "complex" == "msg_float":
            self.qtgui_freq_sink_x_0.set_plot_pos_half(not True)

        labels = ['', '', '', '', '', '', '', '', '', '']
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "green", "black", "cyan", "magenta", "yellow",
            "dark red", "dark green", "dark blue"
        ]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_freq_sink_x_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_freq_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_freq_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_freq_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i])

        self._qtgui_freq_sink_x_0_win = sip.wrapinstance(
            self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win)
        self.osmosdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " +
                                               '')
        self.osmosdr_source_0.set_sample_rate(samp_rate)
        self.osmosdr_source_0.set_center_freq(sdr_hardware_f_slider, 0)
        self.osmosdr_source_0.set_freq_corr(0, 0)
        self.osmosdr_source_0.set_dc_offset_mode(0, 0)
        self.osmosdr_source_0.set_iq_balance_mode(0, 0)
        self.osmosdr_source_0.set_gain_mode(False, 0)
        self.osmosdr_source_0.set_gain(10, 0)
        self.osmosdr_source_0.set_if_gain(20, 0)
        self.osmosdr_source_0.set_bb_gain(30, 0)
        self.osmosdr_source_0.set_antenna('', 0)
        self.osmosdr_source_0.set_bandwidth(0, 0)

        self.low_pass_filter_0 = filter.fir_filter_ccf(
            10,
            firdes.low_pass(1, samp_rate, low_pass_filter_cutoff_f_slider,
                            low_pass_trans_width_slider, firdes.WIN_HAMMING,
                            6.76))
        self._curr_f_label_tool_bar = Qt.QToolBar(self)

        if None:
            self._curr_f_label_formatter = None
        else:
            self._curr_f_label_formatter = lambda x: eng_notation.num_to_str(x)

        self._curr_f_label_tool_bar.addWidget(
            Qt.QLabel('Current Frequency' + ": "))
        self._curr_f_label_label = Qt.QLabel(
            str(self._curr_f_label_formatter(self.curr_f_label)))
        self._curr_f_label_tool_bar.addWidget(self._curr_f_label_label)
        self.top_grid_layout.addWidget(self._curr_f_label_tool_bar)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff(
            (volume_slider, ))
        self.audio_sink_0 = audio.sink(48000, '', True)
        self.analog_wfm_rcv_1 = analog.wfm_rcv(
            quad_rate=480e3,
            audio_decimation=10,
        )
        self.analog_standard_squelch_0 = analog.standard_squelch(
            audio_rate=48e3)
        self.analog_standard_squelch_0.set_threshold(squelch_slider)
        self.analog_sig_source_x_1 = analog.sig_source_c(
            samp_rate, analog.GR_COS_WAVE, if_slider, 1, 0)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_sig_source_x_1, 0),
                     (self.blocks_multiply_xx_0, 0))
        self.connect((self.analog_standard_squelch_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.analog_wfm_rcv_1, 0),
                     (self.analog_standard_squelch_0, 0))
        self.connect((self.analog_wfm_rcv_1, 0),
                     (self.qtgui_freq_sink_x_0_0_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.audio_sink_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0),
                     (self.low_pass_filter_0, 0))
        self.connect((self.low_pass_filter_0, 0), (self.analog_wfm_rcv_1, 0))
        self.connect((self.osmosdr_source_0, 0),
                     (self.blocks_multiply_xx_0, 1))
        self.connect((self.osmosdr_source_0, 0), (self.qtgui_freq_sink_x_0, 0))
Exemple #35
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="FM Receiver")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Variables
        ##################################################
        self.band_segment = band_segment = 94.4e6
        self.adjust_freq = adjust_freq = 0
        self.variable_static_text_0 = variable_static_text_0 = band_segment + adjust_freq
        self.samp_rate = samp_rate = 1024000
        self.rf_gain = rf_gain = 30
        self.if_gain = if_gain = 30
        self.audio_gain = audio_gain = .1

        ##################################################
        # Blocks
        ##################################################
        _rf_gain_sizer = wx.BoxSizer(wx.VERTICAL)
        self._rf_gain_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_rf_gain_sizer,
            value=self.rf_gain,
            callback=self.set_rf_gain,
            label='RF Gain',
            converter=forms.float_converter(),
            proportion=0,
        )
        self._rf_gain_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_rf_gain_sizer,
            value=self.rf_gain,
            callback=self.set_rf_gain,
            minimum=0,
            maximum=100,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_rf_gain_sizer, 3, 1, 1, 1)
        _if_gain_sizer = wx.BoxSizer(wx.VERTICAL)
        self._if_gain_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_if_gain_sizer,
            value=self.if_gain,
            callback=self.set_if_gain,
            label='IF Gain',
            converter=forms.float_converter(),
            proportion=0,
        )
        self._if_gain_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_if_gain_sizer,
            value=self.if_gain,
            callback=self.set_if_gain,
            minimum=0,
            maximum=100,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_if_gain_sizer, 3, 2, 1, 1)
        self._band_segment_chooser = forms.radio_buttons(
            parent=self.GetWin(),
            value=self.band_segment,
            callback=self.set_band_segment,
            label='Station',
            choices=[88.2e6, 94.4e6, 94.9e6, 102.7e6],
            labels=[88.2, 94.4, 94.9, 102.7],
            style=wx.RA_HORIZONTAL,
        )
        self.GridAdd(self._band_segment_chooser, 2, 0, 1, 4)
        _audio_gain_sizer = wx.BoxSizer(wx.VERTICAL)
        self._audio_gain_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_audio_gain_sizer,
            value=self.audio_gain,
            callback=self.set_audio_gain,
            label='Audio Gain',
            converter=forms.float_converter(),
            proportion=0,
        )
        self._audio_gain_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_audio_gain_sizer,
            value=self.audio_gain,
            callback=self.set_audio_gain,
            minimum=0,
            maximum=5,
            num_steps=1000,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_audio_gain_sizer, 3, 0, 1, 1)
        _adjust_freq_sizer = wx.BoxSizer(wx.VERTICAL)
        self._adjust_freq_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_adjust_freq_sizer,
            value=self.adjust_freq,
            callback=self.set_adjust_freq,
            label='Frequency Tune: +/- 200KHz',
            converter=forms.float_converter(),
            proportion=0,
        )
        self._adjust_freq_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_adjust_freq_sizer,
            value=self.adjust_freq,
            callback=self.set_adjust_freq,
            minimum=-2e3,
            maximum=2e3,
            num_steps=1000,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_adjust_freq_sizer, 3, 3, 1, 1)
        self.wxgui_fftsink2_0 = fftsink2.fft_sink_c(
            self.GetWin(),
            baseband_freq=band_segment + adjust_freq,
            y_per_div=10,
            y_divs=12,
            ref_level=0,
            ref_scale=2.0,
            sample_rate=samp_rate,
            fft_size=1024,
            fft_rate=10,
            average=False,
            avg_alpha=.2,
            title='RF Spectrum ',
            peak_hold=True,
            size=(1024, 512),
        )
        self.GridAdd(self.wxgui_fftsink2_0.win, 0, 0, 1, 4)
        self._variable_static_text_0_static_text = forms.static_text(
            parent=self.GetWin(),
            value=self.variable_static_text_0,
            callback=self.set_variable_static_text_0,
            label='Current Frequency : ',
            converter=forms.float_converter(),
        )
        self.GridAdd(self._variable_static_text_0_static_text, 1, 0, 1, 4)
        self.rtlsdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " +
                                              '')
        self.rtlsdr_source_0.set_sample_rate(samp_rate)
        self.rtlsdr_source_0.set_center_freq(band_segment + adjust_freq, 0)
        self.rtlsdr_source_0.set_freq_corr(0, 0)
        self.rtlsdr_source_0.set_dc_offset_mode(0, 0)
        self.rtlsdr_source_0.set_iq_balance_mode(0, 0)
        self.rtlsdr_source_0.set_gain_mode(False, 0)
        self.rtlsdr_source_0.set_gain(rf_gain, 0)
        self.rtlsdr_source_0.set_if_gain(if_gain, 0)
        self.rtlsdr_source_0.set_bb_gain(0, 0)
        self.rtlsdr_source_0.set_antenna('', 0)
        self.rtlsdr_source_0.set_bandwidth(0, 0)

        self.low_pass_filter_1 = filter.fir_filter_fff(
            10,
            firdes.low_pass(1, samp_rate, 10.0e3, 1e3, firdes.WIN_HAMMING,
                            6.76))
        self.low_pass_filter_0 = filter.fir_filter_ccf(
            1,
            firdes.low_pass(1, samp_rate, 250e3, 5e3, firdes.WIN_HAMMING,
                            6.76))
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff(
            (audio_gain, ))
        self.audio_sink_0 = audio.sink(48000, '', True)
        self.analog_wfm_rcv_0 = analog.wfm_rcv(
            quad_rate=samp_rate,
            audio_decimation=2,
        )

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_wfm_rcv_0, 0), (self.low_pass_filter_1, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.audio_sink_0, 0))
        self.connect((self.low_pass_filter_0, 0), (self.analog_wfm_rcv_0, 0))
        self.connect((self.low_pass_filter_1, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.rtlsdr_source_0, 0), (self.low_pass_filter_0, 0))
        self.connect((self.rtlsdr_source_0, 0), (self.wxgui_fftsink2_0, 0))
Exemple #36
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Top Block")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 10e6
        self.channel_width = channel_width = 200e3
        self.channel_freq = channel_freq = 97.9e6
        self.center_freq = center_freq = 97.9e6
        self.audio_gain = audio_gain = 0.1

        ##################################################
        # Blocks
        ##################################################
        _channel_freq_sizer = wx.BoxSizer(wx.VERTICAL)
        self._channel_freq_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_channel_freq_sizer,
        	value=self.channel_freq,
        	callback=self.set_channel_freq,
        	label='channel_freq',
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._channel_freq_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_channel_freq_sizer,
        	value=self.channel_freq,
        	callback=self.set_channel_freq,
        	minimum=87.9e6,
        	maximum=107.9e6,
        	num_steps=200,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.Add(_channel_freq_sizer)
        _audio_gain_sizer = wx.BoxSizer(wx.VERTICAL)
        self._audio_gain_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_audio_gain_sizer,
        	value=self.audio_gain,
        	callback=self.set_audio_gain,
        	label='audio_gain',
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._audio_gain_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_audio_gain_sizer,
        	value=self.audio_gain,
        	callback=self.set_audio_gain,
        	minimum=0,
        	maximum=10,
        	num_steps=100,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.Add(_audio_gain_sizer)
        self.wxgui_fftsink2_0 = fftsink2.fft_sink_c(
        	self.GetWin(),
        	baseband_freq=center_freq,
        	y_per_div=10,
        	y_divs=10,
        	ref_level=0,
        	ref_scale=2.0,
        	sample_rate=samp_rate,
        	fft_size=1024,
        	fft_rate=15,
        	average=True,
        	avg_alpha=None,
        	title='FFT Plot',
        	peak_hold=False,
        )
        self.Add(self.wxgui_fftsink2_0.win)
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
                interpolation=12,
                decimation=5,
                taps=None,
                fractional_bw=None,
        )
        self.osmosdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + '' )
        self.osmosdr_source_0.set_sample_rate(samp_rate)
        self.osmosdr_source_0.set_center_freq(center_freq, 0)
        self.osmosdr_source_0.set_freq_corr(0, 0)
        self.osmosdr_source_0.set_dc_offset_mode(0, 0)
        self.osmosdr_source_0.set_iq_balance_mode(0, 0)
        self.osmosdr_source_0.set_gain_mode(False, 0)
        self.osmosdr_source_0.set_gain(0, 0)
        self.osmosdr_source_0.set_if_gain(20, 0)
        self.osmosdr_source_0.set_bb_gain(20, 0)
        self.osmosdr_source_0.set_antenna('', 0)
        self.osmosdr_source_0.set_bandwidth(0, 0)

        self.low_pass_filter_0 = filter.fir_filter_ccf(int(samp_rate / channel_width), firdes.low_pass(
        	1, samp_rate, 75e3, 25e3, firdes.WIN_HAMMING, 6.76))
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((audio_gain, ))
        self.audio_sink_0 = audio.sink(48000, '', True)
        self.analog_wfm_rcv_0 = analog.wfm_rcv(
        	quad_rate=480e3,
        	audio_decimation=10,
        )
        self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, center_freq - channel_freq, 1, 0)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1))
        self.connect((self.analog_wfm_rcv_0, 0), (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.audio_sink_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0), (self.low_pass_filter_0, 0))
        self.connect((self.low_pass_filter_0, 0), (self.rational_resampler_xxx_0, 0))
        self.connect((self.osmosdr_source_0, 0), (self.blocks_multiply_xx_0, 0))
        self.connect((self.osmosdr_source_0, 0), (self.wxgui_fftsink2_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0), (self.analog_wfm_rcv_0, 0))
    def __init__(self):
        gr.top_block.__init__(self, "Tutorial Two 2")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Tutorial Two 2")
        qtgui.util.check_set_qss()
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

        self.settings = Qt.QSettings("GNU Radio", "tutorial_two_2")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 48000
        self.probe_var = probe_var = 0

        ##################################################
        # Blocks
        ##################################################
        self.probe_signal = blocks.probe_signal_f()
        self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_f(
            1024,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate,  #bw
            "QT GUI Plot",  #name
            1  #number of inputs
        )
        self.qtgui_waterfall_sink_x_0.set_update_time(0.10)
        self.qtgui_waterfall_sink_x_0.enable_grid(False)
        self.qtgui_waterfall_sink_x_0.enable_axis_labels(True)

        if not True:
            self.qtgui_waterfall_sink_x_0.disable_legend()

        if "float" == "float" or "float" == "msg_float":
            self.qtgui_waterfall_sink_x_0.set_plot_pos_half(not True)

        labels = ['', '', '', '', '', '', '', '', '', '']
        colors = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_waterfall_sink_x_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_waterfall_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_waterfall_sink_x_0.set_color_map(i, colors[i])
            self.qtgui_waterfall_sink_x_0.set_line_alpha(i, alphas[i])

        self.qtgui_waterfall_sink_x_0.set_intensity_range(-140, 10)

        self._qtgui_waterfall_sink_x_0_win = sip.wrapinstance(
            self.qtgui_waterfall_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_waterfall_sink_x_0_win)
        self.qtgui_time_sink_x_0 = qtgui.time_sink_f(
            1024,  #size
            samp_rate,  #samp_rate
            "QT GUI Plot",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0.set_y_axis(-1, 1)

        self.qtgui_time_sink_x_0.set_y_label('Amplitude', "")

        self.qtgui_time_sink_x_0.enable_tags(-1, True)
        self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE,
                                                  qtgui.TRIG_SLOPE_POS, 0.0, 0,
                                                  0, "")
        self.qtgui_time_sink_x_0.enable_autoscale(False)
        self.qtgui_time_sink_x_0.enable_grid(False)
        self.qtgui_time_sink_x_0.enable_axis_labels(True)
        self.qtgui_time_sink_x_0.enable_control_panel(False)
        self.qtgui_time_sink_x_0.enable_stem_plot(False)

        if not True:
            self.qtgui_time_sink_x_0.disable_legend()

        labels = ['', '', '', '', '', '', '', '', '', '']
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "green", "black", "cyan", "magenta", "yellow",
            "dark red", "dark green", "blue"
        ]
        styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]

        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_time_sink_x_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_0.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_0.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i])

        self._qtgui_time_sink_x_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_win)
        self.qtgui_tab_widget_0 = Qt.QTabWidget()
        self.qtgui_tab_widget_0_widget_0 = Qt.QWidget()
        self.qtgui_tab_widget_0_layout_0 = Qt.QBoxLayout(
            Qt.QBoxLayout.TopToBottom, self.qtgui_tab_widget_0_widget_0)
        self.qtgui_tab_widget_0_grid_layout_0 = Qt.QGridLayout()
        self.qtgui_tab_widget_0_layout_0.addLayout(
            self.qtgui_tab_widget_0_grid_layout_0)
        self.qtgui_tab_widget_0.addTab(self.qtgui_tab_widget_0_widget_0,
                                       'Time')
        self.qtgui_tab_widget_0_widget_1 = Qt.QWidget()
        self.qtgui_tab_widget_0_layout_1 = Qt.QBoxLayout(
            Qt.QBoxLayout.TopToBottom, self.qtgui_tab_widget_0_widget_1)
        self.qtgui_tab_widget_0_grid_layout_1 = Qt.QGridLayout()
        self.qtgui_tab_widget_0_layout_1.addLayout(
            self.qtgui_tab_widget_0_grid_layout_1)
        self.qtgui_tab_widget_0.addTab(self.qtgui_tab_widget_0_widget_1,
                                       'Waterfall')
        self.top_grid_layout.addWidget(self.qtgui_tab_widget_0)

        def _probe_var_probe():
            while True:
                val = self.probe_signal.level()
                try:
                    self.set_probe_var(val)
                except AttributeError:
                    pass
                time.sleep(1.0 / (10))

        _probe_var_thread = threading.Thread(target=_probe_var_probe)
        _probe_var_thread.daemon = True
        _probe_var_thread.start()

        self.audio_sink_0 = audio.sink(48000, '', True)
        self.analog_sig_source_x_0_0 = analog.sig_source_f(
            samp_rate, analog.GR_SIN_WAVE, 0, 0.5, 0)
        self.analog_sig_source_x_0 = analog.sig_source_f(
            samp_rate, analog.GR_TRI_WAVE, 0.0001, 1, 0)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_sig_source_x_0, 0), (self.probe_signal, 0))
        self.connect((self.analog_sig_source_x_0_0, 0), (self.audio_sink_0, 0))
        self.connect((self.analog_sig_source_x_0_0, 0),
                     (self.qtgui_time_sink_x_0, 0))
        self.connect((self.analog_sig_source_x_0_0, 0),
                     (self.qtgui_waterfall_sink_x_0, 0))
Exemple #38
0
    def __init__(self,
                 audio_device="dmix:CARD=monitor,DEV=0",
                 decimation=1,
                 fm_station=401100000,
                 hostname='127.0.0.1',
                 interpolation=2,
                 uri='193.168.2.1',
                 wav_file='/home/work/github/gnuradio/grexample/111.wav'):
        gr.top_block.__init__(self, "Testfm")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Testfm")
        qtgui.util.check_set_qss()
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

        self.settings = Qt.QSettings("GNU Radio", "testFM")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Parameters
        ##################################################
        self.audio_device = audio_device
        self.decimation = decimation
        self.fm_station = fm_station
        self.hostname = hostname
        self.interpolation = interpolation
        self.uri = uri
        self.wav_file = wav_file

        ##################################################
        # Variables
        ##################################################
        self.sample_rate = sample_rate = 2200000
        self.samp_rate = samp_rate = 2304000

        ##################################################
        # Blocks
        ##################################################
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
            interpolation=8 / interpolation,
            decimation=1,
            taps=None,
            fractional_bw=None,
        )
        self.qtgui_sink_x_1 = qtgui.sink_c(
            1024,  #fftsize
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            fm_station,  #fc
            samp_rate,  #bw
            "",  #name
            True,  #plotfreq
            True,  #plotwaterfall
            True,  #plottime
            True,  #plotconst
        )
        self.qtgui_sink_x_1.set_update_time(1.0 / 10)
        self._qtgui_sink_x_1_win = sip.wrapinstance(
            self.qtgui_sink_x_1.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_sink_x_1_win)

        self.qtgui_sink_x_1.enable_rf_freq(False)

        self.qtgui_sink_x_0 = qtgui.sink_c(
            1024,  #fftsize
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            fm_station,  #fc
            20000,  #bw
            "",  #name
            True,  #plotfreq
            True,  #plotwaterfall
            True,  #plottime
            True,  #plotconst
        )
        self.qtgui_sink_x_0.set_update_time(1.0 / 10)
        self._qtgui_sink_x_0_win = sip.wrapinstance(
            self.qtgui_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_sink_x_0_win)

        self.qtgui_sink_x_0.enable_rf_freq(True)

        self.pluto_source_0 = iio.pluto_source(uri, fm_station, samp_rate,
                                               20000, 0x20000, True, True,
                                               True, "manual", 10.0, '', True)
        self.pluto_sink_0 = iio.pluto_sink(uri, fm_station, samp_rate, 20000,
                                           0x8000, False, 10.0, '', True)
        self.low_pass_filter_0 = filter.fir_filter_ccf(
            sample_rate / (384000 * decimation),
            firdes.low_pass(1, sample_rate / decimation, 44100, 44100,
                            firdes.WIN_HAMMING, 6.76))
        self.blocks_wavfile_source_0 = blocks.wavfile_source(
            '/home/work/github/gnuradio/grexample/111.wav', True)
        self.blocks_add_xx_0 = blocks.add_vff(1)
        self.audio_sink_0 = audio.sink(48000, '', True)
        self.analog_wfm_rcv_0 = analog.wfm_rcv(
            quad_rate=288000,
            audio_decimation=8,
        )
        self.analog_nbfm_tx_0 = analog.nbfm_tx(
            audio_rate=48000,
            quad_rate=samp_rate / 8,
            tau=75e-6,
            max_dev=75e3,
            fh=-1.0,
        )

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_nbfm_tx_0, 0),
                     (self.rational_resampler_xxx_0, 0))
        self.connect((self.analog_wfm_rcv_0, 0), (self.audio_sink_0, 0))
        self.connect((self.blocks_add_xx_0, 0), (self.analog_nbfm_tx_0, 0))
        self.connect((self.blocks_wavfile_source_0, 0),
                     (self.blocks_add_xx_0, 0))
        self.connect((self.blocks_wavfile_source_0, 1),
                     (self.blocks_add_xx_0, 1))
        self.connect((self.low_pass_filter_0, 0), (self.analog_wfm_rcv_0, 0))
        self.connect((self.low_pass_filter_0, 0), (self.qtgui_sink_x_1, 0))
        self.connect((self.pluto_source_0, 0), (self.low_pass_filter_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.pluto_sink_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.qtgui_sink_x_0, 0))
Exemple #39
0
    def __init__(self):
        gr.top_block.__init__(self, "Fm Fdb B")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Fm Fdb B")
        qtgui.util.check_set_qss()
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

        self.settings = Qt.QSettings("GNU Radio", "FM_FDB_B")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.volume = volume = 1
        self.rx_sr = rx_sr = 1e6
        self.qa_rate = qa_rate = 200e3
        self.cf = cf = 2.45e9
        self.a_rate = a_rate = 44.1e3

        ##################################################
        # Blocks
        ##################################################
        self._volume_range = Range(0, 1, 0.1, 1, 200)
        self._volume_win = RangeWidget(self._volume_range, self.set_volume,
                                       "volume", "counter_slider", float)
        self.top_layout.addWidget(self._volume_win)
        self.controls = Qt.QTabWidget()
        self.controls_widget_0 = Qt.QWidget()
        self.controls_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom,
                                               self.controls_widget_0)
        self.controls_grid_layout_0 = Qt.QGridLayout()
        self.controls_layout_0.addLayout(self.controls_grid_layout_0)
        self.controls.addTab(self.controls_widget_0, 'Freq_RX')
        self.controls_widget_1 = Qt.QWidget()
        self.controls_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom,
                                               self.controls_widget_1)
        self.controls_grid_layout_1 = Qt.QGridLayout()
        self.controls_layout_1.addLayout(self.controls_grid_layout_1)
        self.controls.addTab(self.controls_widget_1, 'Time_RX')
        self.controls_widget_2 = Qt.QWidget()
        self.controls_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom,
                                               self.controls_widget_2)
        self.controls_grid_layout_2 = Qt.QGridLayout()
        self.controls_layout_2.addLayout(self.controls_grid_layout_2)
        self.controls.addTab(self.controls_widget_2, 'Freq_TX')
        self.controls_widget_3 = Qt.QWidget()
        self.controls_layout_3 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom,
                                               self.controls_widget_3)
        self.controls_grid_layout_3 = Qt.QGridLayout()
        self.controls_layout_3.addLayout(self.controls_grid_layout_3)
        self.controls.addTab(self.controls_widget_3, 'Time_TX')
        self.top_layout.addWidget(self.controls)
        self.uhd_usrp_source_0 = uhd.usrp_source(
            ",".join(('', "")),
            uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ),
        )
        self.uhd_usrp_source_0.set_samp_rate(rx_sr)
        self.uhd_usrp_source_0.set_center_freq(5e9, 0)
        self.uhd_usrp_source_0.set_gain(0, 0)
        self.uhd_usrp_source_0.set_antenna('RX2', 0)
        self.uhd_usrp_sink_0 = uhd.usrp_sink(
            ",".join(("", "")),
            uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ),
        )
        self.uhd_usrp_sink_0.set_samp_rate(rx_sr)
        self.uhd_usrp_sink_0.set_center_freq(2.45e9, 0)
        self.uhd_usrp_sink_0.set_gain(0, 0)
        self.uhd_usrp_sink_0.set_antenna('TX/RX', 0)
        self.rational_resampler_xxx_1 = filter.rational_resampler_ccc(
            interpolation=int(rx_sr),
            decimation=int(a_rate),
            taps=None,
            fractional_bw=None,
        )
        self.rational_resampler_xxx_0 = filter.rational_resampler_fff(
            interpolation=int(a_rate / 1e3 * 1.03),
            decimation=int(qa_rate / 1e3),
            taps=None,
            fractional_bw=None,
        )
        self.qtgui_time_sink_x_0_0 = qtgui.time_sink_f(
            1024,  #size
            a_rate,  #samp_rate
            "",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_0_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0_0.set_y_axis(-1, 1)

        self.qtgui_time_sink_x_0_0.set_y_label('Amplitude', "")

        self.qtgui_time_sink_x_0_0.enable_tags(-1, True)
        self.qtgui_time_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE,
                                                    qtgui.TRIG_SLOPE_POS, 0.0,
                                                    0, 0, "")
        self.qtgui_time_sink_x_0_0.enable_autoscale(False)
        self.qtgui_time_sink_x_0_0.enable_grid(False)
        self.qtgui_time_sink_x_0_0.enable_axis_labels(True)
        self.qtgui_time_sink_x_0_0.enable_control_panel(False)

        if not True:
            self.qtgui_time_sink_x_0_0.disable_legend()

        labels = ['Audio Signal', '', '', '', '', '', '', '', '', '']
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "green", "black", "cyan", "magenta", "yellow",
            "dark red", "dark green", "blue"
        ]
        styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]

        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_time_sink_x_0_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_0_0.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_0_0.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_0_0.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_0_0.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_0_0.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_0_0.set_line_alpha(i, alphas[i])

        self._qtgui_time_sink_x_0_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_0_0.pyqwidget(), Qt.QWidget)
        self.controls_grid_layout_3.addWidget(self._qtgui_time_sink_x_0_0_win,
                                              0, 0, 1, 1)
        self.qtgui_time_sink_x_0 = qtgui.time_sink_f(
            1024,  #size
            a_rate,  #samp_rate
            "",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0.set_y_axis(-1, 1)

        self.qtgui_time_sink_x_0.set_y_label('Amplitude', "")

        self.qtgui_time_sink_x_0.enable_tags(-1, True)
        self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE,
                                                  qtgui.TRIG_SLOPE_POS, 0.0, 0,
                                                  0, "")
        self.qtgui_time_sink_x_0.enable_autoscale(False)
        self.qtgui_time_sink_x_0.enable_grid(False)
        self.qtgui_time_sink_x_0.enable_axis_labels(True)
        self.qtgui_time_sink_x_0.enable_control_panel(False)

        if not True:
            self.qtgui_time_sink_x_0.disable_legend()

        labels = ['', '', '', '', '', '', '', '', '', '']
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "green", "black", "cyan", "magenta", "yellow",
            "dark red", "dark green", "blue"
        ]
        styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]

        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_time_sink_x_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_0.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_0.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i])

        self._qtgui_time_sink_x_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget)
        self.controls_grid_layout_1.addWidget(self._qtgui_time_sink_x_0_win, 0,
                                              0, 1, 1)
        self.qtgui_freq_sink_x_0_0 = qtgui.freq_sink_c(
            1024,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            rx_sr,  #bw
            "",  #name
            1  #number of inputs
        )
        self.qtgui_freq_sink_x_0_0.set_update_time(0.10)
        self.qtgui_freq_sink_x_0_0.set_y_axis(-140, 10)
        self.qtgui_freq_sink_x_0_0.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0,
                                                    0, "")
        self.qtgui_freq_sink_x_0_0.enable_autoscale(False)
        self.qtgui_freq_sink_x_0_0.enable_grid(False)
        self.qtgui_freq_sink_x_0_0.set_fft_average(1.0)
        self.qtgui_freq_sink_x_0_0.enable_axis_labels(True)
        self.qtgui_freq_sink_x_0_0.enable_control_panel(False)

        if not True:
            self.qtgui_freq_sink_x_0_0.disable_legend()

        if "complex" == "float" or "complex" == "msg_float":
            self.qtgui_freq_sink_x_0_0.set_plot_pos_half(not True)

        labels = ['', '', '', '', '', '', '', '', '', '']
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "green", "black", "cyan", "magenta", "yellow",
            "dark red", "dark green", "dark blue"
        ]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_freq_sink_x_0_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_freq_sink_x_0_0.set_line_label(i, labels[i])
            self.qtgui_freq_sink_x_0_0.set_line_width(i, widths[i])
            self.qtgui_freq_sink_x_0_0.set_line_color(i, colors[i])
            self.qtgui_freq_sink_x_0_0.set_line_alpha(i, alphas[i])

        self._qtgui_freq_sink_x_0_0_win = sip.wrapinstance(
            self.qtgui_freq_sink_x_0_0.pyqwidget(), Qt.QWidget)
        self.controls_grid_layout_2.addWidget(self._qtgui_freq_sink_x_0_0_win,
                                              0, 0, 1, 1)
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c(
            1024,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            rx_sr,  #bw
            "",  #name
            1  #number of inputs
        )
        self.qtgui_freq_sink_x_0.set_update_time(0.10)
        self.qtgui_freq_sink_x_0.set_y_axis(-140, 10)
        self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0,
                                                  "")
        self.qtgui_freq_sink_x_0.enable_autoscale(False)
        self.qtgui_freq_sink_x_0.enable_grid(False)
        self.qtgui_freq_sink_x_0.set_fft_average(1.0)
        self.qtgui_freq_sink_x_0.enable_axis_labels(True)
        self.qtgui_freq_sink_x_0.enable_control_panel(False)

        if not True:
            self.qtgui_freq_sink_x_0.disable_legend()

        if "complex" == "float" or "complex" == "msg_float":
            self.qtgui_freq_sink_x_0.set_plot_pos_half(not True)

        labels = ['', '', '', '', '', '', '', '', '', '']
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "green", "black", "cyan", "magenta", "yellow",
            "dark red", "dark green", "dark blue"
        ]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_freq_sink_x_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_freq_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_freq_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_freq_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i])

        self._qtgui_freq_sink_x_0_win = sip.wrapinstance(
            self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget)
        self.controls_grid_layout_0.addWidget(self._qtgui_freq_sink_x_0_win, 0,
                                              0, 1, 1)
        self.low_pass_filter_0 = filter.fir_filter_ccf(
            5, firdes.low_pass(1, rx_sr, 10e3, 1e3, firdes.WIN_HAMMING, 6.76))
        self._cf_range = Range(2e9, 3e9, 0.1e9, 2.45e9, 200)
        self._cf_win = RangeWidget(self._cf_range, self.set_cf, "cf",
                                   "counter_slider", float)
        self.top_layout.addWidget(self._cf_win)
        self.blocks_wavfile_sink_0 = blocks.wavfile_sink(
            'fm_record', 1, 44100, 8)
        self.blocks_probe_rate_0 = blocks.probe_rate(gr.sizeof_gr_complex * 1,
                                                     500.0, 0.15)
        self.blocks_multiply_const_vxx_0_1 = blocks.multiply_const_vcc((1, ))
        self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vff((0.5, ))
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff(
            (volume, ))
        self.blocks_message_debug_0 = blocks.message_debug()
        self.audio_source_0 = audio.source(44100, '', False)
        self.audio_sink_0 = audio.sink(44100, '', False)
        self.analog_nbfm_tx_0 = analog.nbfm_tx(
            audio_rate=int(a_rate),
            quad_rate=int(a_rate),
            tau=75e-6,
            max_dev=20e3,
            fh=-1.0,
        )
        self.analog_nbfm_rx_0 = analog.nbfm_rx(
            audio_rate=int(qa_rate),
            quad_rate=int(qa_rate),
            tau=75e-6,
            max_dev=20e3,
        )

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_probe_rate_0, 'rate'),
                         (self.blocks_message_debug_0, 'print'))
        self.connect((self.analog_nbfm_rx_0, 0),
                     (self.rational_resampler_xxx_0, 0))
        self.connect((self.analog_nbfm_tx_0, 0), (self.blocks_probe_rate_0, 0))
        self.connect((self.analog_nbfm_tx_0, 0),
                     (self.rational_resampler_xxx_1, 0))
        self.connect((self.audio_source_0, 0),
                     (self.blocks_multiply_const_vxx_0_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.audio_sink_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.blocks_wavfile_sink_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.qtgui_time_sink_x_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0_0, 0),
                     (self.analog_nbfm_tx_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0_0, 0),
                     (self.qtgui_time_sink_x_0_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0_1, 0),
                     (self.qtgui_freq_sink_x_0_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0_1, 0),
                     (self.uhd_usrp_sink_0, 0))
        self.connect((self.low_pass_filter_0, 0), (self.analog_nbfm_rx_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.rational_resampler_xxx_1, 0),
                     (self.blocks_multiply_const_vxx_0_1, 0))
        self.connect((self.uhd_usrp_source_0, 0), (self.low_pass_filter_0, 0))
        self.connect((self.uhd_usrp_source_0, 0),
                     (self.qtgui_freq_sink_x_0, 0))
Exemple #40
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="FM radio FFT example")

        ##################################################
        # Variables
        ##################################################
        self.variable_static_text_0 = variable_static_text_0 = 'RTL R820T'
        self.variable_sample_rate_0 = variable_sample_rate_0 = 1.024E6
        self.RF_Gain = RF_Gain = 13
        self.CF = CF = 106.7e6

        ##################################################
        # Blocks
        ##################################################
        self._variable_sample_rate_0_text_box = forms.text_box(
        	parent=self.GetWin(),
        	value=self.variable_sample_rate_0,
        	callback=self.set_variable_sample_rate_0,
        	label='Sample Rate: 1.024M, 1.4M, 1.8M, 1.92M, 2.048M, 2.4M & 2. 56M',
        	converter=forms.float_converter(),
        )
        self.GridAdd(self._variable_sample_rate_0_text_box, 7, 0, 1, 5)
        self.notebook_0 = self.notebook_0 = wx.Notebook(self.GetWin(), style=wx.NB_TOP)
        self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "Spectrum")
        self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "Waterfall")
        self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "Constellation")
        self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "Scope")
        self.GridAdd(self.notebook_0, 1, 0, 4, 5)
        _CF_sizer = wx.BoxSizer(wx.VERTICAL)
        self._CF_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_CF_sizer,
        	value=self.CF,
        	callback=self.set_CF,
        	label='Center Frequency',
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._CF_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_CF_sizer,
        	value=self.CF,
        	callback=self.set_CF,
        	minimum=87.9e6,
        	maximum=107.9e6,
        	num_steps=100,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_CF_sizer, 5, 0, 1, 5)
        self.wxgui_waterfallsink2_0 = waterfallsink2.waterfall_sink_c(
        	self.notebook_0.GetPage(1).GetWin(),
        	baseband_freq=CF,
        	dynamic_range=100,
        	ref_level=0,
        	ref_scale=2.0,
        	sample_rate=variable_sample_rate_0,
        	fft_size=512,
        	fft_rate=15,
        	average=False,
        	avg_alpha=None,
        	title='Waterfall Plot',
        	size=(575, 600),
        )
        self.notebook_0.GetPage(1).Add(self.wxgui_waterfallsink2_0.win)
        self.wxgui_scopesink2_0 = scopesink2.scope_sink_c(
        	self.notebook_0.GetPage(3).GetWin(),
        	title='Scope Plot',
        	sample_rate=variable_sample_rate_0,
        	v_scale=0,
        	v_offset=0,
        	t_scale=0,
        	ac_couple=False,
        	xy_mode=False,
        	num_inputs=1,
        	trig_mode=wxgui.TRIG_MODE_AUTO,
        	y_axis_label='Counts',
        )
        self.notebook_0.GetPage(3).Add(self.wxgui_scopesink2_0.win)
        self.wxgui_fftsink2_0 = fftsink2.fft_sink_c(
        	self.notebook_0.GetPage(0).GetWin(),
        	baseband_freq=CF,
        	y_per_div=10,
        	y_divs=10,
        	ref_level=0,
        	ref_scale=2.0,
        	sample_rate=2048000,
        	fft_size=1024,
        	fft_rate=15,
        	average=False,
        	avg_alpha=None,
        	title='FFT Plot',
        	peak_hold=False,
        	size=(575, 600),
        )
        self.notebook_0.GetPage(0).Add(self.wxgui_fftsink2_0.win)
        self.wxgui_constellationsink2_0 = constsink_gl.const_sink_c(
        	self.notebook_0.GetPage(2).GetWin(),
        	title='Constellation Plot',
        	sample_rate=variable_sample_rate_0,
        	frame_rate=5,
        	const_size=2048,
        	M=4,
        	theta=0,
        	loop_bw=6.28/100.0,
        	fmax=0.06,
        	mu=0.5,
        	gain_mu=0.005,
        	symbol_rate=variable_sample_rate_0/4.,
        	omega_limit=0.005,
        	size=(575, 600),
        )
        self.notebook_0.GetPage(2).Add(self.wxgui_constellationsink2_0.win)
        self._variable_static_text_0_static_text = forms.static_text(
        	parent=self.GetWin(),
        	value=self.variable_static_text_0,
        	callback=self.set_variable_static_text_0,
        	label='SDR ',
        	converter=forms.str_converter(),
        )
        self.GridAdd(self._variable_static_text_0_static_text, 0, 0, 1, 5)
        self.low_pass_filter_0 = filter.fir_filter_ccf(10, firdes.low_pass(
        	2, 2048000, 100000, 100000, firdes.WIN_HAMMING, 6.76))
        self.audio_sink_0 = audio.sink(48000, '', True)
        self.analog_wfm_rcv_0 = analog.wfm_rcv(
        	quad_rate=204800,
        	audio_decimation=4,
        )
        self.RTL820T = osmosdr.source( args="numchan=" + str(1) + " " + 'driver=rtlsdr,rtl=1' )
        self.RTL820T.set_sample_rate(2048000)
        self.RTL820T.set_center_freq(100, 0)
        self.RTL820T.set_freq_corr(0, 0)
        self.RTL820T.set_dc_offset_mode(1, 0)
        self.RTL820T.set_iq_balance_mode(1, 0)
        self.RTL820T.set_gain_mode(False, 0)
        self.RTL820T.set_gain(10, 0)
        self.RTL820T.set_if_gain(20, 0)
        self.RTL820T.set_bb_gain(20, 0)
        self.RTL820T.set_antenna('', 0)
        self.RTL820T.set_bandwidth(0, 0)
          
        _RF_Gain_sizer = wx.BoxSizer(wx.VERTICAL)
        self._RF_Gain_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_RF_Gain_sizer,
        	value=self.RF_Gain,
        	callback=self.set_RF_Gain,
        	label='RF Gain',
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._RF_Gain_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_RF_Gain_sizer,
        	value=self.RF_Gain,
        	callback=self.set_RF_Gain,
        	minimum=0,
        	maximum=45,
        	num_steps=45,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_RF_Gain_sizer, 6, 0, 1, 5)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.RTL820T, 0), (self.low_pass_filter_0, 0))    
        self.connect((self.RTL820T, 0), (self.wxgui_constellationsink2_0, 0))    
        self.connect((self.RTL820T, 0), (self.wxgui_fftsink2_0, 0))    
        self.connect((self.RTL820T, 0), (self.wxgui_scopesink2_0, 0))    
        self.connect((self.RTL820T, 0), (self.wxgui_waterfallsink2_0, 0))    
        self.connect((self.analog_wfm_rcv_0, 0), (self.audio_sink_0, 0))    
        self.connect((self.low_pass_filter_0, 0), (self.analog_wfm_rcv_0, 0))    
Exemple #41
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Airband")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Variables
        ##################################################
        self.base_freq = base_freq = 134225000
        self.volume = volume = 0.9
        self.squelch = squelch = -28
        self.samp_rate = samp_rate = 2400000
        self.freq_corr = freq_corr = 96
        self.freq = freq = base_freq

        ##################################################
        # Blocks
        ##################################################
        _volume_sizer = wx.BoxSizer(wx.VERTICAL)
        self._volume_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_volume_sizer,
            value=self.volume,
            callback=self.set_volume,
            label="Volume",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._volume_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_volume_sizer,
            value=self.volume,
            callback=self.set_volume,
            minimum=0,
            maximum=1,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.Add(_volume_sizer)
        _squelch_sizer = wx.BoxSizer(wx.VERTICAL)
        self._squelch_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_squelch_sizer,
            value=self.squelch,
            callback=self.set_squelch,
            label="Squelch",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._squelch_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_squelch_sizer,
            value=self.squelch,
            callback=self.set_squelch,
            minimum=-150,
            maximum=200,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.Add(_squelch_sizer)
        _freq_corr_sizer = wx.BoxSizer(wx.VERTICAL)
        self._freq_corr_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_freq_corr_sizer,
            value=self.freq_corr,
            callback=self.set_freq_corr,
            label="Freq correction (ppm)",
            converter=forms.int_converter(),
            proportion=0,
        )
        self._freq_corr_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_freq_corr_sizer,
            value=self.freq_corr,
            callback=self.set_freq_corr,
            minimum=-127,
            maximum=127,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=int,
            proportion=1,
        )
        self.Add(_freq_corr_sizer)
        self._freq_chooser = forms.drop_down(
            parent=self.GetWin(),
            value=self.freq,
            callback=self.set_freq,
            label="Frequency select",
            choices=[
                121250000, 121500000, 122200000, 122700000, 123450000,
                124175000, 124500000, 124925000, 125450000, 130875000,
                132700000, 134225000, 134925000, 136050000, 136575000,
                136975000, 169000000
            ],
            labels=[
                'EPSC TWR', 'EP EMRG', 'EPSD Kwadrat', 'EPSD Port',
                'Air-To-Air', 'Mueritz EDWW Radar', 'EP Przelotowa',
                'B FIR Warszawa', 'EPWW Radar 2', 'EPWW Radar 3',
                'EPWW Radar 4', 'D FIR Warszawa', 'EPWW Radar',
                'Mark EDWW Radar', 'E FIR Warszawa', 'Air-ToAir 2',
                'Lotnicze Pogotowie Ratunkowe'
            ],
        )
        self.Add(self._freq_chooser)
        self.wxgui_fftsink2_0 = fftsink2.fft_sink_c(
            self.GetWin(),
            baseband_freq=0,
            y_per_div=10,
            y_divs=10,
            ref_level=0,
            ref_scale=2.0,
            sample_rate=samp_rate,
            fft_size=512,
            fft_rate=30,
            average=False,
            avg_alpha=None,
            title="FFT Plot",
            peak_hold=False,
        )
        self.Add(self.wxgui_fftsink2_0.win)
        self.rtlsdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " +
                                              "")
        self.rtlsdr_source_0.set_sample_rate(samp_rate)
        self.rtlsdr_source_0.set_center_freq(freq, 0)
        self.rtlsdr_source_0.set_freq_corr(freq_corr, 0)
        self.rtlsdr_source_0.set_dc_offset_mode(0, 0)
        self.rtlsdr_source_0.set_iq_balance_mode(2, 0)
        self.rtlsdr_source_0.set_gain_mode(False, 0)
        self.rtlsdr_source_0.set_gain(49.6, 0)
        self.rtlsdr_source_0.set_if_gain(1, 0)
        self.rtlsdr_source_0.set_bb_gain(1, 0)
        self.rtlsdr_source_0.set_antenna("RX", 0)
        self.rtlsdr_source_0.set_bandwidth(0, 0)

        self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(
            50, (firdes.low_pass_2(1, samp_rate, 25e3, 10e3, 40)), 0,
            samp_rate)
        self.blocks_probe_signal_x_0 = blocks.probe_signal_f()
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff(
            (volume, ))
        self.audio_sink_0 = audio.sink(48000, "hw:0,1", True)
        self.analog_pwr_squelch_xx_0 = analog.pwr_squelch_cc(
            squelch, 0.1, 0, False)
        self.analog_am_demod_cf_0 = analog.am_demod_cf(
            channel_rate=48000,
            audio_decim=1,
            audio_pass=5000,
            audio_stop=5500,
        )
        self.analog_agc2_xx_0 = analog.agc2_cc(1e-1, 0.1e-4, 1.0, 0)
        self.analog_agc2_xx_0.set_max_gain(5)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.audio_sink_0, 0))
        self.connect((self.rtlsdr_source_0, 0),
                     (self.freq_xlating_fir_filter_xxx_0, 0))
        self.connect((self.analog_am_demod_cf_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.analog_agc2_xx_0, 0),
                     (self.analog_am_demod_cf_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0),
                     (self.analog_pwr_squelch_xx_0, 0))
        self.connect((self.analog_pwr_squelch_xx_0, 0),
                     (self.analog_agc2_xx_0, 0))
        self.connect((self.analog_pwr_squelch_xx_0, 0),
                     (self.wxgui_fftsink2_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.blocks_probe_signal_x_0, 0))
Exemple #42
0
    def __init__(self,
                 dest=_def_dest,
                 do_imbe=_def_do_imbe,
                 num_ambe=_def_num_ambe,
                 wireshark_host=_def_wireshark_host,
                 udp_port=_def_udp_port,
                 do_msgq=False,
                 msgq=None,
                 audio_output=_def_audio_output,
                 debug=_def_debug):
        """
	Hierarchical block for P25 decoding.

        @param debug: debug level
        @type debug: int
	"""

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

        assert 0 <= num_ambe <= _def_max_tdma_timeslots
        assert not (num_ambe > 1 and dest != 'wav')

        self.debug = debug
        self.dest = dest
        do_output = 1
        do_audio_output = True

        if msgq is None:
            msgq = gr.msg_queue(1)

        self.p25_decoders = []
        self.audio_s2f = []
        self.scaler = []
        self.audio_sink = []
        self.xorhash = []
        num_decoders = 1
        if num_ambe > 1:
            num_decoders += num_ambe - 1
        for slot in xrange(num_decoders):
            self.p25_decoders.append(
                op25_repeater.p25_frame_assembler(wireshark_host, udp_port,
                                                  debug, do_imbe, do_output,
                                                  do_msgq, msgq,
                                                  do_audio_output, True))
            self.p25_decoders[slot].set_slotid(slot)

            self.audio_s2f.append(
                blocks.short_to_float())  # another ridiculous conversion
            self.scaler.append(blocks.multiply_const_ff(1 / 32768.0))
            self.xorhash.append('')

            if dest == 'wav':
                filename = 'default-%f-%d.wav' % (time.time(), slot)
                n_channels = 1
                sample_rate = 8000
                bits_per_sample = 16
                self.audio_sink.append(
                    blocks.wavfile_sink(filename, n_channels, sample_rate,
                                        bits_per_sample))
            elif dest == 'audio':
                self.audio_sink.append(
                    audio.sink(_def_audio_rate, audio_output, True))

            self.connect(self, self.p25_decoders[slot], self.audio_s2f[slot],
                         self.scaler[slot], self.audio_sink[slot])
Exemple #43
0
    def __init__(self):
        gr.top_block.__init__(self, "RTTY decoder example")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("RTTY decoder example")
        qtgui.util.check_set_qss()
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

        self.settings = Qt.QSettings("GNU Radio", "rtty_decode")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 8000
        self.decimation = decimation = 4
        self.bps = bps = 45.45
        self.audio_rate = audio_rate = 48000

        ##################################################
        # Blocks
        ##################################################
        self.show_text_0 = display.show_text()
        self._show_text_0_win = sip.wrapinstance(self.show_text_0.pyqwidget(),
                                                 Qt.QWidget)
        self.top_grid_layout.addWidget(self._show_text_0_win)
        self.rtty_decode_ff_0 = rtty.rtty_decode_ff(
            samp_rate / decimation,
            bps,
            False,
        )
        self.rational_resampler_xxx_0 = filter.rational_resampler_fff(
            interpolation=audio_rate,
            decimation=samp_rate,
            taps=None,
            fractional_bw=None,
        )
        self.qtgui_time_sink_x_0 = qtgui.time_sink_f(
            1024,  #size
            samp_rate,  #samp_rate
            "",  #name
            2  #number of inputs
        )
        self.qtgui_time_sink_x_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0.set_y_axis(-1, 1)

        self.qtgui_time_sink_x_0.set_y_label('Amplitude', "")

        self.qtgui_time_sink_x_0.enable_tags(-1, True)
        self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_AUTO,
                                                  qtgui.TRIG_SLOPE_POS, 0.0, 0,
                                                  0, "")
        self.qtgui_time_sink_x_0.enable_autoscale(False)
        self.qtgui_time_sink_x_0.enable_grid(False)
        self.qtgui_time_sink_x_0.enable_axis_labels(True)
        self.qtgui_time_sink_x_0.enable_control_panel(False)
        self.qtgui_time_sink_x_0.enable_stem_plot(False)

        if not True:
            self.qtgui_time_sink_x_0.disable_legend()

        labels = ['LPF', 'Slicer', '', '', '', '', '', '', '', '']
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "green", "black", "cyan", "magenta", "yellow",
            "dark red", "dark green", "blue"
        ]
        styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]

        for i in xrange(2):
            if len(labels[i]) == 0:
                self.qtgui_time_sink_x_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_0.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_0.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i])

        self._qtgui_time_sink_x_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_win)
        self.qtgui_freq_sink_x_0_0 = qtgui.freq_sink_c(
            1024,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate,  #bw
            "",  #name
            2  #number of inputs
        )
        self.qtgui_freq_sink_x_0_0.set_update_time(0.10)
        self.qtgui_freq_sink_x_0_0.set_y_axis(-140, 10)
        self.qtgui_freq_sink_x_0_0.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0,
                                                    0, "")
        self.qtgui_freq_sink_x_0_0.enable_autoscale(False)
        self.qtgui_freq_sink_x_0_0.enable_grid(False)
        self.qtgui_freq_sink_x_0_0.set_fft_average(1.0)
        self.qtgui_freq_sink_x_0_0.enable_axis_labels(True)
        self.qtgui_freq_sink_x_0_0.enable_control_panel(False)

        if not True:
            self.qtgui_freq_sink_x_0_0.disable_legend()

        if "complex" == "float" or "complex" == "msg_float":
            self.qtgui_freq_sink_x_0_0.set_plot_pos_half(not True)

        labels = ['Raw', 'Shifted to zero', '', '', '', '', '', '', '', '']
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "green", "black", "cyan", "magenta", "yellow",
            "dark red", "dark green", "dark blue"
        ]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(2):
            if len(labels[i]) == 0:
                self.qtgui_freq_sink_x_0_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_freq_sink_x_0_0.set_line_label(i, labels[i])
            self.qtgui_freq_sink_x_0_0.set_line_width(i, widths[i])
            self.qtgui_freq_sink_x_0_0.set_line_color(i, colors[i])
            self.qtgui_freq_sink_x_0_0.set_line_alpha(i, alphas[i])

        self._qtgui_freq_sink_x_0_0_win = sip.wrapinstance(
            self.qtgui_freq_sink_x_0_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_0_win)
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_f(
            1024,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate,  #bw
            "",  #name
            1  #number of inputs
        )
        self.qtgui_freq_sink_x_0.set_update_time(0.10)
        self.qtgui_freq_sink_x_0.set_y_axis(-140, 10)
        self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0,
                                                  "")
        self.qtgui_freq_sink_x_0.enable_autoscale(False)
        self.qtgui_freq_sink_x_0.enable_grid(False)
        self.qtgui_freq_sink_x_0.set_fft_average(1.0)
        self.qtgui_freq_sink_x_0.enable_axis_labels(True)
        self.qtgui_freq_sink_x_0.enable_control_panel(False)

        if not True:
            self.qtgui_freq_sink_x_0.disable_legend()

        if "float" == "float" or "float" == "msg_float":
            self.qtgui_freq_sink_x_0.set_plot_pos_half(not False)

        labels = ['', '', '', '', '', '', '', '', '', '']
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "green", "black", "cyan", "magenta", "yellow",
            "dark red", "dark green", "dark blue"
        ]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_freq_sink_x_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_freq_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_freq_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_freq_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i])

        self._qtgui_freq_sink_x_0_win = sip.wrapinstance(
            self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win)
        self.low_pass_filter_0 = filter.fir_filter_fff(
            decimation,
            firdes.low_pass(4, samp_rate, bps * 3, bps, firdes.WIN_BLACKMAN,
                            6.76))
        self.gr_wavfile_source_0 = blocks.wavfile_source(
            'D:\\gnuradio\\vs\\gr-rtty\\apps\\rtty_audio.wav', True)
        self.gr_quadrature_demod_cf_0 = analog.quadrature_demod_cf(4)
        self.gr_hilbert_fc_0 = filter.hilbert_fc(65, firdes.WIN_BLACKMAN, 6.76)
        self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(
            1, ([1]), 555 + (170 / 2), samp_rate)
        self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb()
        self.blocks_uchar_to_float_1 = blocks.uchar_to_float()
        self.audio_sink_0 = audio.sink(48000, '', True)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_uchar_to_float_1, 0),
                     (self.qtgui_time_sink_x_0, 1))
        self.connect((self.blocks_uchar_to_float_1, 0),
                     (self.rtty_decode_ff_0, 0))
        self.connect((self.digital_binary_slicer_fb_0, 0),
                     (self.blocks_uchar_to_float_1, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0),
                     (self.gr_quadrature_demod_cf_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0),
                     (self.qtgui_freq_sink_x_0_0, 1))
        self.connect((self.gr_hilbert_fc_0, 0),
                     (self.freq_xlating_fir_filter_xxx_0, 0))
        self.connect((self.gr_hilbert_fc_0, 0),
                     (self.qtgui_freq_sink_x_0_0, 0))
        self.connect((self.gr_quadrature_demod_cf_0, 0),
                     (self.low_pass_filter_0, 0))
        self.connect((self.gr_wavfile_source_0, 0), (self.gr_hilbert_fc_0, 0))
        self.connect((self.gr_wavfile_source_0, 0),
                     (self.qtgui_freq_sink_x_0, 0))
        self.connect((self.gr_wavfile_source_0, 0),
                     (self.rational_resampler_xxx_0, 0))
        self.connect((self.low_pass_filter_0, 0),
                     (self.digital_binary_slicer_fb_0, 0))
        self.connect((self.low_pass_filter_0, 0),
                     (self.qtgui_time_sink_x_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.audio_sink_0, 0))
        self.connect((self.rtty_decode_ff_0, 0), (self.show_text_0, 0))
Exemple #44
0
    def __init__(self):
        gr.top_block.__init__(self, "NOAA Demo based on PFB Channelizer Demo")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("NOAA Demo based on PFB Channelizer Demo")
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

        self.settings = Qt.QSettings("GNU Radio", "noaa_demo")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.noaa_num_chans = noaa_num_chans = 7
        self.noaa_chan_width = noaa_chan_width = int(25e3)
        self.noaa_band_start = noaa_band_start = 162.4e6
        self.oversampled_width = oversampled_width = noaa_chan_width * (
            noaa_num_chans + 1)
        self.noaa_fm_dev = noaa_fm_dev = int(5e3)
        self.noaa_band_center = noaa_band_center = noaa_band_start + (
            noaa_num_chans / 2 * noaa_chan_width)
        self.hardware_rate = hardware_rate = int(1e6)
        self.tuner_freq = tuner_freq = 162.3e6
        self.target_freq = target_freq = noaa_band_center
        self.ppm = ppm = 0
        self.pfb_taps = pfb_taps = firdes.low_pass(2.0, oversampled_width,
                                                   noaa_fm_dev * 2, 1000,
                                                   firdes.WIN_HAMMING, 6.76)
        self.lpf_taps = lpf_taps = firdes.low_pass(1.0, hardware_rate,
                                                   oversampled_width / 2,
                                                   noaa_chan_width,
                                                   firdes.WIN_HAMMING, 6.76)
        self.channel_map = channel_map = range(0, noaa_num_chans)
        self.volume = volume = 0.15
        self.tuner_offset = tuner_offset = target_freq - tuner_freq
        self.ppm_corr = ppm_corr = tuner_freq * (ppm / 1e6)
        self.pfb_sizeof_taps = pfb_sizeof_taps = len(pfb_taps)
        self.noaa_band_width = noaa_band_width = noaa_chan_width * noaa_num_chans
        self.noaa_band_end = noaa_band_end = noaa_band_start + (
            noaa_num_chans * noaa_chan_width)
        self.lpf_sizeof_taps = lpf_sizeof_taps = len(lpf_taps)
        self.fftwidth = fftwidth = 512
        self.fft_interval = fft_interval = 1.0 / 20
        self.decimation = decimation = hardware_rate / oversampled_width
        self.channelizer_map = channelizer_map = 5, 6, 7, 0, 1, 2, 3
        self.channel_names = channel_names = map(
            lambda x: "%.3fMHz" % (162.4 + (x * 0.025)), channel_map)
        self.chan_num = chan_num = channel_map[6]

        ##################################################
        # Blocks
        ##################################################
        self._volume_layout = Qt.QVBoxLayout()
        self._volume_label = Qt.QLabel("volume")
        self._volume_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal,
                                            Qwt.QwtSlider.BottomScale,
                                            Qwt.QwtSlider.BgSlot)
        self._volume_slider.setRange(0, 1, 0.05)
        self._volume_slider.setValue(self.volume)
        self._volume_slider.setMinimumWidth(50)
        self._volume_slider.valueChanged.connect(self.set_volume)
        self._volume_label.setAlignment(Qt.Qt.AlignBottom | Qt.Qt.AlignHCenter)
        self._volume_layout.addWidget(self._volume_label)
        self._volume_layout.addWidget(self._volume_slider)
        self.top_grid_layout.addLayout(self._volume_layout, 0, 1, 1, 1)
        self._chan_num_options = channel_map
        self._chan_num_labels = channel_names
        self._chan_num_tool_bar = Qt.QToolBar(self)
        self._chan_num_tool_bar.addWidget(Qt.QLabel("Channel" + ": "))
        self._chan_num_combo_box = Qt.QComboBox()
        self._chan_num_tool_bar.addWidget(self._chan_num_combo_box)
        for label in self._chan_num_labels:
            self._chan_num_combo_box.addItem(label)
        self._chan_num_callback = lambda i: Qt.QMetaObject.invokeMethod(
            self._chan_num_combo_box, "setCurrentIndex",
            Qt.Q_ARG("int", self._chan_num_options.index(i)))
        self._chan_num_callback(self.chan_num)
        self._chan_num_combo_box.currentIndexChanged.connect(
            lambda i: self.set_chan_num(self._chan_num_options[i]))
        self.top_grid_layout.addWidget(self._chan_num_tool_bar, 0, 0, 1, 1)
        self.uhd_usrp_source_0 = uhd.usrp_source(
            ",".join(("", "")),
            uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ),
        )
        self.uhd_usrp_source_0.set_clock_source("external", 0)
        self.uhd_usrp_source_0.set_subdev_spec("A:0", 0)
        self.uhd_usrp_source_0.set_samp_rate(hardware_rate)
        self.uhd_usrp_source_0.set_center_freq(tuner_freq, 0)
        self.uhd_usrp_source_0.set_gain(30, 0)
        self.uhd_usrp_source_0.set_antenna("TX/RX", 0)
        self.rational_resampler_xxx_0 = filter.rational_resampler_fff(
            interpolation=48,
            decimation=25,
            taps=None,
            fractional_bw=None,
        )
        self.qtgui_sink_x_0_0 = qtgui.sink_c(
            1024,  #fftsize
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            hardware_rate,  #bw
            "Radoi Samples",  #name
            True,  #plotfreq
            False,  #plotwaterfall
            False,  #plottime
            False,  #plotconst
        )
        self.qtgui_sink_x_0_0.set_update_time(1.0 / 10)
        self._qtgui_sink_x_0_0_win = sip.wrapinstance(
            self.qtgui_sink_x_0_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_sink_x_0_0_win)

        self.qtgui_sink_x_0_0.enable_rf_freq(False)

        self.qtgui_sink_x_0 = qtgui.sink_c(
            1024,  #fftsize
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            hardware_rate / decimation,  #bw
            "Filtered Samples",  #name
            True,  #plotfreq
            False,  #plotwaterfall
            False,  #plottime
            False,  #plotconst
        )
        self.qtgui_sink_x_0.set_update_time(1.0 / 10)
        self._qtgui_sink_x_0_win = sip.wrapinstance(
            self.qtgui_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_sink_x_0_win)

        self.qtgui_sink_x_0.enable_rf_freq(False)

        self._ppm_layout = Qt.QVBoxLayout()
        self._ppm_label = Qt.QLabel("ppm")
        self._ppm_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal,
                                         Qwt.QwtSlider.BottomScale,
                                         Qwt.QwtSlider.BgSlot)
        self._ppm_slider.setRange(-20, 20, 0.5)
        self._ppm_slider.setValue(self.ppm)
        self._ppm_slider.setMinimumWidth(50)
        self._ppm_slider.valueChanged.connect(self.set_ppm)
        self._ppm_label.setAlignment(Qt.Qt.AlignBottom | Qt.Qt.AlignHCenter)
        self._ppm_layout.addWidget(self._ppm_label)
        self._ppm_layout.addWidget(self._ppm_slider)
        self.top_grid_layout.addLayout(self._ppm_layout, 0, 2, 1, 1)
        self.pfb_channelizer_ccf_0 = pfb.channelizer_ccf(
            noaa_num_chans + 1, (pfb_taps), 1, 1)
        self.pfb_channelizer_ccf_0.set_channel_map((channelizer_map))
        self.pfb_channelizer_ccf_0.declare_sample_delay(0)

        self.freq_xlating_fft_filter_ccc_0 = filter.freq_xlating_fft_filter_ccc(
            int(decimation), (lpf_taps), tuner_offset + ppm_corr,
            hardware_rate)
        self.freq_xlating_fft_filter_ccc_0.set_nthreads(1)
        self.freq_xlating_fft_filter_ccc_0.declare_sample_delay(0)
        self.blocks_multiply_const_vxx_0_7 = blocks.multiply_const_vcc((50, ))
        self.blocks_multiply_const_vxx_0_6_0 = blocks.multiply_const_vff(
            (volume, ))
        self.blocks_multiply_const_vxx_0_6 = blocks.multiply_const_vcc((10, ))
        self.blocks_multiply_const_vxx_0_5_0 = blocks.multiply_const_vcc(
            (1 if chan_num is 7 else 0, ))
        self.blocks_multiply_const_vxx_0_5 = blocks.multiply_const_vcc(
            (1 if chan_num is 6 else 0, ))
        self.blocks_multiply_const_vxx_0_4 = blocks.multiply_const_vcc(
            (1 if chan_num is 5 else 0, ))
        self.blocks_multiply_const_vxx_0_3 = blocks.multiply_const_vcc(
            (1 if chan_num is 4 else 0, ))
        self.blocks_multiply_const_vxx_0_2 = blocks.multiply_const_vcc(
            (1 if chan_num is 3 else 0, ))
        self.blocks_multiply_const_vxx_0_1 = blocks.multiply_const_vcc(
            (1 if chan_num is 2 else 0, ))
        self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vcc(
            (1 if chan_num is 1 else 0, ))
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc(
            (1 if chan_num is 0 else 0, ))
        self.blocks_add_xx_0 = blocks.add_vcc(1)
        self.audio_sink_0 = audio.sink(48000, "", True)
        self.analog_nbfm_rx_0 = analog.nbfm_rx(
            audio_rate=noaa_chan_width,
            quad_rate=noaa_chan_width,
            tau=75e-6,
            max_dev=noaa_fm_dev,
        )

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_nbfm_rx_0, 0),
                     (self.rational_resampler_xxx_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.blocks_add_xx_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0_0, 0),
                     (self.blocks_add_xx_0, 1))
        self.connect((self.blocks_multiply_const_vxx_0_1, 0),
                     (self.blocks_add_xx_0, 2))
        self.connect((self.blocks_multiply_const_vxx_0_2, 0),
                     (self.blocks_add_xx_0, 3))
        self.connect((self.blocks_multiply_const_vxx_0_3, 0),
                     (self.blocks_add_xx_0, 4))
        self.connect((self.blocks_multiply_const_vxx_0_4, 0),
                     (self.blocks_add_xx_0, 5))
        self.connect((self.blocks_multiply_const_vxx_0_5, 0),
                     (self.blocks_add_xx_0, 6))
        self.connect((self.blocks_multiply_const_vxx_0_5_0, 0),
                     (self.blocks_add_xx_0, 7))
        self.connect((self.blocks_multiply_const_vxx_0_6, 0),
                     (self.analog_nbfm_rx_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0_6_0, 0),
                     (self.audio_sink_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0_7, 0),
                     (self.qtgui_sink_x_0_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.blocks_multiply_const_vxx_0_6_0, 0))
        self.connect((self.uhd_usrp_source_0, 0),
                     (self.blocks_multiply_const_vxx_0_7, 0))
        self.connect((self.blocks_multiply_const_vxx_0_7, 0),
                     (self.freq_xlating_fft_filter_ccc_0, 0))
        self.connect((self.freq_xlating_fft_filter_ccc_0, 0),
                     (self.pfb_channelizer_ccf_0, 0))
        self.connect((self.freq_xlating_fft_filter_ccc_0, 0),
                     (self.qtgui_sink_x_0, 0))
        self.connect((self.blocks_add_xx_0, 0),
                     (self.blocks_multiply_const_vxx_0_6, 0))
        self.connect((self.pfb_channelizer_ccf_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.pfb_channelizer_ccf_0, 1),
                     (self.blocks_multiply_const_vxx_0_0, 0))
        self.connect((self.pfb_channelizer_ccf_0, 2),
                     (self.blocks_multiply_const_vxx_0_1, 0))
        self.connect((self.pfb_channelizer_ccf_0, 3),
                     (self.blocks_multiply_const_vxx_0_2, 0))
        self.connect((self.pfb_channelizer_ccf_0, 4),
                     (self.blocks_multiply_const_vxx_0_3, 0))
        self.connect((self.pfb_channelizer_ccf_0, 5),
                     (self.blocks_multiply_const_vxx_0_4, 0))
        self.connect((self.pfb_channelizer_ccf_0, 6),
                     (self.blocks_multiply_const_vxx_0_5, 0))
        self.connect((self.pfb_channelizer_ccf_0, 7),
                     (self.blocks_multiply_const_vxx_0_5_0, 0))
Exemple #45
0
    def __init__(self):
        gr.top_block.__init__(self, "Top Block")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Top Block")
        qtgui.util.check_set_qss()
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

        self.settings = Qt.QSettings("GNU Radio", "top_block")

        if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"):
            self.restoreGeometry(self.settings.value("geometry").toByteArray())
        else:
            self.restoreGeometry(
                self.settings.value("geometry", type=QtCore.QByteArray))

        ##################################################
        # Variables
        ##################################################
        self.ssCVSD = ssCVSD = 2
        self.payload = payload = 128
        self.nbConst = nbConst = 64
        self.bwCVSD = bwCVSD = 0.3

        ##################################################
        # Blocks
        ##################################################
        self.vocoder_cvsd_encode_fb_0 = vocoder.cvsd_encode_fb(ssCVSD, bwCVSD)
        self.vocoder_cvsd_decode_bf_0 = vocoder.cvsd_decode_bf(ssCVSD, bwCVSD)
        self.rational_resampler_xxx_0 = filter.rational_resampler_fff(
            interpolation=1,
            decimation=1,
            taps=None,
            fractional_bw=None,
        )
        self.digital_ofdm_tx_0 = digital.ofdm_tx(
            fft_len=64,
            cp_len=16,
            packet_length_tag_key="packet_len",
            bps_header=1,
            bps_payload=1,
            rolloff=0,
            debug_log=False,
            scramble_bits=False)
        self.digital_ofdm_rx_0 = digital.ofdm_rx(
            fft_len=64,
            cp_len=16,
            frame_length_tag_key='frame_' + "packet_len",
            packet_length_tag_key="packet_len",
            bps_header=1,
            bps_payload=1,
            debug_log=False,
            scramble_bits=False)
        self.blocks_wavfile_source_1 = blocks.wavfile_source(
            '/home/tarnagda/Documents/Transmission/WAVs/streetwave.wav', True)
        self.blocks_tag_gate_0 = blocks.tag_gate(gr.sizeof_gr_complex * 1,
                                                 False)
        self.blocks_stream_to_tagged_stream_0 = blocks.stream_to_tagged_stream(
            gr.sizeof_char, 1, payload, "packet_len")
        self.audio_sink_0 = audio.sink(44100, '', True)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_stream_to_tagged_stream_0, 0),
                     (self.digital_ofdm_tx_0, 0))
        self.connect((self.blocks_tag_gate_0, 0), (self.digital_ofdm_rx_0, 0))
        self.connect((self.blocks_wavfile_source_1, 0),
                     (self.vocoder_cvsd_encode_fb_0, 0))
        self.connect((self.digital_ofdm_rx_0, 0),
                     (self.vocoder_cvsd_decode_bf_0, 0))
        self.connect((self.digital_ofdm_tx_0, 0), (self.blocks_tag_gate_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.audio_sink_0, 0))
        self.connect((self.vocoder_cvsd_decode_bf_0, 0),
                     (self.rational_resampler_xxx_0, 0))
        self.connect((self.vocoder_cvsd_encode_fb_0, 0),
                     (self.blocks_stream_to_tagged_stream_0, 0))
Exemple #46
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="[FG]MRS Receiver")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 1e6
        self.channel_width = channel_width = 25e3
        self.rf_freq_mhz = rf_freq_mhz = 462.5625
        self.decimation = decimation = int(samp_rate/channel_width)
        self.squelch = squelch = -20
        self.spec_size = spec_size = 480,256
        self.rf_freq = rf_freq = rf_freq_mhz*1.0e6
        self.decimated_rate = decimated_rate = samp_rate/decimation
        self.center_freq = center_freq = (int(rf_freq_mhz)+0.5)*1e6
        self.cctss_freq = cctss_freq = 0
        self.audio_rate = audio_rate = int(11025)

        ##################################################
        # Blocks
        ##################################################
        _squelch_sizer = wx.BoxSizer(wx.VERTICAL)
        self._squelch_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_squelch_sizer,
        	value=self.squelch,
        	callback=self.set_squelch,
        	label="Squelch (dBm)",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._squelch_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_squelch_sizer,
        	value=self.squelch,
        	callback=self.set_squelch,
        	minimum=-50,
        	maximum=0,
        	num_steps=50,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_squelch_sizer, 3, 3, 1, 2)
        self._cctss_freq_chooser = forms.drop_down(
        	parent=self.GetWin(),
        	value=self.cctss_freq,
        	callback=self.set_cctss_freq,
        	label="Privacy Code",
        	choices=[0,67.0,71.9,74.4,77.0,79.7,82.5,85.4,88.5,91.5,94.8,97.4,100.0,103.5,107.2,110.9,114.8,118.8,123.0,127.3,131.8,136.5,141.3,146.2,151.4,156.7,162.2,167.9,173.8,179.9,186.2,192.8,203.5,210.7,218.1,225.7,233.7,241.8,250.3],
        	labels=['0 (Monitor)',1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38],
        )
        self.GridAdd(self._cctss_freq_chooser, 3, 2, 1, 1)
        self.wxgui_waterfallsink2_1_0 = waterfallsink2.waterfall_sink_f(
        	self.GetWin(),
        	baseband_freq=0,
        	dynamic_range=40,
        	ref_level=-25,
        	ref_scale=2.0,
        	sample_rate=audio_rate,
        	fft_size=512,
        	fft_rate=15,
        	average=False,
        	avg_alpha=None,
        	title="Raw Audio Spectrum",
        	size=(spec_size),
        )
        self.GridAdd(self.wxgui_waterfallsink2_1_0.win, 2, 4, 1, 3)
        self.wxgui_waterfallsink2_1 = waterfallsink2.waterfall_sink_f(
        	self.GetWin(),
        	baseband_freq=0,
        	dynamic_range=40,
        	ref_level=-25,
        	ref_scale=2.0,
        	sample_rate=audio_rate,
        	fft_size=512,
        	fft_rate=15,
        	average=False,
        	avg_alpha=None,
        	title="Squelched Audio Spectrum",
        	size=(spec_size),
        )
        self.GridAdd(self.wxgui_waterfallsink2_1.win, 2, 1, 1, 3)
        self.wxgui_waterfallsink2_0_0 = waterfallsink2.waterfall_sink_c(
        	self.GetWin(),
        	baseband_freq=center_freq,
        	dynamic_range=40,
        	ref_level=-25,
        	ref_scale=2.0,
        	sample_rate=samp_rate,
        	fft_size=512,
        	fft_rate=15,
        	average=False,
        	avg_alpha=None,
        	title="RF Spectrum",
        	size=(spec_size),
        )
        self.GridAdd(self.wxgui_waterfallsink2_0_0.win, 1, 1, 1, 3)
        self.wxgui_waterfallsink2_0 = waterfallsink2.waterfall_sink_c(
        	self.GetWin(),
        	baseband_freq=0,
        	dynamic_range=40,
        	ref_level=-25,
        	ref_scale=2.0,
        	sample_rate=samp_rate,
        	fft_size=512,
        	fft_rate=15,
        	average=False,
        	avg_alpha=None,
        	title="Baseband Spectrum",
        	size=(spec_size),
        )
        self.GridAdd(self.wxgui_waterfallsink2_0.win, 1, 4, 1, 3)
        self._rf_freq_mhz_chooser = forms.drop_down(
        	parent=self.GetWin(),
        	value=self.rf_freq_mhz,
        	callback=self.set_rf_freq_mhz,
        	label="Channel",
        	choices=[462.5625, 462.5875, 462.6125, 462.6375, 462.6625, 462.6875, 462.7125, 467.5625, 467.5875, 467.6125, 467.6375, 467.6625, 467.6875, 467.7125, 462.550, 462.575, 462.600, 462.625,462.650,462.675,462.700, 462.725],
        	labels=['FRS1 / GMRS 9',2,3,4,5,6,'FRS7 / GMRS15 ','FRS8',9,10,11,12,13,'FRS14','GMRS1',2,3,4,5,6,7,'GMRS8'],
        )
        self.GridAdd(self._rf_freq_mhz_chooser, 3, 1, 1, 1)
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
                interpolation=int(audio_rate),
                decimation=int(decimated_rate),
                taps=None,
                fractional_bw=None,
        )
        self.osmosdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + "" )
        self.osmosdr_source_0.set_sample_rate(samp_rate)
        self.osmosdr_source_0.set_center_freq(center_freq, 0)
        self.osmosdr_source_0.set_freq_corr(0, 0)
        self.osmosdr_source_0.set_dc_offset_mode(0, 0)
        self.osmosdr_source_0.set_iq_balance_mode(0, 0)
        self.osmosdr_source_0.set_gain_mode(True, 0)
        self.osmosdr_source_0.set_gain(10, 0)
        self.osmosdr_source_0.set_if_gain(20, 0)
        self.osmosdr_source_0.set_bb_gain(20, 0)
        self.osmosdr_source_0.set_antenna("", 0)
        self.osmosdr_source_0.set_bandwidth(0, 0)
          
        self.low_pass_filter_0 = filter.fir_filter_ccf(decimation, firdes.low_pass(
        	1, samp_rate, decimated_rate*0.8, decimated_rate*0.2, firdes.WIN_HAMMING, 6.76))
        self.dc_blocker_xx_0 = filter.dc_blocker_cc(32, True)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.audio_sink_0 = audio.sink(audio_rate, "", True)
        self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, rf_freq, 1, 0)
        self.analog_pwr_squelch_xx_0 = analog.pwr_squelch_ff(squelch, 0.0001, 1, False)
        self.analog_nbfm_rx_0 = analog.nbfm_rx(
        	audio_rate=audio_rate,
        	quad_rate=audio_rate,
        	tau=75e-6,
        	max_dev=5e3,
        )
        self.analog_ctcss_squelch_ff_0 = analog.ctcss_squelch_ff(audio_rate, cctss_freq, 0.01, 0, 1, False)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0), (self.low_pass_filter_0, 0))
        self.connect((self.low_pass_filter_0, 0), (self.rational_resampler_xxx_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0), (self.analog_nbfm_rx_0, 0))
        self.connect((self.analog_nbfm_rx_0, 0), (self.wxgui_waterfallsink2_1_0, 0))
        self.connect((self.analog_nbfm_rx_0, 0), (self.analog_ctcss_squelch_ff_0, 0))
        self.connect((self.analog_ctcss_squelch_ff_0, 0), (self.analog_pwr_squelch_xx_0, 0))
        self.connect((self.analog_pwr_squelch_xx_0, 0), (self.audio_sink_0, 0))
        self.connect((self.analog_pwr_squelch_xx_0, 0), (self.wxgui_waterfallsink2_1, 0))
        self.connect((self.blocks_multiply_xx_0, 0), (self.wxgui_waterfallsink2_0, 0))
        self.connect((self.osmosdr_source_0, 0), (self.dc_blocker_xx_0, 0))
        self.connect((self.dc_blocker_xx_0, 0), (self.wxgui_waterfallsink2_0_0, 0))
        self.connect((self.dc_blocker_xx_0, 0), (self.blocks_multiply_xx_0, 1))
    def __init__(self):
        gr.top_block.__init__(self, "Aprs Rxtx")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Aprs Rxtx")
        qtgui.util.check_set_qss()
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

        self.settings = Qt.QSettings("GNU Radio", "aprs_rxtx")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 44100

        ##################################################
        # Blocks
        ##################################################
        self.qtgui_time_sink_x_0 = qtgui.time_sink_f(
            1024,  #size
            samp_rate,  #samp_rate
            "",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0.set_y_axis(-1, 1)

        self.qtgui_time_sink_x_0.set_y_label('Amplitude', "")

        self.qtgui_time_sink_x_0.enable_tags(-1, True)
        self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE,
                                                  qtgui.TRIG_SLOPE_POS, 0.0, 0,
                                                  0, "")
        self.qtgui_time_sink_x_0.enable_autoscale(False)
        self.qtgui_time_sink_x_0.enable_grid(False)
        self.qtgui_time_sink_x_0.enable_axis_labels(True)
        self.qtgui_time_sink_x_0.enable_control_panel(False)

        if not True:
            self.qtgui_time_sink_x_0.disable_legend()

        labels = ['', '', '', '', '', '', '', '', '', '']
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "green", "black", "cyan", "magenta", "yellow",
            "dark red", "dark green", "blue"
        ]
        styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]

        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_time_sink_x_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_0.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_0.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i])

        self._qtgui_time_sink_x_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_win)
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_f(
            1024,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate,  #bw
            "",  #name
            1  #number of inputs
        )
        self.qtgui_freq_sink_x_0.set_update_time(0.10)
        self.qtgui_freq_sink_x_0.set_y_axis(-140, 10)
        self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0,
                                                  "")
        self.qtgui_freq_sink_x_0.enable_autoscale(False)
        self.qtgui_freq_sink_x_0.enable_grid(False)
        self.qtgui_freq_sink_x_0.set_fft_average(1.0)
        self.qtgui_freq_sink_x_0.enable_axis_labels(True)
        self.qtgui_freq_sink_x_0.enable_control_panel(False)

        if not True:
            self.qtgui_freq_sink_x_0.disable_legend()

        if "float" == "float" or "float" == "msg_float":
            self.qtgui_freq_sink_x_0.set_plot_pos_half(not True)

        labels = ['', '', '', '', '', '', '', '', '', '']
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "green", "black", "cyan", "magenta", "yellow",
            "dark red", "dark green", "dark blue"
        ]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_freq_sink_x_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_freq_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_freq_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_freq_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i])

        self._qtgui_freq_sink_x_0_win = sip.wrapinstance(
            self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win)
        self.bruninga_str_to_aprs_0 = bruninga.str_to_aprs(
            'NOCALL', 'NOCALL', [])
        self.bruninga_ax25_fsk_mod_0 = bruninga.ax25_fsk_mod(
            samp_rate, 300, 10, 2200, 1200, 1200)
        self.blocks_wavfile_sink_0 = blocks.wavfile_sink(
            '/home/ben-mccall/Desktop/flowgraphs/TJ_APRS/afsk_audio_files/gr_bruninga_helloworld2.wav',
            1, samp_rate, 16)
        self.blocks_socket_pdu_0 = blocks.socket_pdu("UDP_SERVER", '', '5577',
                                                     10000, False)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((0.1, ))
        self.audio_sink_0 = audio.sink(44100, 'hw:1,0', True)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_socket_pdu_0, 'pdus'),
                         (self.bruninga_str_to_aprs_0, 'in'))
        self.msg_connect((self.bruninga_str_to_aprs_0, 'out'),
                         (self.bruninga_ax25_fsk_mod_0, 'in'))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.audio_sink_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.blocks_wavfile_sink_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.qtgui_freq_sink_x_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.qtgui_time_sink_x_0, 0))
        self.connect((self.bruninga_ax25_fsk_mod_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
Exemple #48
0
    def __init__(self, frame, panel, vbox, argv):
        stdgui2.std_top_block.__init__(self, frame, panel, vbox, argv)

        parser = OptionParser(option_class=eng_option)
        parser.add_option("-a",
                          "--args",
                          type="string",
                          default="",
                          help="UHD device address args, [default=%default]")
        parser.add_option("",
                          "--spec",
                          type="string",
                          default=None,
                          help="Subdevice of UHD device where appropriate")
        parser.add_option("-A",
                          "--antenna",
                          type="string",
                          default=None,
                          help="select Rx Antenna where appropriate")
        parser.add_option("-f",
                          "--freq",
                          type="eng_float",
                          default=137.5e6,
                          help="set frequency to FREQ",
                          metavar="FREQ")
        parser.add_option("-g",
                          "--gain",
                          type="eng_float",
                          default=None,
                          help="set gain in dB (default is midpoint)")
        parser.add_option("-V",
                          "--volume",
                          type="eng_float",
                          default=None,
                          help="set volume (default is midpoint)")
        parser.add_option(
            "-O",
            "--audio-output",
            type="string",
            default="default",
            help="pcm device name.  E.g., hw:0,0 or surround51 or /dev/dsp")
        parser.add_option("",
                          "--freq-min",
                          type="eng_float",
                          default=137e6,
                          help="Set a minimum frequency [default=%default]")
        parser.add_option("",
                          "--freq-max",
                          type="eng_float",
                          default=138e6,
                          help="Set a maximum frequency [default=%default]")

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

        self.frame = frame
        self.panel = panel

        self.vol = 0
        self.state = "FREQ"
        self.freq = 0

        self.freq_min = options.freq_min
        self.freq_max = options.freq_max

        # build graph
        self.u = uhd.usrp_source(device_addr=options.args,
                                 stream_args=uhd.stream_args('fc32'))

        # Set the subdevice spec
        if (options.spec):
            self.u.set_subdev_spec(options.spec, 0)

        # Set the antenna
        if (options.antenna):
            self.u.set_antenna(options.antenna, 0)

        usrp_rate = 320e3
        demod_rate = 320e3
        audio_rate = 32e3
        audio_decim = int(demod_rate / audio_rate)

        self.u.set_samp_rate(usrp_rate)
        dev_rate = self.u.get_samp_rate()

        nfilts = 32
        chan_coeffs = gr.firdes.low_pass_2(
            nfilts,  # gain
            nfilts * usrp_rate,  # sampling rate
            40e3,  # passband cutoff
            20e3,  # transition bw
            60)  # stopband attenuation
        rrate = usrp_rate / dev_rate
        self.chan_filt = blks2.pfb_arb_resampler_ccf(rrate, chan_coeffs,
                                                     nfilts)

        self.guts = blks2.wfm_rcv(demod_rate, audio_decim)

        self.volume_control = gr.multiply_const_ff(self.vol)

        # sound card as final sink
        self.audio_sink = audio.sink(int(audio_rate), options.audio_output)

        # now wire it all together
        self.connect(self.u, self.chan_filt, self.guts, self.volume_control,
                     self.audio_sink)

        self._build_gui(vbox, usrp_rate, demod_rate, audio_rate)

        if options.gain is None:
            # if no gain was specified, use the mid-point in dB
            g = self.u.get_gain_range()
            options.gain = float(g.start() + g.stop()) / 2.0

        if options.volume is None:
            g = self.volume_range()
            options.volume = float(g[0] + g[1]) / 2

        frange = self.u.get_freq_range()
        if (frange.start() > self.freq_max or frange.stop() < self.freq_min):
            sys.stderr.write(
                "Radio does not support required frequency range.\n")
            sys.exit(1)
        if (options.freq < self.freq_min or options.freq > self.freq_max):
            sys.stderr.write(
                "Requested frequency is outside of required frequency range.\n"
            )
            sys.exit(1)

        # set initial values
        self.set_gain(options.gain)
        self.set_vol(options.volume)
        if not (self.set_freq(options.freq)):
            self._set_status_msg("Failed to set initial frequency")
Exemple #49
0
    def __init__(self):
        gr.top_block.__init__(self, "Top Block")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Top Block")
        qtgui.util.check_set_qss()
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

        self.settings = Qt.QSettings("GNU Radio", "top_block")

        if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"):
            self.restoreGeometry(self.settings.value("geometry").toByteArray())
        else:
            self.restoreGeometry(
                self.settings.value("geometry", type=QtCore.QByteArray))

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 32000
        self.mute_enable = mute_enable = 0
        self.attenuation = attenuation = 1

        ##################################################
        # Blocks
        ##################################################
        self._attenuation_range = Range(0, 1, 0.001, 1, 200)
        self._attenuation_win = RangeWidget(self._attenuation_range,
                                            self.set_attenuation,
                                            "attenuation", "counter_slider",
                                            float)
        self.top_layout.addWidget(self._attenuation_win)
        self.qtgui_time_sink_x_0 = qtgui.time_sink_c(
            512,  #size
            samp_rate,  #samp_rate
            "Frequency Modulated Mozart",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0.set_y_axis(-1, 1)

        self.qtgui_time_sink_x_0.set_y_label('Amplitude', "")

        self.qtgui_time_sink_x_0.enable_tags(-1, True)
        self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE,
                                                  qtgui.TRIG_SLOPE_POS, 0.0, 0,
                                                  0, "")
        self.qtgui_time_sink_x_0.enable_autoscale(False)
        self.qtgui_time_sink_x_0.enable_grid(False)
        self.qtgui_time_sink_x_0.enable_axis_labels(True)
        self.qtgui_time_sink_x_0.enable_control_panel(False)
        self.qtgui_time_sink_x_0.enable_stem_plot(False)

        if not True:
            self.qtgui_time_sink_x_0.disable_legend()

        labels = ['', '', '', '', '', '', '', '', '', '']
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "green", "black", "cyan", "magenta", "yellow",
            "dark red", "dark green", "blue"
        ]
        styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]

        for i in xrange(2):
            if len(labels[i]) == 0:
                if (i % 2 == 0):
                    self.qtgui_time_sink_x_0.set_line_label(
                        i, "Re{{Data {0}}}".format(i / 2))
                else:
                    self.qtgui_time_sink_x_0.set_line_label(
                        i, "Im{{Data {0}}}".format(i / 2))
            else:
                self.qtgui_time_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_0.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_0.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i])

        self._qtgui_time_sink_x_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_time_sink_x_0_win)
        _mute_enable_push_button = Qt.QPushButton("mute_enable")
        self._mute_enable_choices = {'Pressed': 1, 'Released': 0}
        _mute_enable_push_button.pressed.connect(
            lambda: self.set_mute_enable(self._mute_enable_choices['Pressed']))
        _mute_enable_push_button.released.connect(lambda: self.set_mute_enable(
            self._mute_enable_choices['Released']))
        self.top_layout.addWidget(_mute_enable_push_button)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc(
            (attenuation, ))
        self.basic_basicsink_py_c_0 = basic.basicsink_py_c()
        self.audio_sink_0 = audio.sink(samp_rate, '', True)
        self.analog_sig_source_x_1 = analog.sig_source_c(
            samp_rate, analog.GR_COS_WAVE, 1000, 1, 0)
        self.analog_sig_source_x_0 = analog.sig_source_c(
            samp_rate, analog.GR_COS_WAVE, 10000, 1, 0)
        self.analog_am_demod_cf_0 = analog.am_demod_cf(
            channel_rate=32000,
            audio_decim=5,
            audio_pass=5000,
            audio_stop=5500,
        )

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_am_demod_cf_0, 0), (self.audio_sink_0, 0))
        self.connect((self.analog_sig_source_x_0, 0),
                     (self.blocks_multiply_xx_0, 1))
        self.connect((self.analog_sig_source_x_1, 0),
                     (self.blocks_multiply_xx_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.analog_am_demod_cf_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.basic_basicsink_py_c_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.qtgui_time_sink_x_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
Exemple #50
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Radio")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Variables
        ##################################################
        self.volume = volume = 1
        self.sample_rate = sample_rate = 500e3
        self.freq = freq = 100.7e6
        self.fm_sample = fm_sample = 500e3
        self.audio_rate = audio_rate = 48e3

        ##################################################
        # Blocks
        ##################################################

        self.rational_resampler_xxx_0 = filter.rational_resampler_fff(
            interpolation=int(audio_rate / 1000),
            decimation=int(fm_sample / 10000),
            taps=None,
            fractional_bw=None,
        )
        self.osmosdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " +
                                               "")
        self.osmosdr_source_0.set_sample_rate(sample_rate)
        self.osmosdr_source_0.set_center_freq(freq, 0)
        self.osmosdr_source_0.set_freq_corr(0, 0)
        self.osmosdr_source_0.set_dc_offset_mode(0, 0)
        self.osmosdr_source_0.set_iq_balance_mode(0, 0)
        self.osmosdr_source_0.set_gain_mode(False, 0)
        self.osmosdr_source_0.set_gain(10, 0)
        self.osmosdr_source_0.set_if_gain(20, 0)
        self.osmosdr_source_0.set_bb_gain(20, 0)
        self.osmosdr_source_0.set_antenna("", 0)
        self.osmosdr_source_0.set_bandwidth(0, 0)

        self.low_pass_filter_0 = filter.fir_filter_ccf(
            int(sample_rate / fm_sample),
            firdes.low_pass(1, sample_rate, 100e3, 10e3, firdes.WIN_HAMMING,
                            6.76))
        self.blocks_multiply_xx_0 = blocks.multiply_vff(1)
        self.audio_sink_0 = audio.sink(int(audio_rate), "", True)
        self.analog_wfm_rcv_0 = analog.wfm_rcv(
            quad_rate=fm_sample,
            audio_decimation=10,
        )
        self.analog_const_source_x_0 = analog.sig_source_f(
            0, analog.GR_CONST_WAVE, 0, 0, volume)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.low_pass_filter_0, 0), (self.analog_wfm_rcv_0, 0))
        #        self.connect((self.osmosdr_source_0, 0), (self.wxgui_fftsink2_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0), (self.audio_sink_0, 0))
        self.connect((self.analog_const_source_x_0, 0),
                     (self.blocks_multiply_xx_0, 1))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.blocks_multiply_xx_0, 0))
        self.connect((self.osmosdr_source_0, 0), (self.low_pass_filter_0, 0))
        self.connect((self.analog_wfm_rcv_0, 0),
                     (self.rational_resampler_xxx_0, 0))
Exemple #51
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Hackrfone Am Rx 8Msps")

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 8e6
        self.ppm = ppm = 0
        self.freq = freq = 472e3
        self.fi = fi = 200e3
        self.RF_Gain = RF_Gain = 0
        self.FI_Gain = FI_Gain = 10
        self.FI_BWD = FI_BWD = 10e3
        self.BandWidth = BandWidth = 0
        self.BB_Gain = BB_Gain = 20
        self.Audio_Gain = Audio_Gain = 5

        ##################################################
        # Blocks
        ##################################################
        _ppm_sizer = wx.BoxSizer(wx.VERTICAL)
        self._ppm_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_ppm_sizer,
        	value=self.ppm,
        	callback=self.set_ppm,
        	label='Freq. Corr. [ppm]',
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._ppm_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_ppm_sizer,
        	value=self.ppm,
        	callback=self.set_ppm,
        	minimum=-10,
        	maximum=10,
        	num_steps=200,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_ppm_sizer, 1, 1, 1, 1)
        self.notebook_0 = self.notebook_0 = wx.Notebook(self.GetWin(), style=wx.NB_TOP)
        self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "RF")
        self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "FI")
        self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "AF")
        self.Add(self.notebook_0)
        _freq_sizer = wx.BoxSizer(wx.VERTICAL)
        self._freq_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_freq_sizer,
        	value=self.freq,
        	callback=self.set_freq,
        	label='Frequency',
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._freq_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_freq_sizer,
        	value=self.freq,
        	callback=self.set_freq,
        	minimum=400e3,
        	maximum=1.2e6,
        	num_steps=1000,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_freq_sizer, 1, 0, 1, 1)
        self._RF_Gain_chooser = forms.button(
        	parent=self.GetWin(),
        	value=self.RF_Gain,
        	callback=self.set_RF_Gain,
        	label='RF Amp',
        	choices=[0, 8],
        	labels=['0 dB', '13 dB'],
        )
        self.GridAdd(self._RF_Gain_chooser, 0, 0, 1, 1)
        _FI_Gain_sizer = wx.BoxSizer(wx.VERTICAL)
        self._FI_Gain_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_FI_Gain_sizer,
        	value=self.FI_Gain,
        	callback=self.set_FI_Gain,
        	label='Rx FI Gain',
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._FI_Gain_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_FI_Gain_sizer,
        	value=self.FI_Gain,
        	callback=self.set_FI_Gain,
        	minimum=0,
        	maximum=47,
        	num_steps=47,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_FI_Gain_sizer, 0, 1, 1, 1)
        _FI_BWD_sizer = wx.BoxSizer(wx.VERTICAL)
        self._FI_BWD_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_FI_BWD_sizer,
        	value=self.FI_BWD,
        	callback=self.set_FI_BWD,
        	label='FI Bandwidth',
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._FI_BWD_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_FI_BWD_sizer,
        	value=self.FI_BWD,
        	callback=self.set_FI_BWD,
        	minimum=500,
        	maximum=20e3,
        	num_steps=100,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_FI_BWD_sizer, 1, 3, 1, 1)
        self._BandWidth_chooser = forms.drop_down(
        	parent=self.GetWin(),
        	value=self.BandWidth,
        	callback=self.set_BandWidth,
        	label='Bandwidth',
        	choices=[0, 1.75e6, 20e6],
        	labels=['Auto', '1.75 MHz', '20 MHz'],
        )
        self.GridAdd(self._BandWidth_chooser, 0, 3, 1, 1)
        _BB_Gain_sizer = wx.BoxSizer(wx.VERTICAL)
        self._BB_Gain_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_BB_Gain_sizer,
        	value=self.BB_Gain,
        	callback=self.set_BB_Gain,
        	label='Base Band Gain',
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._BB_Gain_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_BB_Gain_sizer,
        	value=self.BB_Gain,
        	callback=self.set_BB_Gain,
        	minimum=0,
        	maximum=62,
        	num_steps=31,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_BB_Gain_sizer, 0, 2, 1, 1)
        _Audio_Gain_sizer = wx.BoxSizer(wx.VERTICAL)
        self._Audio_Gain_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_Audio_Gain_sizer,
        	value=self.Audio_Gain,
        	callback=self.set_Audio_Gain,
        	label='Audio Gain',
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._Audio_Gain_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_Audio_Gain_sizer,
        	value=self.Audio_Gain,
        	callback=self.set_Audio_Gain,
        	minimum=0,
        	maximum=10,
        	num_steps=50,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_Audio_Gain_sizer, 1, 2, 1, 1)
        self.wxgui_numbersink2_0 = numbersink2.number_sink_f(
        	self.GetWin(),
        	unit='Unidades',
        	minval=0,
        	maxval=2,
        	factor=1.0,
        	decimal_places=2,
        	ref_level=0,
        	sample_rate=samp_rate,
        	number_rate=2,
        	average=False,
        	avg_alpha=0.5,
        	label='RMS de Entrada',
        	peak_hold=False,
        	show_gauge=True,
        )
        self.GridAdd(self.wxgui_numbersink2_0.win, 2, 0, 1, 4)
        self.wxgui_fftsink2_0_1 = fftsink2.fft_sink_c(
        	self.notebook_0.GetPage(0).GetWin(),
        	baseband_freq=freq,
        	y_per_div=10,
        	y_divs=10,
        	ref_level=0,
        	ref_scale=2.0,
        	sample_rate=samp_rate,
        	fft_size=1024,
        	fft_rate=15,
        	average=True,
        	avg_alpha=0.5,
        	title='FFT Plot',
        	peak_hold=False,
        	size=(800,400),
        )
        self.notebook_0.GetPage(0).Add(self.wxgui_fftsink2_0_1.win)
        self.wxgui_fftsink2_0_0_0_0 = fftsink2.fft_sink_f(
        	self.notebook_0.GetPage(2).GetWin(),
        	baseband_freq=0,
        	y_per_div=10,
        	y_divs=10,
        	ref_level=0,
        	ref_scale=2.0,
        	sample_rate=32000,
        	fft_size=1024,
        	fft_rate=15,
        	average=True,
        	avg_alpha=0.2,
        	title='AF',
        	peak_hold=False,
        	size=(800,500),
        )
        self.notebook_0.GetPage(2).Add(self.wxgui_fftsink2_0_0_0_0.win)
        self.wxgui_fftsink2_0_0_0 = fftsink2.fft_sink_c(
        	self.notebook_0.GetPage(1).GetWin(),
        	baseband_freq=fi,
        	y_per_div=10,
        	y_divs=10,
        	ref_level=0,
        	ref_scale=2.0,
        	sample_rate=samp_rate/80,
        	fft_size=1024,
        	fft_rate=15,
        	average=True,
        	avg_alpha=0.2,
        	title='FI',
        	peak_hold=False,
        	size=(800,500),
        )
        self.notebook_0.GetPage(1).Add(self.wxgui_fftsink2_0_0_0.win)
        self.rational_resampler_xxx_0 = filter.rational_resampler_fff(
                interpolation=8,
                decimation=25,
                taps=None,
                fractional_bw=None,
        )
        self.osmosdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + '' )
        self.osmosdr_source_0.set_sample_rate(samp_rate)
        self.osmosdr_source_0.set_center_freq(freq+fi, 0)
        self.osmosdr_source_0.set_freq_corr(ppm, 0)
        self.osmosdr_source_0.set_dc_offset_mode(0, 0)
        self.osmosdr_source_0.set_iq_balance_mode(0, 0)
        self.osmosdr_source_0.set_gain_mode(True, 0)
        self.osmosdr_source_0.set_gain(RF_Gain, 0)
        self.osmosdr_source_0.set_if_gain(FI_Gain, 0)
        self.osmosdr_source_0.set_bb_gain(BB_Gain, 0)
        self.osmosdr_source_0.set_antenna('', 0)
        self.osmosdr_source_0.set_bandwidth(BandWidth, 0)
          
        self.low_pass_filter_0 = filter.fir_filter_ccf(80, firdes.low_pass(
        	1, samp_rate, FI_BWD/2, samp_rate/2500, firdes.WIN_HAMMING, 6.76))
        self.dc_blocker_xx_0 = filter.dc_blocker_ff(160, True)
        self.blocks_rms_xx_0 = blocks.rms_cf(0.0001)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((Audio_Gain, ))
        self.audio_sink_0 = audio.sink(32000, '', True)
        self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, fi, 1, 0)
        self.analog_am_demod_cf_0 = analog.am_demod_cf(
        	channel_rate=samp_rate/80,
        	audio_decim=1,
        	audio_pass=5000,
        	audio_stop=7000,
        )

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_am_demod_cf_0, 0), (self.rational_resampler_xxx_0, 0))    
        self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1))    
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.audio_sink_0, 0))    
        self.connect((self.blocks_multiply_xx_0, 0), (self.low_pass_filter_0, 0))    
        self.connect((self.blocks_multiply_xx_0, 0), (self.wxgui_fftsink2_0_1, 0))    
        self.connect((self.blocks_rms_xx_0, 0), (self.wxgui_numbersink2_0, 0))    
        self.connect((self.dc_blocker_xx_0, 0), (self.blocks_multiply_const_vxx_0, 0))    
        self.connect((self.dc_blocker_xx_0, 0), (self.wxgui_fftsink2_0_0_0_0, 0))    
        self.connect((self.low_pass_filter_0, 0), (self.analog_am_demod_cf_0, 0))    
        self.connect((self.low_pass_filter_0, 0), (self.wxgui_fftsink2_0_0_0, 0))    
        self.connect((self.osmosdr_source_0, 0), (self.blocks_multiply_xx_0, 0))    
        self.connect((self.osmosdr_source_0, 0), (self.blocks_rms_xx_0, 0))    
        self.connect((self.rational_resampler_xxx_0, 0), (self.dc_blocker_xx_0, 0))    
Exemple #52
0
    def __init__(self,frame,panel,vbox,argv):
        stdgui2.std_top_block.__init__ (self,frame,panel,vbox,argv)

        parser=OptionParser(option_class=eng_option)
        parser.add_option("-a", "--args", type="string", default="",
                          help="UHD device address args [default=%default]")
        parser.add_option("", "--spec", type="string", default=None,
	                  help="Subdevice of UHD device where appropriate")
        parser.add_option("-A", "--antenna", type="string", default=None,
                          help="select Rx Antenna where appropriate")
        parser.add_option("-f", "--freq", type="eng_float", default=100.1e6,
                          help="set frequency to FREQ", metavar="FREQ")
        parser.add_option("-g", "--gain", type="eng_float", default=40,
                          help="set gain in dB (default is midpoint)")
        parser.add_option("-V", "--volume", type="eng_float", default=None,
                          help="set volume (default is midpoint)")
        parser.add_option("-O", "--audio-output", type="string", default="",
                          help="pcm device name.  E.g., hw:0,0 or surround51 or /dev/dsp")
        parser.add_option("", "--freq-min", type="eng_float", default=87.9e6,
                          help="Set a minimum frequency [default=%default]")
        parser.add_option("", "--freq-max", type="eng_float", default=108.1e6,
                          help="Set a maximum frequency [default=%default]")

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

        self.frame = frame
        self.panel = panel

        self.vol = 0
        self.state = "FREQ"
        self.freq = 0

        self.fm_freq_min = options.freq_min
        self.fm_freq_max = options.freq_max

        # build graph

        self.u = uhd.usrp_source(device_addr=options.args, stream_args=uhd.stream_args('fc32'))

        usrp_rate  = 320e3
        demod_rate = 320e3
        audio_rate = 32e3
        sca_demod_rate = 64e3
        audio_decim = int(demod_rate / audio_rate)
        sca_chanfilt_decim = int(demod_rate / sca_demod_rate)

        self.u.set_samp_rate(usrp_rate)
        dev_rate = self.u.get_samp_rate()

        nfilts = 32
        chan_coeffs = optfir.low_pass (nfilts,           # gain
                                       nfilts*usrp_rate, # sampling rate
                                       100e3,            # passband cutoff
                                       140e3,            # stopband cutoff
                                       0.1,              # passband ripple
                                       60)               # stopband attenuation
        rrate = usrp_rate / dev_rate
        self.chan_filt = blks2.pfb_arb_resampler_ccf(rrate, chan_coeffs, nfilts)

        #Create demodulator block for Main FM Channel
	max_dev = 75e3
        fm_demod_gain = demod_rate/(2*math.pi*max_dev)
        self.fm_demod = gr.quadrature_demod_cf (fm_demod_gain)

        # Note - deemphasis is not applied to the Main FM Channel as
        # main audio is not decoded

        # SCA Devation is 10% of carrier but some references say 20%
        # if mono with one SCA (6 KHz seems typical)
        max_sca_dev = 6e3

	# Create filter to get SCA channel we want
        sca_chan_coeffs = gr.firdes.low_pass (1.0,                # gain
                                              demod_rate,         # sampling rate
                                              max_sca_dev,        # cutoff freq
                                              max_sca_dev/3,      # trans. band
                                              gr.firdes.WIN_HANN) # filter type

        self.ddc = gr.freq_xlating_fir_filter_fcf(sca_chanfilt_decim, # decim rate
                                                  sca_chan_coeffs,    # taps
                                                  0,                  # freq translation amount (Gets set by the UI)
                                                  demod_rate)   # input sample rate

        #Create demodulator block for SCA Channel
        sca_demod_gain = sca_demod_rate/(2*math.pi*max_sca_dev)
        self.fm_demod_sca = gr.quadrature_demod_cf (sca_demod_gain)


        # SCA analog audio is bandwidth limited to 5 KHz
        max_sca_audio_freq = 5.0e3

        # SCA analog deephasis is 150 uS (75 uS may be used)
        sca_tau = 150e-6

        # compute FIR filter taps for SCA audio filter
        audio_coeffs = gr.firdes.low_pass (1.0,                    # gain
                                           sca_demod_rate,         # sampling rate
                                           max_sca_audio_freq,     # cutoff freq
                                           max_sca_audio_freq/2.5, # trans. band
                                           gr.firdes.WIN_HAMMING)

        # input: float; output: float
        self.audio_filter = gr.fir_filter_fff (audio_decim, audio_coeffs)

	# Create deemphasis block that is applied after SCA demodulation
        self.deemph = blks2.fm_deemph (audio_rate, sca_tau)

        self.volume_control = gr.multiply_const_ff(self.vol)

        # sound card as final sink
        self.audio_sink = audio.sink (int (audio_rate),
                                      options.audio_output,
                                      False)  # ok_to_block

        # now wire it all together
        self.connect (self.u, self.chan_filt, self.fm_demod,
                      self.ddc, self.fm_demod_sca)
        self.connect (self.fm_demod_sca, self.audio_filter,
                      self.deemph, self.volume_control,
                      self.audio_sink)

        self._build_gui(vbox, usrp_rate, demod_rate, sca_demod_rate, audio_rate)

        if options.gain is None:
            # if no gain was specified, use the mid-point in dB
            g = self.u.get_gain_range()
            options.gain = float(g.start()+g.stop())/2

        if options.volume is None:
            g = self.volume_range()
            options.volume = float(g[0]+g[1])/2

        frange = self.u.get_freq_range()
        if(frange.start() > self.fm_freq_max or frange.stop() <  self.fm_freq_min):
            sys.stderr.write("Radio does not support required frequency range.\n")
            sys.exit(1)
        if(options.freq < self.fm_freq_min or options.freq > self.fm_freq_max):
            sys.stderr.write("Requested frequency is outside of required frequency range.\n")
            sys.exit(1)

        # set initial values

        self.set_gain(options.gain)
        self.set_vol(options.volume)
        if not(self.set_freq(options.freq)):
            self._set_status_msg("Failed to set initial frequency")
        self.set_sca_freq(67000)  # A common SCA Frequency

        # Set the subdevice spec
        if(options.spec):
            self.u.set_subdev_spec(options.spec, 0)
            
        # Set the antenna
        if(options.antenna):
            self.u.set_antenna(options.antenna, 0)
Exemple #53
0
    def __init__(self):
        gr.top_block.__init__(self, "Sdrplay Hf Weaver")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Sdrplay Hf Weaver")
        qtgui.util.check_set_qss()
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

        self.settings = Qt.QSettings("GNU Radio", "sdrplay_hf_weaver")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.rx_freq = rx_freq = 3.993e6
        self.fine_freq = fine_freq = 0
        self.coarse_freq = coarse_freq = 0
        self.volume = volume = 1
        self.usb_lsb = usb_lsb = -1
        self.samp_rate = samp_rate = 200e3
        self.rx_gain = rx_gain = 30
        self.lpf_cutoff = lpf_cutoff = 1.4e3
        self.lna_attn = lna_attn = 0
        self.interp = interp = 48
        self.if_attn = if_attn = 40
        self.freq_label = freq_label = rx_freq + fine_freq + coarse_freq
        self.decim = decim = 200
        self.decay_rate = decay_rate = 100e-6
        self.audio_ref = audio_ref = 1
        self.audio_max_gain = audio_max_gain = 1
        self.audio_gain = audio_gain = 1
        self.audio_decay = audio_decay = 100
        self.audio_attack = audio_attack = 1000
        self.agc = agc = True

        ##################################################
        # Blocks
        ##################################################
        self._volume_range = Range(0, 100, .1, 1, 200)
        self._volume_win = RangeWidget(self._volume_range, self.set_volume,
                                       "volume", "counter_slider", float)
        self.top_grid_layout.addWidget(self._volume_win, 7, 0, 1, 4)
        for r in range(7, 8):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 4):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._usb_lsb_options = (
            -1,
            1,
        )
        self._usb_lsb_labels = (
            'USB',
            'LSB',
        )
        self._usb_lsb_group_box = Qt.QGroupBox("usb_lsb")
        self._usb_lsb_box = Qt.QHBoxLayout()

        class variable_chooser_button_group(Qt.QButtonGroup):
            def __init__(self, parent=None):
                Qt.QButtonGroup.__init__(self, parent)

            @pyqtSlot(int)
            def updateButtonChecked(self, button_id):
                self.button(button_id).setChecked(True)

        self._usb_lsb_button_group = variable_chooser_button_group()
        self._usb_lsb_group_box.setLayout(self._usb_lsb_box)
        for i, label in enumerate(self._usb_lsb_labels):
            radio_button = Qt.QRadioButton(label)
            self._usb_lsb_box.addWidget(radio_button)
            self._usb_lsb_button_group.addButton(radio_button, i)
        self._usb_lsb_callback = lambda i: Qt.QMetaObject.invokeMethod(
            self._usb_lsb_button_group, "updateButtonChecked",
            Qt.Q_ARG("int", self._usb_lsb_options.index(i)))
        self._usb_lsb_callback(self.usb_lsb)
        self._usb_lsb_button_group.buttonClicked[int].connect(
            lambda i: self.set_usb_lsb(self._usb_lsb_options[i]))
        self.top_grid_layout.addWidget(self._usb_lsb_group_box, 5, 5, 1, 1)
        for r in range(5, 6):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(5, 6):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._rx_freq_tool_bar = Qt.QToolBar(self)
        self._rx_freq_tool_bar.addWidget(Qt.QLabel("rx_freq" + ": "))
        self._rx_freq_line_edit = Qt.QLineEdit(str(self.rx_freq))
        self._rx_freq_tool_bar.addWidget(self._rx_freq_line_edit)
        self._rx_freq_line_edit.returnPressed.connect(lambda: self.set_rx_freq(
            eng_notation.str_to_num(
                str(self._rx_freq_line_edit.text().toAscii()))))
        self.top_grid_layout.addWidget(self._rx_freq_tool_bar, 4, 0, 1, 1)
        for r in range(4, 5):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 1):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._lpf_cutoff_tool_bar = Qt.QToolBar(self)
        self._lpf_cutoff_tool_bar.addWidget(Qt.QLabel("lpf_cutoff" + ": "))
        self._lpf_cutoff_line_edit = Qt.QLineEdit(str(self.lpf_cutoff))
        self._lpf_cutoff_tool_bar.addWidget(self._lpf_cutoff_line_edit)
        self._lpf_cutoff_line_edit.returnPressed.connect(
            lambda: self.set_lpf_cutoff(
                eng_notation.str_to_num(
                    str(self._lpf_cutoff_line_edit.text().toAscii()))))
        self.top_grid_layout.addWidget(self._lpf_cutoff_tool_bar, 4, 5, 1, 1)
        for r in range(4, 5):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(5, 6):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._lna_attn_tool_bar = Qt.QToolBar(self)
        self._lna_attn_tool_bar.addWidget(Qt.QLabel("lna_attn" + ": "))
        self._lna_attn_line_edit = Qt.QLineEdit(str(self.lna_attn))
        self._lna_attn_tool_bar.addWidget(self._lna_attn_line_edit)
        self._lna_attn_line_edit.returnPressed.connect(
            lambda: self.set_lna_attn(
                int(str(self._lna_attn_line_edit.text().toAscii()))))
        self.top_grid_layout.addWidget(self._lna_attn_tool_bar, 4, 3, 1, 1)
        for r in range(4, 5):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(3, 4):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._if_attn_tool_bar = Qt.QToolBar(self)
        self._if_attn_tool_bar.addWidget(Qt.QLabel("if_attn" + ": "))
        self._if_attn_line_edit = Qt.QLineEdit(str(self.if_attn))
        self._if_attn_tool_bar.addWidget(self._if_attn_line_edit)
        self._if_attn_line_edit.returnPressed.connect(lambda: self.set_if_attn(
            int(str(self._if_attn_line_edit.text().toAscii()))))
        self.top_grid_layout.addWidget(self._if_attn_tool_bar, 4, 1, 1, 1)
        for r in range(4, 5):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(1, 2):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._fine_freq_range = Range(-1e3, 1e3, 1, 0, 200)
        self._fine_freq_win = RangeWidget(self._fine_freq_range,
                                          self.set_fine_freq, "fine_freq",
                                          "counter_slider", float)
        self.top_grid_layout.addWidget(self._fine_freq_win, 5, 0, 1, 4)
        for r in range(5, 6):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 4):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._decay_rate_options = (
            100e-6,
            65e-3,
            20e-3,
        )
        self._decay_rate_labels = (
            'Fast',
            'Medium',
            'Slow',
        )
        self._decay_rate_group_box = Qt.QGroupBox("decay_rate")
        self._decay_rate_box = Qt.QHBoxLayout()

        class variable_chooser_button_group(Qt.QButtonGroup):
            def __init__(self, parent=None):
                Qt.QButtonGroup.__init__(self, parent)

            @pyqtSlot(int)
            def updateButtonChecked(self, button_id):
                self.button(button_id).setChecked(True)

        self._decay_rate_button_group = variable_chooser_button_group()
        self._decay_rate_group_box.setLayout(self._decay_rate_box)
        for i, label in enumerate(self._decay_rate_labels):
            radio_button = Qt.QRadioButton(label)
            self._decay_rate_box.addWidget(radio_button)
            self._decay_rate_button_group.addButton(radio_button, i)
        self._decay_rate_callback = lambda i: Qt.QMetaObject.invokeMethod(
            self._decay_rate_button_group, "updateButtonChecked",
            Qt.Q_ARG("int", self._decay_rate_options.index(i)))
        self._decay_rate_callback(self.decay_rate)
        self._decay_rate_button_group.buttonClicked[int].connect(
            lambda i: self.set_decay_rate(self._decay_rate_options[i]))
        self.top_grid_layout.addWidget(self._decay_rate_group_box, 4, 6, 1, 1)
        for r in range(4, 5):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(6, 7):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._coarse_freq_range = Range(-10e3, 10e3, 1, 0, 200)
        self._coarse_freq_win = RangeWidget(self._coarse_freq_range,
                                            self.set_coarse_freq,
                                            "coarse_freq", "counter_slider",
                                            float)
        self.top_grid_layout.addWidget(self._coarse_freq_win, 6, 0, 1, 4)
        for r in range(6, 7):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 4):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._audio_ref_tool_bar = Qt.QToolBar(self)
        self._audio_ref_tool_bar.addWidget(Qt.QLabel("audio_ref" + ": "))
        self._audio_ref_line_edit = Qt.QLineEdit(str(self.audio_ref))
        self._audio_ref_tool_bar.addWidget(self._audio_ref_line_edit)
        self._audio_ref_line_edit.returnPressed.connect(
            lambda: self.set_audio_ref(
                eng_notation.str_to_num(
                    str(self._audio_ref_line_edit.text().toAscii()))))
        self.top_grid_layout.addWidget(self._audio_ref_tool_bar, 9, 3, 1, 1)
        for r in range(9, 10):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(3, 4):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._audio_max_gain_tool_bar = Qt.QToolBar(self)
        self._audio_max_gain_tool_bar.addWidget(
            Qt.QLabel("audio_max_gain" + ": "))
        self._audio_max_gain_line_edit = Qt.QLineEdit(str(self.audio_max_gain))
        self._audio_max_gain_tool_bar.addWidget(self._audio_max_gain_line_edit)
        self._audio_max_gain_line_edit.returnPressed.connect(
            lambda: self.set_audio_max_gain(
                eng_notation.str_to_num(
                    str(self._audio_max_gain_line_edit.text().toAscii()))))
        self.top_grid_layout.addWidget(self._audio_max_gain_tool_bar, 9, 5, 1,
                                       1)
        for r in range(9, 10):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(5, 6):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._audio_gain_tool_bar = Qt.QToolBar(self)
        self._audio_gain_tool_bar.addWidget(Qt.QLabel("audio_gain" + ": "))
        self._audio_gain_line_edit = Qt.QLineEdit(str(self.audio_gain))
        self._audio_gain_tool_bar.addWidget(self._audio_gain_line_edit)
        self._audio_gain_line_edit.returnPressed.connect(
            lambda: self.set_audio_gain(
                eng_notation.str_to_num(
                    str(self._audio_gain_line_edit.text().toAscii()))))
        self.top_grid_layout.addWidget(self._audio_gain_tool_bar, 9, 4, 1, 1)
        for r in range(9, 10):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(4, 5):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._audio_decay_tool_bar = Qt.QToolBar(self)
        self._audio_decay_tool_bar.addWidget(Qt.QLabel("audio_decay" + ": "))
        self._audio_decay_line_edit = Qt.QLineEdit(str(self.audio_decay))
        self._audio_decay_tool_bar.addWidget(self._audio_decay_line_edit)
        self._audio_decay_line_edit.returnPressed.connect(
            lambda: self.set_audio_decay(
                eng_notation.str_to_num(
                    str(self._audio_decay_line_edit.text().toAscii()))))
        self.top_grid_layout.addWidget(self._audio_decay_tool_bar, 9, 2, 1, 1)
        for r in range(9, 10):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(2, 3):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._audio_attack_tool_bar = Qt.QToolBar(self)
        self._audio_attack_tool_bar.addWidget(Qt.QLabel("audio_attack" + ": "))
        self._audio_attack_line_edit = Qt.QLineEdit(str(self.audio_attack))
        self._audio_attack_tool_bar.addWidget(self._audio_attack_line_edit)
        self._audio_attack_line_edit.returnPressed.connect(
            lambda: self.set_audio_attack(
                eng_notation.str_to_num(
                    str(self._audio_attack_line_edit.text().toAscii()))))
        self.top_grid_layout.addWidget(self._audio_attack_tool_bar, 9, 1, 1, 1)
        for r in range(9, 10):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(1, 2):
            self.top_grid_layout.setColumnStretch(c, 1)
        _agc_check_box = Qt.QCheckBox("agc")
        self._agc_choices = {True: True, False: False}
        self._agc_choices_inv = dict(
            (v, k) for k, v in self._agc_choices.iteritems())
        self._agc_callback = lambda i: Qt.QMetaObject.invokeMethod(
            _agc_check_box, "setChecked",
            Qt.Q_ARG("bool", self._agc_choices_inv[i]))
        self._agc_callback(self.agc)
        _agc_check_box.stateChanged.connect(
            lambda i: self.set_agc(self._agc_choices[bool(i)]))
        self.top_grid_layout.addWidget(_agc_check_box, 4, 4, 1, 1)
        for r in range(4, 5):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(4, 5):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.sdrplay_rspduo_source_0 = sdrplay.rspduo_source(
            rx_freq, 200, bool(agc), if_attn, True, True, False, 0, 1,
            samp_rate, True, True, lna_attn, False, '0', 'T1_50ohm')

        self._rx_gain_tool_bar = Qt.QToolBar(self)
        self._rx_gain_tool_bar.addWidget(Qt.QLabel("rx_gain" + ": "))
        self._rx_gain_line_edit = Qt.QLineEdit(str(self.rx_gain))
        self._rx_gain_tool_bar.addWidget(self._rx_gain_line_edit)
        self._rx_gain_line_edit.returnPressed.connect(lambda: self.set_rx_gain(
            eng_notation.str_to_num(
                str(self._rx_gain_line_edit.text().toAscii()))))
        self.top_grid_layout.addWidget(self._rx_gain_tool_bar, 4, 2, 1, 1)
        for r in range(4, 5):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(2, 3):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.rational_resampler_xxx_1 = filter.rational_resampler_ccc(
            interpolation=1,
            decimation=4,
            taps=None,
            fractional_bw=None,
        )
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
            interpolation=interp,
            decimation=decim,
            taps=None,
            fractional_bw=None,
        )
        self.qtgui_time_sink_x_0_0 = qtgui.time_sink_f(
            1024,  #size
            samp_rate / decim * interp / 3 / 4,  #samp_rate
            "",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_0_0.set_update_time(0.010)
        self.qtgui_time_sink_x_0_0.set_y_axis(-1, 100)

        self.qtgui_time_sink_x_0_0.set_y_label('Amplitude', "")

        self.qtgui_time_sink_x_0_0.enable_tags(-1, True)
        self.qtgui_time_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE,
                                                    qtgui.TRIG_SLOPE_POS, 0.0,
                                                    0, 0, "")
        self.qtgui_time_sink_x_0_0.enable_autoscale(False)
        self.qtgui_time_sink_x_0_0.enable_grid(True)
        self.qtgui_time_sink_x_0_0.enable_axis_labels(True)
        self.qtgui_time_sink_x_0_0.enable_control_panel(False)
        self.qtgui_time_sink_x_0_0.enable_stem_plot(False)

        if not True:
            self.qtgui_time_sink_x_0_0.disable_legend()

        labels = ['', '', '', '', '', '', '', '', '', '']
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "green", "black", "cyan", "magenta", "yellow",
            "dark red", "dark green", "blue"
        ]
        styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]

        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_time_sink_x_0_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_0_0.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_0_0.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_0_0.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_0_0.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_0_0.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_0_0.set_line_alpha(i, alphas[i])

        self._qtgui_time_sink_x_0_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_0_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_0_win, 6, 6,
                                       3, 2)
        for r in range(6, 9):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(6, 8):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_time_sink_x_0 = qtgui.time_sink_f(
            1024,  #size
            samp_rate / decim * interp / 3,  #samp_rate
            "",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0.set_y_axis(-1, 1)

        self.qtgui_time_sink_x_0.set_y_label('Amplitude', "")

        self.qtgui_time_sink_x_0.enable_tags(-1, True)
        self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE,
                                                  qtgui.TRIG_SLOPE_POS, 0.0, 0,
                                                  0, "")
        self.qtgui_time_sink_x_0.enable_autoscale(False)
        self.qtgui_time_sink_x_0.enable_grid(False)
        self.qtgui_time_sink_x_0.enable_axis_labels(True)
        self.qtgui_time_sink_x_0.enable_control_panel(False)
        self.qtgui_time_sink_x_0.enable_stem_plot(False)

        if not True:
            self.qtgui_time_sink_x_0.disable_legend()

        labels = ['', '', '', '', '', '', '', '', '', '']
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "green", "black", "cyan", "magenta", "yellow",
            "dark red", "dark green", "blue"
        ]
        styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]

        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_time_sink_x_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_0.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_0.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i])

        self._qtgui_time_sink_x_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_win, 8, 0, 1,
                                       4)
        for r in range(8, 9):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 4):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_number_sink_0 = qtgui.number_sink(gr.sizeof_float, 0,
                                                     qtgui.NUM_GRAPH_HORIZ, 1)
        self.qtgui_number_sink_0.set_update_time(0.010)
        self.qtgui_number_sink_0.set_title('')

        labels = ["RSSI", '', '', '', '', '', '', '', '', '']
        units = ['', '', '', '', '', '', '', '', '', '']
        colors = [("blue", "red"), ("black", "black"), ("black", "black"),
                  ("black", "black"), ("black", "black"), ("black", "black"),
                  ("black", "black"), ("black", "black"), ("black", "black"),
                  ("black", "black")]
        factor = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        for i in xrange(1):
            self.qtgui_number_sink_0.set_min(i, 0)
            self.qtgui_number_sink_0.set_max(i, 50)
            self.qtgui_number_sink_0.set_color(i, colors[i][0], colors[i][1])
            if len(labels[i]) == 0:
                self.qtgui_number_sink_0.set_label(i, "Data {0}".format(i))
            else:
                self.qtgui_number_sink_0.set_label(i, labels[i])
            self.qtgui_number_sink_0.set_unit(i, units[i])
            self.qtgui_number_sink_0.set_factor(i, factor[i])

        self.qtgui_number_sink_0.enable_autoscale(False)
        self._qtgui_number_sink_0_win = sip.wrapinstance(
            self.qtgui_number_sink_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_number_sink_0_win, 5, 6, 1,
                                       1)
        for r in range(5, 6):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(6, 7):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_freq_sink_x_0_0 = qtgui.freq_sink_c(
            2048,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate / decim * interp / 3,  #bw
            "",  #name
            1  #number of inputs
        )
        self.qtgui_freq_sink_x_0_0.set_update_time(0.0010)
        self.qtgui_freq_sink_x_0_0.set_y_axis(-140, 10)
        self.qtgui_freq_sink_x_0_0.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0,
                                                    0, "")
        self.qtgui_freq_sink_x_0_0.enable_autoscale(False)
        self.qtgui_freq_sink_x_0_0.enable_grid(True)
        self.qtgui_freq_sink_x_0_0.set_fft_average(1.0)
        self.qtgui_freq_sink_x_0_0.enable_axis_labels(True)
        self.qtgui_freq_sink_x_0_0.enable_control_panel(False)

        if not False:
            self.qtgui_freq_sink_x_0_0.disable_legend()

        if "complex" == "float" or "complex" == "msg_float":
            self.qtgui_freq_sink_x_0_0.set_plot_pos_half(not True)

        labels = ['', 'processed', '', '', '', '', '', '', '', '']
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "green", "black", "cyan", "magenta", "yellow",
            "dark red", "dark green", "dark blue"
        ]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_freq_sink_x_0_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_freq_sink_x_0_0.set_line_label(i, labels[i])
            self.qtgui_freq_sink_x_0_0.set_line_width(i, widths[i])
            self.qtgui_freq_sink_x_0_0.set_line_color(i, colors[i])
            self.qtgui_freq_sink_x_0_0.set_line_alpha(i, alphas[i])

        self._qtgui_freq_sink_x_0_0_win = sip.wrapinstance(
            self.qtgui_freq_sink_x_0_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_0_win, 6, 4,
                                       3, 2)
        for r in range(6, 9):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(4, 6):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c(
            2048,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate / decim * interp,  #bw
            "",  #name
            1  #number of inputs
        )
        self.qtgui_freq_sink_x_0.set_update_time(0.010)
        self.qtgui_freq_sink_x_0.set_y_axis(-140, 10)
        self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0,
                                                  "")
        self.qtgui_freq_sink_x_0.enable_autoscale(False)
        self.qtgui_freq_sink_x_0.enable_grid(True)
        self.qtgui_freq_sink_x_0.set_fft_average(1.0)
        self.qtgui_freq_sink_x_0.enable_axis_labels(True)
        self.qtgui_freq_sink_x_0.enable_control_panel(False)

        if not True:
            self.qtgui_freq_sink_x_0.disable_legend()

        if "complex" == "float" or "complex" == "msg_float":
            self.qtgui_freq_sink_x_0.set_plot_pos_half(not True)

        labels = ['pre-d', 'processed', '', '', '', '', '', '', '', '']
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "green", "black", "cyan", "magenta", "yellow",
            "dark red", "dark green", "dark blue"
        ]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_freq_sink_x_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_freq_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_freq_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_freq_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i])

        self._qtgui_freq_sink_x_0_win = sip.wrapinstance(
            self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win, 0, 4, 4,
                                       4)
        for r in range(0, 4):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(4, 8):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.low_pass_filter_0_1 = filter.interp_fir_filter_fff(
            1,
            firdes.low_pass(1, samp_rate / decim * interp / 3, 1.5e3, 100,
                            firdes.WIN_HAMMING, 6.76))
        self.low_pass_filter_0_0 = filter.fir_filter_ccf(
            3,
            firdes.low_pass(1, samp_rate / decim * interp, lpf_cutoff, 100,
                            firdes.WIN_HAMMING, 6.76))
        self.low_pass_filter_0 = filter.interp_fir_filter_fff(
            1,
            firdes.low_pass(1, samp_rate / decim * interp / 3, 1.5e3, 100,
                            firdes.WIN_HAMMING, 6.76))
        self._freq_label_tool_bar = Qt.QToolBar(self)

        if None:
            self._freq_label_formatter = None
        else:
            self._freq_label_formatter = lambda x: eng_notation.num_to_str(x)

        self._freq_label_tool_bar.addWidget(Qt.QLabel('Tuned Freq' + ": "))
        self._freq_label_label = Qt.QLabel(
            str(self._freq_label_formatter(self.freq_label)))
        self._freq_label_tool_bar.addWidget(self._freq_label_label)
        self.top_grid_layout.addWidget(self._freq_label_tool_bar, 5, 4, 1, 1)
        for r in range(5, 6):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(4, 5):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.fosphor_qt_sink_c_0 = fosphor.qt_sink_c()
        self.fosphor_qt_sink_c_0.set_fft_window(window.WIN_BLACKMAN_hARRIS)
        self.fosphor_qt_sink_c_0.set_frequency_range(rx_freq, samp_rate)
        self._fosphor_qt_sink_c_0_win = sip.wrapinstance(
            self.fosphor_qt_sink_c_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._fosphor_qt_sink_c_0_win, 0, 0, 4,
                                       4)
        for r in range(0, 4):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 4):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.blocks_multiply_xx_1_0 = blocks.multiply_vff(1)
        self.blocks_multiply_xx_1 = blocks.multiply_vff(1)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_multiply_const_vxx_1_0 = blocks.multiply_const_vff(
            (100000, ))
        self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vff(
            (usb_lsb, ))
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff(
            (volume, ))
        self.blocks_moving_average_xx_0 = blocks.moving_average_ff(
            1000, 1 / 1000.0, 4000, 1)
        self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1)
        self.blocks_complex_to_float_0 = blocks.complex_to_float(1)
        self.blocks_add_xx_0 = blocks.add_vff(1)
        self.audio_sink_0 = audio.sink(16000, '', True)
        self.analog_sig_source_x_0_0_0 = analog.sig_source_f(
            samp_rate / decim * interp / 3, analog.GR_SIN_WAVE, 1.5e3, 1, 0)
        self.analog_sig_source_x_0_0 = analog.sig_source_f(
            samp_rate / decim * interp / 3, analog.GR_COS_WAVE, 1.5e3, 1, 0)
        self.analog_sig_source_x_0 = analog.sig_source_c(
            samp_rate, analog.GR_COS_WAVE, -1 * (fine_freq + coarse_freq), 1,
            0)
        self.analog_agc2_xx_0_0 = analog.agc2_ff(audio_attack, audio_decay,
                                                 audio_ref, audio_gain)
        self.analog_agc2_xx_0_0.set_max_gain(audio_max_gain)
        self.analog_agc2_xx_0 = analog.agc2_cc(0.1, decay_rate, .3, 1.0)
        self.analog_agc2_xx_0.set_max_gain(1)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_agc2_xx_0, 0), (self.low_pass_filter_0_0, 0))
        self.connect((self.analog_agc2_xx_0, 0), (self.qtgui_freq_sink_x_0, 0))
        self.connect((self.analog_agc2_xx_0_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.analog_sig_source_x_0, 0),
                     (self.blocks_multiply_xx_0, 1))
        self.connect((self.analog_sig_source_x_0_0, 0),
                     (self.blocks_multiply_xx_1, 1))
        self.connect((self.analog_sig_source_x_0_0_0, 0),
                     (self.blocks_multiply_xx_1_0, 1))
        self.connect((self.blocks_add_xx_0, 0), (self.analog_agc2_xx_0_0, 0))
        self.connect((self.blocks_complex_to_float_0, 0),
                     (self.low_pass_filter_0, 0))
        self.connect((self.blocks_complex_to_float_0, 1),
                     (self.low_pass_filter_0_1, 0))
        self.connect((self.blocks_complex_to_mag_squared_0, 0),
                     (self.blocks_moving_average_xx_0, 0))
        self.connect((self.blocks_moving_average_xx_0, 0),
                     (self.blocks_multiply_const_vxx_1_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.audio_sink_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.qtgui_time_sink_x_0, 0))
        self.connect((self.blocks_multiply_const_vxx_1, 0),
                     (self.blocks_add_xx_0, 1))
        self.connect((self.blocks_multiply_const_vxx_1_0, 0),
                     (self.qtgui_number_sink_0, 0))
        self.connect((self.blocks_multiply_const_vxx_1_0, 0),
                     (self.qtgui_time_sink_x_0_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0),
                     (self.rational_resampler_xxx_0, 0))
        self.connect((self.blocks_multiply_xx_1, 0), (self.blocks_add_xx_0, 0))
        self.connect((self.blocks_multiply_xx_1_0, 0),
                     (self.blocks_multiply_const_vxx_1, 0))
        self.connect((self.low_pass_filter_0, 0),
                     (self.blocks_multiply_xx_1, 0))
        self.connect((self.low_pass_filter_0_0, 0),
                     (self.blocks_complex_to_float_0, 0))
        self.connect((self.low_pass_filter_0_0, 0),
                     (self.qtgui_freq_sink_x_0_0, 0))
        self.connect((self.low_pass_filter_0_0, 0),
                     (self.rational_resampler_xxx_1, 0))
        self.connect((self.low_pass_filter_0_1, 0),
                     (self.blocks_multiply_xx_1_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.analog_agc2_xx_0, 0))
        self.connect((self.rational_resampler_xxx_1, 0),
                     (self.blocks_complex_to_mag_squared_0, 0))
        self.connect((self.sdrplay_rspduo_source_0, 0),
                     (self.blocks_multiply_xx_0, 0))
        self.connect((self.sdrplay_rspduo_source_0, 0),
                     (self.fosphor_qt_sink_c_0, 0))
Exemple #54
0
    def __init__(self):
        gr.top_block.__init__(self, "Top Block")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Top Block")
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

        self.settings = Qt.QSettings("GNU Radio", "top_block")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.wideband_bypass_ctr = wideband_bypass_ctr = 0
        self.samp_rate = samp_rate = 96000
        self.f_knob = f_knob = 7285000
        self.attenuator_ctr = attenuator_ctr = 0
        self.wide_band_bypass = wide_band_bypass = wideband_bypass_ctr
        self.freq = freq = f_knob
        self.firdes_tap = firdes_tap = firdes.low_pass(1, samp_rate, 10000,
                                                       4000,
                                                       firdes.WIN_HAMMING,
                                                       6.76)
        self.att = att = attenuator_ctr

        ##################################################
        # Blocks
        ##################################################
        self._wideband_bypass_ctr_options = (
            0,
            1,
        )
        self._wideband_bypass_ctr_labels = (
            "No bypass",
            "Wide Band",
        )
        self._wideband_bypass_ctr_tool_bar = Qt.QToolBar(self)
        self._wideband_bypass_ctr_tool_bar.addWidget(
            Qt.QLabel("wideband_bypass_ctr" + ": "))
        self._wideband_bypass_ctr_combo_box = Qt.QComboBox()
        self._wideband_bypass_ctr_tool_bar.addWidget(
            self._wideband_bypass_ctr_combo_box)
        for label in self._wideband_bypass_ctr_labels:
            self._wideband_bypass_ctr_combo_box.addItem(label)
        self._wideband_bypass_ctr_callback = lambda i: Qt.QMetaObject.invokeMethod(
            self._wideband_bypass_ctr_combo_box, "setCurrentIndex",
            Qt.Q_ARG("int", self._wideband_bypass_ctr_options.index(i)))
        self._wideband_bypass_ctr_callback(self.wideband_bypass_ctr)
        self._wideband_bypass_ctr_combo_box.currentIndexChanged.connect(
            lambda i: self.set_wideband_bypass_ctr(
                self._wideband_bypass_ctr_options[i]))
        self.top_layout.addWidget(self._wideband_bypass_ctr_tool_bar)
        self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c(
            1024,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            freq,  #fc
            samp_rate,  #bw
            "",  #name
            1  #number of inputs
        )
        self.qtgui_waterfall_sink_x_0.set_update_time(0.10)
        self.qtgui_waterfall_sink_x_0.enable_grid(False)

        labels = ["", "", "", "", "", "", "", "", "", ""]
        colors = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_waterfall_sink_x_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_waterfall_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_waterfall_sink_x_0.set_color_map(i, colors[i])
            self.qtgui_waterfall_sink_x_0.set_line_alpha(i, alphas[i])

        self.qtgui_waterfall_sink_x_0.set_intensity_range(-140, -80)

        self._qtgui_waterfall_sink_x_0_win = sip.wrapinstance(
            self.qtgui_waterfall_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_waterfall_sink_x_0_win)
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c(
            1024,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            freq,  #fc
            samp_rate,  #bw
            "",  #name
            1  #number of inputs
        )
        self.qtgui_freq_sink_x_0.set_update_time(0.10)
        self.qtgui_freq_sink_x_0.set_y_axis(-140, -80)
        self.qtgui_freq_sink_x_0.enable_autoscale(False)
        self.qtgui_freq_sink_x_0.enable_grid(False)
        self.qtgui_freq_sink_x_0.set_fft_average(1.0)

        labels = ["", "", "", "", "", "", "", "", "", ""]
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "green", "black", "cyan", "magenta", "yellow",
            "dark red", "dark green", "dark blue"
        ]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_freq_sink_x_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_freq_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_freq_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_freq_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i])

        self._qtgui_freq_sink_x_0_win = sip.wrapinstance(
            self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_freq_sink_x_0_win)
        self.microtelecom_perseus_0 = microtelecom.perseus(
            samp_rate, freq, 0, 0, 0, wide_band_bypass)

        self.fir_filter_xxx_0 = filter.fir_filter_ccc(4, (firdes_tap))
        self.fir_filter_xxx_0.declare_sample_delay(0)
        self._f_knob_layout = Qt.QVBoxLayout()
        self._f_knob_tool_bar = Qt.QToolBar(self)
        self._f_knob_layout.addWidget(self._f_knob_tool_bar)
        self._f_knob_tool_bar.addWidget(Qt.QLabel("Freq Hz" + ": "))

        class qwt_counter_pyslot(Qwt.QwtCounter):
            def __init__(self, parent=None):
                Qwt.QwtCounter.__init__(self, parent)

            @pyqtSlot('double')
            def setValue(self, value):
                super(Qwt.QwtCounter, self).setValue(value)

        self._f_knob_counter = qwt_counter_pyslot()
        self._f_knob_counter.setRange(7100000, 7300000, 1000)
        self._f_knob_counter.setNumButtons(2)
        self._f_knob_counter.setValue(self.f_knob)
        self._f_knob_tool_bar.addWidget(self._f_knob_counter)
        self._f_knob_counter.valueChanged.connect(self.set_f_knob)
        self._f_knob_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal,
                                            Qwt.QwtSlider.BottomScale,
                                            Qwt.QwtSlider.BgSlot)
        self._f_knob_slider.setRange(7100000, 7300000, 1000)
        self._f_knob_slider.setValue(self.f_knob)
        self._f_knob_slider.setMinimumWidth(200)
        self._f_knob_slider.valueChanged.connect(self.set_f_knob)
        self._f_knob_layout.addWidget(self._f_knob_slider)
        self.top_layout.addLayout(self._f_knob_layout)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1,
                                                 samp_rate, True)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((100, ))
        self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1)
        self.audio_sink_0 = audio.sink(samp_rate / 4, "", True)
        self._attenuator_ctr_options = (
            0,
            10,
            20,
            30,
        )
        self._attenuator_ctr_labels = (
            "0dB",
            "-10dB",
            "-20dB",
            "-30dB",
        )
        self._attenuator_ctr_tool_bar = Qt.QToolBar(self)
        self._attenuator_ctr_tool_bar.addWidget(Qt.QLabel("ATT dB" + ": "))
        self._attenuator_ctr_combo_box = Qt.QComboBox()
        self._attenuator_ctr_tool_bar.addWidget(self._attenuator_ctr_combo_box)
        for label in self._attenuator_ctr_labels:
            self._attenuator_ctr_combo_box.addItem(label)
        self._attenuator_ctr_callback = lambda i: Qt.QMetaObject.invokeMethod(
            self._attenuator_ctr_combo_box, "setCurrentIndex",
            Qt.Q_ARG("int", self._attenuator_ctr_options.index(i)))
        self._attenuator_ctr_callback(self.attenuator_ctr)
        self._attenuator_ctr_combo_box.currentIndexChanged.connect(
            lambda i: self.set_attenuator_ctr(self._attenuator_ctr_options[i]))
        self.top_layout.addWidget(self._attenuator_ctr_tool_bar)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_throttle_0, 0),
                     (self.qtgui_freq_sink_x_0, 0))
        self.connect((self.blocks_throttle_0, 0),
                     (self.qtgui_waterfall_sink_x_0, 0))
        self.connect((self.blocks_throttle_0, 0), (self.fir_filter_xxx_0, 0))
        self.connect((self.fir_filter_xxx_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.blocks_complex_to_mag_0, 0))
        self.connect((self.blocks_complex_to_mag_0, 0), (self.audio_sink_0, 0))
        self.connect((self.microtelecom_perseus_0, 0),
                     (self.blocks_throttle_0, 0))
Exemple #55
0
 def __init__(self, audiorate):
     self.block = audio.sink(audiorate, "", True)
    def __init__(self):
        gr.top_block.__init__(self, "Fm Receiver")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Fm Receiver")
        qtgui.util.check_set_qss()
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

        self.settings = Qt.QSettings("GNU Radio", "FM_Receiver")

        if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"):
            self.restoreGeometry(self.settings.value("geometry").toByteArray())
        else:
            self.restoreGeometry(
                self.settings.value("geometry", type=QtCore.QByteArray))

        ##################################################
        # Variables
        ##################################################
        self.volume = volume = 0.4
        self.transition = transition = 100
        self.samp_rate = samp_rate = 32000
        self.cutoff = cutoff = 100e3
        self.center_freq = center_freq = 92e6

        ##################################################
        # Blocks
        ##################################################
        self._volume_range = Range(0, 4, 0.2, 0.4, 200)
        self._volume_win = RangeWidget(self._volume_range, self.set_volume,
                                       "volume", "counter_slider", float)
        self.top_layout.addWidget(self._volume_win)
        self._transition_range = Range(0, 1e6, 1, 100, 200)
        self._transition_win = RangeWidget(self._transition_range,
                                           self.set_transition, "transition",
                                           "counter_slider", float)
        self.top_layout.addWidget(self._transition_win)
        self._cutoff_range = Range(50e3, 200e3, 1, 100e3, 200)
        self._cutoff_win = RangeWidget(self._cutoff_range, self.set_cutoff,
                                       "cutoff", "counter_slider", float)
        self.top_layout.addWidget(self._cutoff_win)
        self._center_freq_range = Range(88e6, 110e6, 1, 92e6, 200)
        self._center_freq_win = RangeWidget(self._center_freq_range,
                                            self.set_center_freq,
                                            "center_freq", "counter_slider",
                                            float)
        self.top_layout.addWidget(self._center_freq_win)
        self.rational_resampler_xxx_0 = filter.rational_resampler_fff(
            interpolation=48,
            decimation=500,
            taps=None,
            fractional_bw=None,
        )
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c(
            1024,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            center_freq,  #fc
            2e6,  #bw
            "",  #name
            1  #number of inputs
        )
        self.qtgui_freq_sink_x_0.set_update_time(0.10)
        self.qtgui_freq_sink_x_0.set_y_axis(-140, 10)
        self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0,
                                                  "")
        self.qtgui_freq_sink_x_0.enable_autoscale(False)
        self.qtgui_freq_sink_x_0.enable_grid(False)
        self.qtgui_freq_sink_x_0.set_fft_average(1.0)
        self.qtgui_freq_sink_x_0.enable_axis_labels(True)
        self.qtgui_freq_sink_x_0.enable_control_panel(False)

        if not True:
            self.qtgui_freq_sink_x_0.disable_legend()

        if "complex" == "float" or "complex" == "msg_float":
            self.qtgui_freq_sink_x_0.set_plot_pos_half(not True)

        labels = ['', '', '', '', '', '', '', '', '', '']
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "green", "black", "cyan", "magenta", "yellow",
            "dark red", "dark green", "dark blue"
        ]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_freq_sink_x_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_freq_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_freq_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_freq_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i])

        self._qtgui_freq_sink_x_0_win = sip.wrapinstance(
            self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_freq_sink_x_0_win)
        self.osmosdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " +
                                               '')
        self.osmosdr_source_0.set_sample_rate(2e6)
        self.osmosdr_source_0.set_center_freq(center_freq, 0)
        self.osmosdr_source_0.set_freq_corr(0, 0)
        self.osmosdr_source_0.set_dc_offset_mode(0, 0)
        self.osmosdr_source_0.set_iq_balance_mode(2, 0)
        self.osmosdr_source_0.set_gain_mode(False, 0)
        self.osmosdr_source_0.set_gain(10, 0)
        self.osmosdr_source_0.set_if_gain(20, 0)
        self.osmosdr_source_0.set_bb_gain(20, 0)
        self.osmosdr_source_0.set_antenna('', 0)
        self.osmosdr_source_0.set_bandwidth(0, 0)

        self.low_pass_filter_0 = filter.fir_filter_ccf(
            4,
            firdes.low_pass(1, 2e6, cutoff, transition, firdes.WIN_HAMMING,
                            6.76))
        self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vff(
            (volume, ))
        self.audio_sink_0 = audio.sink(48000, '', True)
        self.analog_wfm_rcv_0 = analog.wfm_rcv(
            quad_rate=500000,
            audio_decimation=1,
        )

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_wfm_rcv_0, 0),
                     (self.rational_resampler_xxx_0, 0))
        self.connect((self.blocks_multiply_const_vxx_1, 0),
                     (self.audio_sink_0, 0))
        self.connect((self.low_pass_filter_0, 0), (self.analog_wfm_rcv_0, 0))
        self.connect((self.low_pass_filter_0, 0),
                     (self.qtgui_freq_sink_x_0, 0))
        self.connect((self.osmosdr_source_0, 0), (self.low_pass_filter_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.blocks_multiply_const_vxx_1, 0))
Exemple #57
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Wbfm Transceiver")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Variables
        ##################################################
        self.tx_gain = tx_gain = 0
        self.samp_rate = samp_rate = 1000000
        self.rx_gain = rx_gain = 0
        self.nbfm_max_dev = nbfm_max_dev = 75000
        self.center_freq = center_freq = 1000000
        self.audio_rate = audio_rate = 44100
        self.audio_interp = audio_interp = 1

        ##################################################
        # Blocks
        ##################################################
        self.wxgui_scopesink2_0_0 = scopesink2.scope_sink_f(
            self.GetWin(),
            title='Osciloscope',
            sample_rate=samp_rate,
            v_scale=0,
            v_offset=0,
            t_scale=0,
            ac_couple=True,
            xy_mode=False,
            num_inputs=2,
            trig_mode=wxgui.TRIG_MODE_STRIPCHART,
            y_axis_label='Amplitude',
        )
        self.Add(self.wxgui_scopesink2_0_0.win)
        self.uhd_usrp_source_0 = uhd.usrp_source(
            ",".join(('addr=192.168.10.3', "")),
            uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ),
        )
        self.uhd_usrp_source_0.set_samp_rate(samp_rate)
        self.uhd_usrp_source_0.set_center_freq(center_freq, 0)
        self.uhd_usrp_source_0.set_gain(rx_gain, 0)
        self.uhd_usrp_source_0.set_antenna('RX2', 0)
        self.uhd_usrp_sink_0 = uhd.usrp_sink(
            ",".join(('addr=192.168.10.2', "")),
            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(center_freq, 0)
        self.uhd_usrp_sink_0.set_gain(tx_gain, 0)
        self.uhd_usrp_sink_0.set_antenna('TX/RX', 0)
        self.rational_resampler_xxx_1 = filter.rational_resampler_ccc(
            interpolation=int(samp_rate),
            decimation=int(audio_interp * audio_rate),
            taps=None,
            fractional_bw=None,
        )
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
            interpolation=int(audio_rate * audio_interp),
            decimation=int(samp_rate),
            taps=None,
            fractional_bw=None,
        )
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((0.200, ))
        self.audio_sink_0 = audio.sink(int(audio_rate), '', False)
        self.analog_wfm_tx_0 = analog.wfm_tx(
            audio_rate=int(audio_rate),
            quad_rate=int(audio_rate * audio_interp),
            tau=75e-6,
            max_dev=75e3,
            fh=-1.0,
        )
        self.analog_wfm_rcv_0 = analog.wfm_rcv(
            quad_rate=audio_interp * audio_rate,
            audio_decimation=audio_interp,
        )
        self.analog_sig_source_x_0 = analog.sig_source_f(
            audio_rate, analog.GR_COS_WAVE, 440, 1, 0)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_sig_source_x_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.analog_wfm_rcv_0, 0), (self.audio_sink_0, 0))
        self.connect((self.analog_wfm_rcv_0, 0),
                     (self.wxgui_scopesink2_0_0, 1))
        self.connect((self.analog_wfm_tx_0, 0),
                     (self.rational_resampler_xxx_1, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.analog_wfm_tx_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.wxgui_scopesink2_0_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.analog_wfm_rcv_0, 0))
        self.connect((self.rational_resampler_xxx_1, 0),
                     (self.uhd_usrp_sink_0, 0))
        self.connect((self.uhd_usrp_source_0, 0),
                     (self.rational_resampler_xxx_0, 0))
    def __init__(self, radio_id='USRP', sat_name='SIM'):
        gr.top_block.__init__(
            self,
            "/home/zleffke/captures/misc/SIM_USRP_20181103_185405.280632_UTC_250k.fc32"
        )
        Qt.QWidget.__init__(self)
        self.setWindowTitle(
            "/home/zleffke/captures/misc/SIM_USRP_20181103_185405.280632_UTC_250k.fc32"
        )
        qtgui.util.check_set_qss()
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

        self.settings = Qt.QSettings("GNU Radio", "nbfm_afsk")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Parameters
        ##################################################
        self.radio_id = radio_id
        self.sat_name = sat_name

        ##################################################
        # Variables
        ##################################################
        self.ts_str = ts_str = dt.strftime(dt.utcnow(),
                                           "%Y%m%d_%H%M%S.%f") + '_UTC'
        self.samp_rate = samp_rate = 250e3
        self.fn = fn = "{:s}_{:s}_{:s}_{:s}k.fc32".format(
            sat_name, radio_id, ts_str, str(int(samp_rate) / 1000))
        self.baud = baud = 1200

        self.xlate_taps = xlate_taps = firdes.low_pass(1.0, samp_rate,
                                                       samp_rate / 2, 1000,
                                                       firdes.WIN_HAMMING,
                                                       6.76)

        self.volume = volume = 0.02
        self.samps_per_symb = samps_per_symb = 48000 / baud
        self.rx_gain = rx_gain = 30
        self.rx_freq = rx_freq = 440.39e6
        self.offset = offset = 0
        self.fsk_deviation_hz = fsk_deviation_hz = 4000
        self.fp = fp = "/home/zleffke/captures/misc/{:s}".format(fn)
        self.decim = decim = 5
        self.audio_lpf_cutoff = audio_lpf_cutoff = 10e3

        ##################################################
        # Blocks
        ##################################################
        self._volume_tool_bar = Qt.QToolBar(self)
        self._volume_tool_bar.addWidget(Qt.QLabel("volume" + ": "))
        self._volume_line_edit = Qt.QLineEdit(str(self.volume))
        self._volume_tool_bar.addWidget(self._volume_line_edit)
        self._volume_line_edit.returnPressed.connect(lambda: self.set_volume(
            eng_notation.str_to_num(
                str(self._volume_line_edit.text().toAscii()))))
        self.top_grid_layout.addWidget(self._volume_tool_bar, 10, 2, 1, 1)
        for r in range(10, 11):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(2, 3):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._rx_gain_tool_bar = Qt.QToolBar(self)
        self._rx_gain_tool_bar.addWidget(Qt.QLabel('GAIN' + ": "))
        self._rx_gain_line_edit = Qt.QLineEdit(str(self.rx_gain))
        self._rx_gain_tool_bar.addWidget(self._rx_gain_line_edit)
        self._rx_gain_line_edit.returnPressed.connect(lambda: self.set_rx_gain(
            eng_notation.str_to_num(
                str(self._rx_gain_line_edit.text().toAscii()))))
        self.top_grid_layout.addWidget(self._rx_gain_tool_bar, 10, 0, 1, 1)
        for r in range(10, 11):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 1):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._rx_freq_tool_bar = Qt.QToolBar(self)
        self._rx_freq_tool_bar.addWidget(Qt.QLabel('FREQ' + ": "))
        self._rx_freq_line_edit = Qt.QLineEdit(str(self.rx_freq))
        self._rx_freq_tool_bar.addWidget(self._rx_freq_line_edit)
        self._rx_freq_line_edit.returnPressed.connect(lambda: self.set_rx_freq(
            eng_notation.str_to_num(
                str(self._rx_freq_line_edit.text().toAscii()))))
        self.top_grid_layout.addWidget(self._rx_freq_tool_bar, 10, 1, 1, 1)
        for r in range(10, 11):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(1, 2):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._offset_tool_bar = Qt.QToolBar(self)
        self._offset_tool_bar.addWidget(Qt.QLabel('OFFSET' + ": "))
        self._offset_line_edit = Qt.QLineEdit(str(self.offset))
        self._offset_tool_bar.addWidget(self._offset_line_edit)
        self._offset_line_edit.returnPressed.connect(lambda: self.set_offset(
            eng_notation.str_to_num(
                str(self._offset_line_edit.text().toAscii()))))
        self.top_grid_layout.addWidget(self._offset_tool_bar, 10, 5, 1, 2)
        for r in range(10, 11):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(5, 7):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._audio_lpf_cutoff_tool_bar = Qt.QToolBar(self)
        self._audio_lpf_cutoff_tool_bar.addWidget(
            Qt.QLabel("audio_lpf_cutoff" + ": "))
        self._audio_lpf_cutoff_line_edit = Qt.QLineEdit(
            str(self.audio_lpf_cutoff))
        self._audio_lpf_cutoff_tool_bar.addWidget(
            self._audio_lpf_cutoff_line_edit)
        self._audio_lpf_cutoff_line_edit.returnPressed.connect(
            lambda: self.set_audio_lpf_cutoff(
                eng_notation.str_to_num(
                    str(self._audio_lpf_cutoff_line_edit.text().toAscii()))))
        self.top_grid_layout.addWidget(self._audio_lpf_cutoff_tool_bar, 10, 3,
                                       1, 2)
        for r in range(10, 11):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(3, 5):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.vtgs_ax25_deframer_0 = vtgs.ax25_deframer()
        self.vtgs_afskdemod_0 = vtgs.afskdemod(samps_per_symb, baud, 1200,
                                               2200)
        self.vcc_qt_hex_text_0 = vcc.qt_hex_text()
        self._vcc_qt_hex_text_0_win = self.vcc_qt_hex_text_0
        self.top_grid_layout.addWidget(self._vcc_qt_hex_text_0_win, 4, 4, 2, 4)
        for r in range(4, 6):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(4, 8):
            self.top_grid_layout.setColumnStretch(c, 1)

        self.uhd_usrp_source_0 = uhd.usrp_source(
            ",".join(("", "")),
            uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ),
        )
        self.uhd_usrp_source_0.set_samp_rate(samp_rate)
        self.uhd_usrp_source_0.set_center_freq(
            uhd.tune_request(rx_freq, samp_rate / 2), 0)
        self.uhd_usrp_source_0.set_gain(rx_gain, 0)
        self.uhd_usrp_source_0.set_antenna('RX2', 0)
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
            interpolation=48,
            decimation=50,
            taps=None,
            fractional_bw=None,
        )
        self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c(
            2048,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate / decim,  #bw
            "",  #name
            1  #number of inputs
        )
        self.qtgui_waterfall_sink_x_0.set_update_time(0.010)
        self.qtgui_waterfall_sink_x_0.enable_grid(False)
        self.qtgui_waterfall_sink_x_0.enable_axis_labels(True)

        if not True:
            self.qtgui_waterfall_sink_x_0.disable_legend()

        if "complex" == "float" or "complex" == "msg_float":
            self.qtgui_waterfall_sink_x_0.set_plot_pos_half(not True)

        labels = ['', '', '', '', '', '', '', '', '', '']
        colors = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_waterfall_sink_x_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_waterfall_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_waterfall_sink_x_0.set_color_map(i, colors[i])
            self.qtgui_waterfall_sink_x_0.set_line_alpha(i, alphas[i])

        self.qtgui_waterfall_sink_x_0.set_intensity_range(-140, -40)

        self._qtgui_waterfall_sink_x_0_win = sip.wrapinstance(
            self.qtgui_waterfall_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_waterfall_sink_x_0_win, 0,
                                       4, 4, 4)
        for r in range(0, 4):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(4, 8):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_time_sink_x_0 = qtgui.time_sink_f(
            1024,  #size
            samp_rate / decim / 50 * 48,  #samp_rate
            "",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0.set_y_axis(-1, 1)

        self.qtgui_time_sink_x_0.set_y_label('Amplitude', "")

        self.qtgui_time_sink_x_0.enable_tags(-1, True)
        self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE,
                                                  qtgui.TRIG_SLOPE_POS, 0.0, 0,
                                                  0, "")
        self.qtgui_time_sink_x_0.enable_autoscale(False)
        self.qtgui_time_sink_x_0.enable_grid(False)
        self.qtgui_time_sink_x_0.enable_axis_labels(True)
        self.qtgui_time_sink_x_0.enable_control_panel(False)
        self.qtgui_time_sink_x_0.enable_stem_plot(False)

        if not True:
            self.qtgui_time_sink_x_0.disable_legend()

        labels = ['', '', '', '', '', '', '', '', '', '']
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "green", "black", "cyan", "magenta", "yellow",
            "dark red", "dark green", "blue"
        ]
        styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]

        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_time_sink_x_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_0.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_0.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i])

        self._qtgui_time_sink_x_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_win, 4, 0, 2,
                                       4)
        for r in range(4, 6):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 4):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c(
            2048,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate / decim,  #bw
            "",  #name
            1  #number of inputs
        )
        self.qtgui_freq_sink_x_0.set_update_time(0.010)
        self.qtgui_freq_sink_x_0.set_y_axis(-90, -10)
        self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0,
                                                  "")
        self.qtgui_freq_sink_x_0.enable_autoscale(False)
        self.qtgui_freq_sink_x_0.enable_grid(True)
        self.qtgui_freq_sink_x_0.set_fft_average(1.0)
        self.qtgui_freq_sink_x_0.enable_axis_labels(True)
        self.qtgui_freq_sink_x_0.enable_control_panel(True)

        if not True:
            self.qtgui_freq_sink_x_0.disable_legend()

        if "complex" == "float" or "complex" == "msg_float":
            self.qtgui_freq_sink_x_0.set_plot_pos_half(not True)

        labels = ['', '', '', '', '', '', '', '', '', '']
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "green", "black", "cyan", "magenta", "yellow",
            "dark red", "dark green", "dark blue"
        ]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_freq_sink_x_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_freq_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_freq_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_freq_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i])

        self._qtgui_freq_sink_x_0_win = sip.wrapinstance(
            self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win, 0, 0, 4,
                                       4)
        for r in range(0, 4):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 4):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.low_pass_filter_0_0_0 = filter.fir_filter_fff(
            1,
            firdes.low_pass(1, samp_rate / decim / 50 * 48, audio_lpf_cutoff,
                            2e3, firdes.WIN_HAMMING, 6.76))
        self.low_pass_filter_0 = filter.fir_filter_ccf(
            decim,
            firdes.low_pass(1, samp_rate, 25e3, 2e3, firdes.WIN_HAMMING, 6.76))
        self.kiss_pdu_to_kiss_0 = kiss.pdu_to_kiss()
        self.hilbert_fc_0 = filter.hilbert_fc(65, firdes.WIN_HAMMING, 6.76)
        self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(
            1, (xlate_taps), offset, samp_rate)
        self.fosphor_glfw_sink_c_0 = fosphor.glfw_sink_c()
        self.fosphor_glfw_sink_c_0.set_fft_window(window.WIN_BLACKMAN_hARRIS)
        self.fosphor_glfw_sink_c_0.set_frequency_range(0, samp_rate)
        self.blocks_socket_pdu_0 = blocks.socket_pdu("TCP_SERVER", '0.0.0.0',
                                                     '8000', 10000, False)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff(
            (volume, ))
        self.blocks_message_debug_0 = blocks.message_debug()
        self.audio_sink_0 = audio.sink(48000, '', True)
        self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(
            samp_rate / (2 * math.pi * fsk_deviation_hz / 8.0))
        self.analog_agc2_xx_0 = analog.agc2_cc(1e-1, 1e-2, 1.0, 1.0)
        self.analog_agc2_xx_0.set_max_gain(65536)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.kiss_pdu_to_kiss_0, 'out'),
                         (self.blocks_message_debug_0, 'print'))
        self.msg_connect((self.kiss_pdu_to_kiss_0, 'out'),
                         (self.blocks_socket_pdu_0, 'pdus'))
        self.msg_connect((self.kiss_pdu_to_kiss_0, 'out'),
                         (self.vcc_qt_hex_text_0, 'pdus'))
        self.msg_connect((self.vtgs_ax25_deframer_0, 'valid_frames'),
                         (self.kiss_pdu_to_kiss_0, 'in'))
        self.connect((self.analog_agc2_xx_0, 0),
                     (self.freq_xlating_fir_filter_xxx_0, 0))
        self.connect((self.analog_quadrature_demod_cf_0, 0),
                     (self.low_pass_filter_0_0_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.audio_sink_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.hilbert_fc_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.qtgui_time_sink_x_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0),
                     (self.low_pass_filter_0, 0))
        self.connect((self.hilbert_fc_0, 0), (self.vtgs_afskdemod_0, 0))
        self.connect((self.low_pass_filter_0, 0),
                     (self.qtgui_freq_sink_x_0, 0))
        self.connect((self.low_pass_filter_0, 0),
                     (self.qtgui_waterfall_sink_x_0, 0))
        self.connect((self.low_pass_filter_0, 0),
                     (self.rational_resampler_xxx_0, 0))
        self.connect((self.low_pass_filter_0_0_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.analog_quadrature_demod_cf_0, 0))
        self.connect((self.uhd_usrp_source_0, 0), (self.analog_agc2_xx_0, 0))
        self.connect((self.uhd_usrp_source_0, 0),
                     (self.fosphor_glfw_sink_c_0, 0))
        self.connect((self.vtgs_afskdemod_0, 0),
                     (self.vtgs_ax25_deframer_0, 0))
Exemple #59
0
    def __init__(self):
        gr.top_block.__init__(self, "Fm Demod")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Fm Demod")
        qtgui.util.check_set_qss()
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

        self.settings = Qt.QSettings("GNU Radio", "fm_demod")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())


        ##################################################
        # Variables
        ##################################################
        self.vol = vol = .01
        self.samp_rate = samp_rate = 1e6
        self.rx_gain = rx_gain = 35
        self.interp = interp = 1
        self.freq = freq = 461.25e6
        self.decim = decim = 20

        ##################################################
        # Blocks
        ##################################################
        self._vol_tool_bar = Qt.QToolBar(self)
        self._vol_tool_bar.addWidget(Qt.QLabel("vol"+": "))
        self._vol_line_edit = Qt.QLineEdit(str(self.vol))
        self._vol_tool_bar.addWidget(self._vol_line_edit)
        self._vol_line_edit.returnPressed.connect(
        	lambda: self.set_vol(eng_notation.str_to_num(str(self._vol_line_edit.text().toAscii()))))
        self.top_grid_layout.addWidget(self._vol_tool_bar, 4, 6, 1, 2)
        for r in range(4, 5):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(6, 8):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._samp_rate_tool_bar = Qt.QToolBar(self)
        self._samp_rate_tool_bar.addWidget(Qt.QLabel("samp_rate"+": "))
        self._samp_rate_line_edit = Qt.QLineEdit(str(self.samp_rate))
        self._samp_rate_tool_bar.addWidget(self._samp_rate_line_edit)
        self._samp_rate_line_edit.returnPressed.connect(
        	lambda: self.set_samp_rate(eng_notation.str_to_num(str(self._samp_rate_line_edit.text().toAscii()))))
        self.top_grid_layout.addWidget(self._samp_rate_tool_bar, 4, 4, 1, 2)
        for r in range(4, 5):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(4, 6):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._rx_gain_tool_bar = Qt.QToolBar(self)
        self._rx_gain_tool_bar.addWidget(Qt.QLabel("rx_gain"+": "))
        self._rx_gain_line_edit = Qt.QLineEdit(str(self.rx_gain))
        self._rx_gain_tool_bar.addWidget(self._rx_gain_line_edit)
        self._rx_gain_line_edit.returnPressed.connect(
        	lambda: self.set_rx_gain(eng_notation.str_to_num(str(self._rx_gain_line_edit.text().toAscii()))))
        self.top_grid_layout.addWidget(self._rx_gain_tool_bar, 4, 2, 1, 2)
        for r in range(4, 5):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(2, 4):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._freq_tool_bar = Qt.QToolBar(self)
        self._freq_tool_bar.addWidget(Qt.QLabel("freq"+": "))
        self._freq_line_edit = Qt.QLineEdit(str(self.freq))
        self._freq_tool_bar.addWidget(self._freq_line_edit)
        self._freq_line_edit.returnPressed.connect(
        	lambda: self.set_freq(eng_notation.str_to_num(str(self._freq_line_edit.text().toAscii()))))
        self.top_grid_layout.addWidget(self._freq_tool_bar, 4, 0, 1, 2)
        for r in range(4, 5):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 2):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.uhd_usrp_source_0 = uhd.usrp_source(
        	",".join(("", "")),
        	uhd.stream_args(
        		cpu_format="fc32",
        		channels=range(1),
        	),
        )
        self.uhd_usrp_source_0.set_samp_rate(samp_rate)
        self.uhd_usrp_source_0.set_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS)
        self.uhd_usrp_source_0.set_center_freq(uhd.tune_request(freq, samp_rate/2), 0)
        self.uhd_usrp_source_0.set_gain(rx_gain, 0)
        self.uhd_usrp_source_0.set_antenna('RX2', 0)
        self.uhd_usrp_source_0.set_auto_dc_offset(True, 0)
        self.uhd_usrp_source_0.set_auto_iq_balance(True, 0)
        self.rational_resampler_xxx_0_0 = filter.rational_resampler_fff(
                interpolation=24,
                decimation=25,
                taps=None,
                fractional_bw=None,
        )
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
                interpolation=interp,
                decimation=decim,
                taps=None,
                fractional_bw=None,
        )
        self.qtgui_freq_sink_x_0_0 = qtgui.freq_sink_c(
        	2048, #size
        	firdes.WIN_BLACKMAN_hARRIS, #wintype
        	0, #fc
        	samp_rate/decim*interp, #bw
        	"", #name
        	1 #number of inputs
        )
        self.qtgui_freq_sink_x_0_0.set_update_time(0.0010)
        self.qtgui_freq_sink_x_0_0.set_y_axis(-140, 10)
        self.qtgui_freq_sink_x_0_0.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "")
        self.qtgui_freq_sink_x_0_0.enable_autoscale(False)
        self.qtgui_freq_sink_x_0_0.enable_grid(True)
        self.qtgui_freq_sink_x_0_0.set_fft_average(1.0)
        self.qtgui_freq_sink_x_0_0.enable_axis_labels(True)
        self.qtgui_freq_sink_x_0_0.enable_control_panel(False)

        if not False:
          self.qtgui_freq_sink_x_0_0.disable_legend()

        if "complex" == "float" or "complex" == "msg_float":
          self.qtgui_freq_sink_x_0_0.set_plot_pos_half(not True)

        labels = ['', 'processed', '', '', '',
                  '', '', '', '', '']
        widths = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        colors = ["blue", "red", "green", "black", "cyan",
                  "magenta", "yellow", "dark red", "dark green", "dark blue"]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_freq_sink_x_0_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_freq_sink_x_0_0.set_line_label(i, labels[i])
            self.qtgui_freq_sink_x_0_0.set_line_width(i, widths[i])
            self.qtgui_freq_sink_x_0_0.set_line_color(i, colors[i])
            self.qtgui_freq_sink_x_0_0.set_line_alpha(i, alphas[i])

        self._qtgui_freq_sink_x_0_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_0_win, 0, 4, 4, 4)
        for r in range(0, 4):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(4, 8):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.fosphor_qt_sink_c_0 = fosphor.qt_sink_c()
        self.fosphor_qt_sink_c_0.set_fft_window(window.WIN_BLACKMAN_hARRIS)
        self.fosphor_qt_sink_c_0.set_frequency_range(0, samp_rate)
        self._fosphor_qt_sink_c_0_win = sip.wrapinstance(self.fosphor_qt_sink_c_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._fosphor_qt_sink_c_0_win, 0, 0, 4, 4)
        for r in range(0, 4):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 4):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((vol, ))
        self.audio_sink_0 = audio.sink(48000, '', True)
        self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(samp_rate/(2*math.pi*samp_rate/8.0))



        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_quadrature_demod_cf_0, 0), (self.rational_resampler_xxx_0_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.audio_sink_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0), (self.analog_quadrature_demod_cf_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0), (self.qtgui_freq_sink_x_0_0, 0))
        self.connect((self.rational_resampler_xxx_0_0, 0), (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.uhd_usrp_source_0, 0), (self.fosphor_qt_sink_c_0, 0))
        self.connect((self.uhd_usrp_source_0, 0), (self.rational_resampler_xxx_0, 0))
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Top Block")
        _icon_path = "D:\Program Files\GNURadio-3.7\share\icons\hicolor\scalable/apps\gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Variables
        ##################################################
        self.volume = volume = 50
        self.samp_rate = samp_rate = 2e6
        self.rf_gain = rf_gain = 15
        self.rf_freq = rf_freq = 100e6
        self.down_rate = down_rate = 200000

        ##################################################
        # Blocks
        ##################################################
        _volume_sizer = wx.BoxSizer(wx.VERTICAL)
        self._volume_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_volume_sizer,
            value=self.volume,
            callback=self.set_volume,
            label='volume',
            converter=forms.float_converter(),
            proportion=0,
        )
        self._volume_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_volume_sizer,
            value=self.volume,
            callback=self.set_volume,
            minimum=0,
            maximum=100,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_volume_sizer, 1, 5, 1, 8)
        _rf_gain_sizer = wx.BoxSizer(wx.VERTICAL)
        self._rf_gain_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_rf_gain_sizer,
            value=self.rf_gain,
            callback=self.set_rf_gain,
            label='rf_gain',
            converter=forms.float_converter(),
            proportion=0,
        )
        self._rf_gain_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_rf_gain_sizer,
            value=self.rf_gain,
            callback=self.set_rf_gain,
            minimum=10,
            maximum=70,
            num_steps=12,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_rf_gain_sizer, 1, 0, 1, 2)
        _rf_freq_sizer = wx.BoxSizer(wx.VERTICAL)
        self._rf_freq_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_rf_freq_sizer,
            value=self.rf_freq,
            callback=self.set_rf_freq,
            label='rf_freq',
            converter=forms.float_converter(),
            proportion=0,
        )
        self._rf_freq_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_rf_freq_sizer,
            value=self.rf_freq,
            callback=self.set_rf_freq,
            minimum=80e6,
            maximum=200e6,
            num_steps=300,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_rf_freq_sizer, 1, 2, 1, 2)
        self.wxgui_fftsink2_1 = fftsink2.fft_sink_f(
            self.GetWin(),
            baseband_freq=0,
            y_per_div=10,
            y_divs=10,
            ref_level=0,
            ref_scale=2.0,
            sample_rate=down_rate,
            fft_size=1024,
            fft_rate=15,
            average=False,
            avg_alpha=None,
            title='Demod out',
            peak_hold=False,
        )
        self.Add(self.wxgui_fftsink2_1.win)
        self.wxgui_fftsink2_0 = fftsink2.fft_sink_c(
            self.GetWin(),
            baseband_freq=rf_freq,
            y_per_div=10,
            y_divs=10,
            ref_level=0,
            ref_scale=2.0,
            sample_rate=samp_rate,
            fft_size=1024,
            fft_rate=15,
            average=False,
            avg_alpha=None,
            title='FFT Plot',
            peak_hold=False,
        )
        self.Add(self.wxgui_fftsink2_0.win)
        self.rational_resampler_xxx_0 = filter.rational_resampler_fff(
            interpolation=48,
            decimation=200,
            taps=None,
            fractional_bw=None,
        )
        self.low_pass_filter_0 = filter.fir_filter_ccf(
            int(samp_rate / down_rate),
            firdes.low_pass(1, samp_rate, 6e3, 200, firdes.WIN_HAMMING, 6.76))
        self.limesdr_source_0 = limesdr.source('', 0, '')
        self.limesdr_source_0.set_sample_rate(samp_rate)
        self.limesdr_source_0.set_center_freq(rf_freq, 0)
        self.limesdr_source_0.set_bandwidth(1.5e6, 0)
        self.limesdr_source_0.set_gain(rf_gain, 0)
        self.limesdr_source_0.set_antenna(255, 0)

        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff(
            (volume / 100, ))
        self.audio_sink_0 = audio.sink(48000, '', True)
        self.analog_am_demod_cf_0 = analog.am_demod_cf(
            channel_rate=down_rate,
            audio_decim=1,
            audio_pass=10000,
            audio_stop=11000,
        )

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_am_demod_cf_0, 0),
                     (self.rational_resampler_xxx_0, 0))
        self.connect((self.analog_am_demod_cf_0, 0),
                     (self.wxgui_fftsink2_1, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.audio_sink_0, 0))
        self.connect((self.limesdr_source_0, 0), (self.low_pass_filter_0, 0))
        self.connect((self.limesdr_source_0, 0), (self.wxgui_fftsink2_0, 0))
        self.connect((self.low_pass_filter_0, 0),
                     (self.analog_am_demod_cf_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))