Example #1
0
    def __init__(self, chan_rate, threshold, freq):
        gr.hier_block2.__init__(self, "indri_radio_channel",
                                gr.io_signature(1, 1, gr.sizeof_gr_complex),
                                gr.io_signature(1, 1, gr.sizeof_float))

        self.chan_rate = chan_rate
        self.threshold = threshold
        self.freq = freq

        self.pwr_squelch = analog.pwr_squelch_cc(self.threshold, 0.001, 0,
                                                 True)

        self.nbfm_rx = analog.nbfm_rx(
            audio_rate=self.chan_rate,
            quad_rate=self.chan_rate,
            tau=75e-6,
            max_dev=6.25e3,
        )

        self.power_probe = analog.probe_avg_mag_sqrd_cf(self.threshold, 0.001)
        self.null_sink = blocks.null_sink(gr.sizeof_float)

        self.tg = 0
        self.closed_once = False  # have we de-squelched since tg assigned?

        self.power_samples = 0
        self.power_total = 0.0

        self.connect(self, self.power_probe, self.null_sink)

        self.connect(self, self.pwr_squelch, self.nbfm_rx, self)
Example #2
0
    def __init__(self):
        gr.hier_block2.__init__(
            self, "NBFM Chain",
            gr.io_signature(1, 1, gr.sizeof_gr_complex*1),
            gr.io_signature(1, 1, gr.sizeof_float*1),
        )

        ##################################################
        # Blocks
        ##################################################
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
                interpolation=192000,
                decimation=2400000,
                taps=None,
                fractional_bw=None,
        )
        self.low_pass_filter_1 = filter.fir_filter_ccf(1, firdes.low_pass(
        	1, 192000, 5e3, 5e3, firdes.WIN_HAMMING, 6.76))
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((5, ))
        self.analog_nbfm_rx_0 = analog.nbfm_rx(
        	audio_rate=48000,
        	quad_rate=192000,
        	tau=75e-6,
        	max_dev=2.5e3,
        )

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_nbfm_rx_0, 0), (self.blocks_multiply_const_vxx_0, 0))    
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self, 0))    
        self.connect((self.low_pass_filter_1, 0), (self.analog_nbfm_rx_0, 0))    
        self.connect((self, 0), (self.rational_resampler_xxx_0, 0))    
        self.connect((self.rational_resampler_xxx_0, 0), (self.low_pass_filter_1, 0))    
Example #3
0
    def __init__(self, squelch, quad_rate, audio_rate, max_dev, out_scale,
                 freq, command):
        gr.hier_block2.__init__(self, "FMtoCommand",
                                gr.io_signature(1, 1, gr.sizeof_gr_complex),
                                gr.io_signature(0, 0, gr.sizeof_gr_complex))

        analog_pwr_squelch = analog.pwr_squelch_cc(squelch, 1e-4, 0, True)
        analog_nbfm_rx = analog.nbfm_rx(
            audio_rate=audio_rate,
            quad_rate=quad_rate,
            tau=75e-6,
            max_dev=max_dev,
        )
        rational_resampler = filter.rational_resampler_fff(
            interpolation=441,
            decimation=500,
            taps=None,
            fractional_bw=None,
        )
        blocks_float_to_short = blocks.float_to_short(1, out_scale)

        self.p = subprocess.Popen(command, shell=True, stdin=subprocess.PIPE)
        sink = blocks.file_descriptor_sink(gr.sizeof_short * 1,
                                           self.p.stdin.fileno())
        self.connect(self, (analog_pwr_squelch, 0))
        self.connect((analog_pwr_squelch, 0), (analog_nbfm_rx, 0))
        self.connect((analog_nbfm_rx, 0), (rational_resampler, 0))
        self.connect((rational_resampler, 0), (blocks_float_to_short, 0))
        self.connect((blocks_float_to_short, 0), (sink, 0))
Example #4
0
    def __init__(self, squelch, quad_rate, audio_rate, max_dev, out_scale, freq, command):
        gr.hier_block2.__init__(self, "FMtoCommand",
                                    gr.io_signature(1, 1, gr.sizeof_gr_complex),
                                    gr.io_signature(0, 0, gr.sizeof_gr_complex))

        analog_pwr_squelch = analog.pwr_squelch_cc(squelch, 1e-4, 0, True)
        analog_nbfm_rx = analog.nbfm_rx(
        	audio_rate = audio_rate,
            quad_rate = quad_rate,
        	tau = 75e-6,
        	max_dev = max_dev,
          )
        rational_resampler = filter.rational_resampler_fff(
            interpolation = 441,
            decimation = 500,
            taps = None,
            fractional_bw = None,
        )
        blocks_float_to_short = blocks.float_to_short(1, out_scale)

        self.p = subprocess.Popen(command, shell = True, stdin = subprocess.PIPE)
        sink = blocks.file_descriptor_sink(gr.sizeof_short*1, self.p.stdin.fileno())
        self.connect(self, (analog_pwr_squelch, 0))
        self.connect((analog_pwr_squelch, 0), (analog_nbfm_rx, 0))
        self.connect((analog_nbfm_rx, 0), (rational_resampler, 0))
        self.connect((rational_resampler, 0), (blocks_float_to_short, 0))
        self.connect((blocks_float_to_short, 0), (sink, 0))
Example #5
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))
Example #6
0
    def __init__(self):
        gr.top_block.__init__(self, "Aprs Uhd")

        ##################################################
        # Variables
        ##################################################
        self.tuner_offset = tuner_offset = 10e3
        self.samp_rate = samp_rate = 19200
        self.rf_samp_rate = rf_samp_rate = 1000000

        ##################################################
        # Blocks
        ##################################################
        self.rational_resampler_xxx_0 = filter.rational_resampler_fff(
            interpolation=samp_rate,
            decimation=rf_samp_rate,
            taps=None,
            fractional_bw=None,
        )
        self.low_pass_filter_0 = filter.fir_filter_ccf(
            1,
            firdes.low_pass(1, rf_samp_rate, 8000, 10000, firdes.WIN_HAMMING,
                            6.76))
        self.digital_hdlc_deframer_bp_0 = digital.hdlc_deframer_bp(15, 500)
        self.bruninga_hdlc_to_ax25_1 = bruninga.hdlc_to_ax25()
        self.bruninga_fsk_demod_0 = bruninga.fsk_demod(samp_rate)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1,
                                                 samp_rate, True)
        self.blocks_rotator_cc_0 = blocks.rotator_cc(
            2 * math.pi * -tuner_offset / rf_samp_rate)
        self.blocks_file_source_0_0 = blocks.file_source(
            gr.sizeof_gr_complex * 1,
            '/home/ben-mccall/Desktop/flowgraphs/TJ_APRS_CAPTURES/1MHz_144_39MHz_recording_KN4DTQ.bin',
            True)
        self.analog_nbfm_rx_0 = analog.nbfm_rx(
            audio_rate=rf_samp_rate,
            quad_rate=rf_samp_rate,
            tau=75e-6,
            max_dev=5e3,
        )

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.digital_hdlc_deframer_bp_0, 'out'),
                         (self.bruninga_hdlc_to_ax25_1, 'in'))
        self.connect((self.analog_nbfm_rx_0, 0),
                     (self.rational_resampler_xxx_0, 0))
        self.connect((self.blocks_file_source_0_0, 0),
                     (self.blocks_throttle_0, 0))
        self.connect((self.blocks_rotator_cc_0, 0),
                     (self.low_pass_filter_0, 0))
        self.connect((self.blocks_throttle_0, 0),
                     (self.blocks_rotator_cc_0, 0))
        self.connect((self.bruninga_fsk_demod_0, 0),
                     (self.digital_hdlc_deframer_bp_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.bruninga_fsk_demod_0, 0))
Example #7
0
    def __init__(self):
        gr.top_block.__init__(self)

        self._nsamples = 1000000
        self._audio_rate = 8000

        # Set up N channels with their own baseband and IF frequencies
        self._N = 5
        chspacing = 16000
        freq = [10, 20, 30, 40, 50]
        f_lo = [0, 1*chspacing, -1*chspacing, 2*chspacing, -2*chspacing]

        self._if_rate = 4*self._N*self._audio_rate

        # Create a signal source and frequency modulate it
        self.sum = blocks.add_cc()
        for n in xrange(self._N):
            sig = analog.sig_source_f(self._audio_rate, analog.GR_SIN_WAVE, freq[n], 0.5)
            fm = fmtx(f_lo[n], self._audio_rate, self._if_rate)
            self.connect(sig, fm)
            self.connect(fm, (self.sum, n))

        self.head = blocks.head(gr.sizeof_gr_complex, self._nsamples)
        self.snk_tx = blocks.vector_sink_c()
        self.channel = channels.channel_model(0.1)

        self.connect(self.sum, self.head, self.channel, self.snk_tx)


        # Design the channlizer
        self._M = 10
        bw = chspacing/2.0
        t_bw = chspacing/10.0
        self._chan_rate = self._if_rate / self._M
        self._taps = filter.firdes.low_pass_2(1, self._if_rate, bw, t_bw,
                                              attenuation_dB=100,
                                              window=filter.firdes.WIN_BLACKMAN_hARRIS)
        tpc = math.ceil(float(len(self._taps)) /  float(self._M))

        print "Number of taps:     ", len(self._taps)
        print "Number of channels: ", self._M
        print "Taps per channel:   ", tpc

        self.pfb = filter.pfb.channelizer_ccf(self._M, self._taps)

        self.connect(self.channel, self.pfb)

        # Create a file sink for each of M output channels of the filter and connect it
        self.fmdet = list()
        self.squelch = list()
        self.snks = list()
        for i in xrange(self._M):
            self.fmdet.append(analog.nbfm_rx(self._audio_rate, self._chan_rate))
            self.squelch.append(analog.standard_squelch(self._audio_rate*10))
            self.snks.append(blocks.vector_sink_f())
            self.connect((self.pfb, i), self.fmdet[i], self.squelch[i], self.snks[i])
Example #8
0
    def __init__(self):
        gr.top_block.__init__(self)

        self._nsamples = 1000000
        self._audio_rate = 8000

        # Set up N channels with their own baseband and IF frequencies
        self._N = 5
        chspacing = 16000
        freq = [10, 20, 30, 40, 50]
        f_lo = [0, 1*chspacing, -1*chspacing, 2*chspacing, -2*chspacing]

        self._if_rate = 4*self._N*self._audio_rate

        # Create a signal source and frequency modulate it
        self.sum = blocks.add_cc()
        for n in range(self._N):
            sig = analog.sig_source_f(self._audio_rate, analog.GR_SIN_WAVE, freq[n], 0.5)
            fm = fmtx(f_lo[n], self._audio_rate, self._if_rate)
            self.connect(sig, fm)
            self.connect(fm, (self.sum, n))

        self.head = blocks.head(gr.sizeof_gr_complex, self._nsamples)
        self.snk_tx = blocks.vector_sink_c()
        self.channel = channels.channel_model(0.1)

        self.connect(self.sum, self.head, self.channel, self.snk_tx)


        # Design the channlizer
        self._M = 10
        bw = chspacing / 2.0
        t_bw = chspacing / 10.0
        self._chan_rate = self._if_rate / self._M
        self._taps = filter.firdes.low_pass_2(1, self._if_rate, bw, t_bw,
                                              attenuation_dB=100,
                                              window=filter.firdes.WIN_BLACKMAN_hARRIS)
        tpc = math.ceil(float(len(self._taps)) / float(self._M))

        print("Number of taps:     ", len(self._taps))
        print("Number of channels: ", self._M)
        print("Taps per channel:   ", tpc)

        self.pfb = filter.pfb.channelizer_ccf(self._M, self._taps)

        self.connect(self.channel, self.pfb)

        # Create a file sink for each of M output channels of the filter and connect it
        self.fmdet = list()
        self.squelch = list()
        self.snks = list()
        for i in range(self._M):
            self.fmdet.append(analog.nbfm_rx(self._audio_rate, self._chan_rate))
            self.squelch.append(analog.standard_squelch(self._audio_rate*10))
            self.snks.append(blocks.vector_sink_f())
            self.connect((self.pfb, i), self.fmdet[i], self.squelch[i], self.snks[i])
Example #9
0
    def __init__(self):
        gr.top_block.__init__(self, "Fm Rec")

        ##################################################
        # Variables
        ##################################################
        self.audio_samp = audio_samp = 44100
        self.quad_rate = quad_rate = 5 * audio_samp
        self.samp_rate = samp_rate = 2 * quad_rate
        self.freq = freq = 448.925e6

        ##################################################
        # Blocks
        ##################################################
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
            interpolation=2,
            decimation=1,
            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, 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.audio_sink_0 = audio.sink(audio_samp, "", True)
        self.analog_nbfm_rx_0 = analog.nbfm_rx(
            audio_rate=audio_samp,
            quad_rate=int(quad_rate),
            tau=75e-6,
            max_dev=5e3,
        )

        ##################################################
        # Connections
        ##################################################
        self.connect((self.osmosdr_source_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.audio_sink_0, 0))
Example #10
0
    def update(self, rxcenter, txcenter, rxsps, txsps, fast=False):
        """
		Updates the module by its parameters. Supports a full reconfiguration
		and a fast reconfiguration for only simple changes such as volume, squelch,
		frequency, and audiosps which can be changed without much computational expense.
		"""
        self.rxsps = rxsps
        self.txsps = txsps

        # self.freq, self.bw, self.bwdrop, self.gain, self.vol, self.isps, self.sq

        freq = self.freq.get_value()
        bw = self.bw.get_value()
        bwdrop = self.bwdrop.get_value()
        gain = self.gain.get_value()
        vol = self.vol.get_value()
        sq = self.sq.get_value()
        dev = self.dev.get_value()

        taps = filter.firdes.low_pass(gain, sps, bw, bwdrop,
                                      filter.firdes.WIN_BLACKMAN)

        # Turn it off to disconnect them before the variable contents
        # below are replaced.
        was_active = self.active
        self.off()

        self.shiftsrc = analog.sig_source_c(sps, analog.GR_COS_WAVE, -freq,
                                            0.1, 0)
        self.shifter = blocks.multiply_cc()
        self.decfilter = filter.fir_filter_ccf(1, taps)

        self.fmdemod = analog.nbfm_rx(
            audio_rate=16000,
            quad_rate=sps,
            tau=float(tau) * 0.000000001,
            max_dev=dev,
        )

        self.sqblock = analog.standard_squelch(isps)
        self.sqblock.set_threshold(float(sq) / 100.0)
        self.volblock = blocks.multiply_const_ff(float(vol) / 70.0)

        if was_active:
            self.on()
        else:
            self.off()
Example #11
0
    def __init__(self,
                 squelch,
                 ch_width,
                 max_dev,
                 out_scale,
                 freq,
                 command,
                 do_audio=False):
        gr.hier_block2.__init__(self, "FMtoCommand",
                                gr.io_signature(1, 1, gr.sizeof_gr_complex),
                                gr.io_signature(0, 0, gr.sizeof_gr_complex))

        self.analog_pwr_squelch = analog.pwr_squelch_cc(squelch, 1e-4, 0, True)
        self.analog_nbfm_rx = analog.nbfm_rx(
            audio_rate=ch_width,
            quad_rate=ch_width,
            tau=75e-6,
            max_dev=max_dev,
        )
        self.blocks_float_to_short = blocks.float_to_short(1, out_scale)
        # OSX: if you get Resource Temporarily Unavailable you probably need to increase maxproc, eg
        # sudo launchctl limit maxproc 2000 3000
        logger.debug("Channel %.3f: Starting %s" % (freq / 1e6, str(command)))
        self.p = subprocess.Popen(command,
                                  shell=True,
                                  stdin=subprocess.PIPE,
                                  stdout=subprocess.PIPE)
        self.sink = blocks.file_descriptor_sink(gr.sizeof_short * 1,
                                                self.p.stdin.fileno())
        self.connect(self, (self.analog_pwr_squelch, 0))
        self.connect((self.analog_pwr_squelch, 0), (self.analog_nbfm_rx, 0))
        self.connect((self.analog_nbfm_rx, 0), (self.blocks_float_to_short, 0))
        self.connect((self.blocks_float_to_short, 0), (self.sink, 0))
        if do_audio:
            self.resampler = grfilter.rational_resampler_fff(
                interpolation=441,
                decimation=425,
                taps=None,
                fractional_bw=None)
            self.mult = blocks.multiply_const_vff((0.2, ))
            self.audio_sink = audio.sink(22050, '', True)
            self.connect((self.analog_nbfm_rx, 0), (self.resampler, 0))
            self.connect((self.resampler, 0), (self.mult, 0))
            self.connect((self.mult, 0), (self.audio_sink, 0))
Example #12
0
    def __init__(self):
        gr.hier_block2.__init__(
            self,
            "NBFM Chain",
            gr.io_signature(1, 1, gr.sizeof_gr_complex * 1),
            gr.io_signature(1, 1, gr.sizeof_float * 1),
        )

        ##################################################
        # Blocks
        ##################################################
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
            interpolation=192000,
            decimation=2400000,
            taps=None,
            fractional_bw=None,
        )
        self.low_pass_filter_1 = filter.fir_filter_ccf(
            1, firdes.low_pass(1, 192000, 5e3, 5e3, firdes.WIN_HAMMING, 6.76))
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((5, ))
        self.analog_nbfm_rx_0 = analog.nbfm_rx(
            audio_rate=48000,
            quad_rate=192000,
            tau=75e-6,
            max_dev=2.5e3,
        )

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_nbfm_rx_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self, 0))
        self.connect((self.low_pass_filter_1, 0), (self.analog_nbfm_rx_0, 0))
        self.connect((self, 0), (self.rational_resampler_xxx_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.low_pass_filter_1, 0))
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Audio 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 = 195312
        self.variable_slider_0 = variable_slider_0 = 80e6
        self.FILT = FILT = firdes.low_pass(1, samp_rate, 10000, 1000, firdes.WIN_HAMMING, 6.76)

        ##################################################
        # Blocks
        ##################################################
        _variable_slider_0_sizer = wx.BoxSizer(wx.VERTICAL)
        self._variable_slider_0_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_variable_slider_0_sizer,
        	value=self.variable_slider_0,
        	callback=self.set_variable_slider_0,
        	label='variable_slider_0',
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._variable_slider_0_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_variable_slider_0_sizer,
        	value=self.variable_slider_0,
        	callback=self.set_variable_slider_0,
        	minimum=80e6,
        	maximum=150e6,
        	num_steps=100,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.Add(_variable_slider_0_sizer)
        self.wxgui_fftsink2_0 = fftsink2.fft_sink_c(
        	self.GetWin(),
        	baseband_freq=variable_slider_0,
        	y_per_div=10,
        	y_divs=10,
        	ref_level=0,
        	ref_scale=2.0,
        	sample_rate=195312,
        	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.uhd_usrp_source_0 = uhd.usrp_source(
        	device_addr="",
        	stream_args=uhd.stream_args(
        		cpu_format="fc32",
        		otw_format="sc16",
        		channels=range(1),
        	),
        )
        self.uhd_usrp_source_0.set_samp_rate(195312)
        self.uhd_usrp_source_0.set_center_freq(variable_slider_0, 0)
        self.uhd_usrp_source_0.set_gain(20, 0)
        self.uhd_usrp_source_0.set_antenna("J1", 0)
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
                interpolation=44100,
                decimation=195312,
                taps=None,
                fractional_bw=None,
        )
        self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(1, (FILT), -100e6, samp_rate)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((3, ))
        self.audio_sink_0_0 = audio.sink(44100, "", True)
        self.analog_nbfm_rx_0 = analog.nbfm_rx(
        	audio_rate=44100,
        	quad_rate=44100,
        	tau=75e-6,
        	max_dev=2.5e3,
        )

        ##################################################
        # Connections
        ##################################################
        self.connect((self.uhd_usrp_source_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0), (self.analog_nbfm_rx_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.rational_resampler_xxx_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.wxgui_fftsink2_0, 0))
        self.connect((self.analog_nbfm_rx_0, 0), (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.audio_sink_0_0, 0))
Example #14
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="narrow fm demod on high freq police radio bands")
        _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 = 2400000
        self.rx_freq = rx_freq = 854.388e6
        self.rx_fine = rx_fine = 0
        self.rx_coarse = rx_coarse = 0
        self.xlate_filter_taps = xlate_filter_taps = firdes.low_pass(1, samp_rate, 125000, 25000, firdes.WIN_HAMMING, 6.76)
        self.width = width = 12500
        self.variable_chooser_1 = variable_chooser_1 = 1
        self.tv_freq = tv_freq = 500.25e6
        self.trans = trans = 25000
        self.squelch = squelch = -55
        self.sql_lev = sql_lev = -20
        self.rx_freq_val = rx_freq_val = rx_freq+(rx_coarse+rx_fine)
        self.freq = freq = 155e6
        self.dev = dev = 7500
        self.decimation = decimation = 50
        self.af_gain = af_gain = 1

        ##################################################
        # Blocks
        ##################################################
        _width_sizer = wx.BoxSizer(wx.VERTICAL)
        self._width_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_width_sizer,
        	value=self.width,
        	callback=self.set_width,
        	label="LP Filter",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._width_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_width_sizer,
        	value=self.width,
        	callback=self.set_width,
        	minimum=2000,
        	maximum=40000,
        	num_steps=760,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_width_sizer, 2, 4, 1, 4)
        _trans_sizer = wx.BoxSizer(wx.VERTICAL)
        self._trans_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_trans_sizer,
        	value=self.trans,
        	callback=self.set_trans,
        	label="LP Trans",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._trans_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_trans_sizer,
        	value=self.trans,
        	callback=self.set_trans,
        	minimum=500,
        	maximum=50000,
        	num_steps=900,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_trans_sizer, 2, 8, 1, 4)
        _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 level",
        	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=-100,
        	maximum=0,
        	num_steps=100,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.Add(_squelch_sizer)
        _rx_freq_sizer = wx.BoxSizer(wx.VERTICAL)
        self._rx_freq_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_rx_freq_sizer,
        	value=self.rx_freq,
        	callback=self.set_rx_freq,
        	label="RX Center ",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._rx_freq_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_rx_freq_sizer,
        	value=self.rx_freq,
        	callback=self.set_rx_freq,
        	minimum=840000000,
        	maximum=860000000,
        	num_steps=1000,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_rx_freq_sizer, 0, 0, 1, 16)
        _rx_fine_sizer = wx.BoxSizer(wx.VERTICAL)
        self._rx_fine_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_rx_fine_sizer,
        	value=self.rx_fine,
        	callback=self.set_rx_fine,
        	label="RX Fine",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._rx_fine_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_rx_fine_sizer,
        	value=self.rx_fine,
        	callback=self.set_rx_fine,
        	minimum=0,
        	maximum=10000,
        	num_steps=1000,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_rx_fine_sizer, 1, 4, 1, 4)
        _rx_coarse_sizer = wx.BoxSizer(wx.VERTICAL)
        self._rx_coarse_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_rx_coarse_sizer,
        	value=self.rx_coarse,
        	callback=self.set_rx_coarse,
        	label="RX Offset",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._rx_coarse_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_rx_coarse_sizer,
        	value=self.rx_coarse,
        	callback=self.set_rx_coarse,
        	minimum=0,
        	maximum=1e6,
        	num_steps=1000,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_rx_coarse_sizer, 1, 0, 1, 4)
        _dev_sizer = wx.BoxSizer(wx.VERTICAL)
        self._dev_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_dev_sizer,
        	value=self.dev,
        	callback=self.set_dev,
        	label="NBFM deviation",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._dev_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_dev_sizer,
        	value=self.dev,
        	callback=self.set_dev,
        	minimum=4000,
        	maximum=16000,
        	num_steps=24,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.Add(_dev_sizer)
        self.wxgui_waterfallsink2_1 = waterfallsink2.waterfall_sink_c(
        	self.GetWin(),
        	baseband_freq=rx_freq + rx_coarse + rx_fine,
        	dynamic_range=100,
        	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_1.win)
        self._variable_chooser_1_chooser = forms.drop_down(
        	parent=self.GetWin(),
        	value=self.variable_chooser_1,
        	callback=self.set_variable_chooser_1,
        	label='variable_chooser_1',
        	choices=[1, 2, 3],
        	labels=[],
        )
        self.Add(self._variable_chooser_1_chooser)
        _sql_lev_sizer = wx.BoxSizer(wx.VERTICAL)
        self._sql_lev_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_sql_lev_sizer,
        	value=self.sql_lev,
        	callback=self.set_sql_lev,
        	label="SQL",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._sql_lev_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_sql_lev_sizer,
        	value=self.sql_lev,
        	callback=self.set_sql_lev,
        	minimum=-100,
        	maximum=100,
        	num_steps=200,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_sql_lev_sizer, 1, 12, 1, 4)
        self._rx_freq_val_static_text = forms.static_text(
        	parent=self.GetWin(),
        	value=self.rx_freq_val,
        	callback=self.set_rx_freq_val,
        	label="Receive",
        	converter=forms.float_converter(),
        )
        self.GridAdd(self._rx_freq_val_static_text, 0, 16, 1, 1)
        self.rtlsdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + "" )
        self.rtlsdr_source_0.set_time_now(osmosdr.time_spec_t(time.time()), osmosdr.ALL_MBOARDS)
        self.rtlsdr_source_0.set_sample_rate(samp_rate)
        self.rtlsdr_source_0.set_center_freq(rx_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(10, 0)
        self.rtlsdr_source_0.set_if_gain(20, 0)
        self.rtlsdr_source_0.set_bb_gain(20, 0)
        self.rtlsdr_source_0.set_antenna("", 0)
        self.rtlsdr_source_0.set_bandwidth(0, 0)
          
        self.low_pass_filter_0 = filter.fir_filter_ccf(decimation, firdes.low_pass(
        	1, samp_rate, width, trans, firdes.WIN_HAMMING, 6.76))
        self.audio_sink_0 = audio.sink(48000, "", True)
        self.analog_simple_squelch_cc_0 = analog.simple_squelch_cc(squelch, 1)
        self.analog_nbfm_rx_0 = analog.nbfm_rx(
        	audio_rate=48000,
        	quad_rate=48000,
        	tau=50e-6,
        	max_dev=dev,
        )
        _af_gain_sizer = wx.BoxSizer(wx.VERTICAL)
        self._af_gain_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_af_gain_sizer,
        	value=self.af_gain,
        	callback=self.set_af_gain,
        	label="VOL",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._af_gain_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_af_gain_sizer,
        	value=self.af_gain,
        	callback=self.set_af_gain,
        	minimum=0,
        	maximum=5,
        	num_steps=50,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_af_gain_sizer, 2, 12, 1, 4)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_nbfm_rx_0, 0), (self.audio_sink_0, 0))    
        self.connect((self.analog_simple_squelch_cc_0, 0), (self.analog_nbfm_rx_0, 0))    
        self.connect((self.low_pass_filter_0, 0), (self.analog_simple_squelch_cc_0, 0))    
        self.connect((self.rtlsdr_source_0, 0), (self.low_pass_filter_0, 0))    
        self.connect((self.rtlsdr_source_0, 0), (self.wxgui_waterfallsink2_1, 0))    
Example #15
0
    def __init__(self):

        # Call the initialization method from the parent class
        gr.top_block.__init__(self)

        # Setup the parser for command line arguments
        parser = OptionParser(option_class=eng_option)
        parser.add_option("-v", "--verbose", action="store_true",
                          dest="verbose", default=False,
                          help="print settings to stdout")
        parser.add_option("-a", "--args", type="string", dest="src_args",
                          default='addr=192.168.1.13',
                          help="USRP device address args")
        parser.add_option("-g", "--gain", type="eng_float", dest="src_gain",
                          default=0, help="USRP gain in dB")
        parser.add_option("-q", "--squelch", type="eng_float",
                          dest="squelch_thresh", default=-80,
                          help="Squelch threshold in dB")
        parser.add_option("-s", "--soundrate", type="eng_float",
                          dest="snd_card_rate", default=48000,
                          help="Sound card rate in Hz (must be n*100 Hz)")
        parser.add_option("-c", "--channels", type="string",
                          dest="channel_file_name",
                          default='channels.txt',
                          help="Text file of EOL delimited channels in Hz")

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

        # Define the user constants
        src_args = str(options.src_args)
        src_gain = float(options.src_gain)
        squelch_thresh = float(options.squelch_thresh)
        snd_card_rate = int(options.snd_card_rate)
        channel_file_name = str(options.channel_file_name)

        # Define other constants (don't mess with these)
        max_rf_bandwidth = 25E6 # Limited by N210
        channel_sample_rate = 20000
        nbfm_maxdev = 2.5E3
        nbfm_tau = 75E-6

        # Open file, split to list, remove empty strings, and convert to float
        with open(channel_file_name) as chanfile:
            lines = chanfile.read().splitlines()
        chanfile.close()
        lines = __builtin__.filter(None, lines)
        chanlist = [float(chan) for chan in lines]

        # Source decimation is first deternmined by the required RF bandwidth
        rf_bandwidth = max(chanlist) - min(chanlist) + 2*channel_sample_rate
        src_decimation = int(math.floor(max_rf_bandwidth/rf_bandwidth))

        # Check if rf_bandwidth is too wide
        if rf_bandwidth > max_rf_bandwidth:
            print 'Error: Channels spaced beyond the \
                %f MHz maximum RF bandwidth!' % (max_rf_bandwidth/1E6)
            sys.exit([1])
        else:
            pass

        # Don't let the source decimation go above 100 (USRP N210 limit)
        if src_decimation > 100:
            src_decimation = 100

        # This is a little tricky
        # Don't want odd values of source decimation greater than 1
        # Also want the source sample rate \
        # to be an integer multiple of channel sample rate
        src_sample_rate = max_rf_bandwidth / src_decimation
        while ((src_decimation%2 != 0) or \
            ((max_rf_bandwidth/src_decimation) % channel_sample_rate != 0)) \
            and src_decimation > 1:
            src_decimation = src_decimation - 1
            src_sample_rate = max_rf_bandwidth / src_decimation

        # Calculate the channel decimation for the fxlating filter
        # (it will be an integer)
        channel_decimation = int(src_sample_rate / channel_sample_rate)

        # Calculate center frequency
        src_center_freq = (max(chanlist) + min(chanlist)) / 2

        # Print some info to stdout for verbose option
        if options.verbose:
            print 'Source args string "%s" ' % src_args
            print 'Source center frequency = %f MHz' % (src_center_freq/1E6)
            print 'Source decimation = %i' % src_decimation
            print 'Source sample rate = %i Hz' % src_sample_rate
            print 'Source gain = %i dB' % src_gain
            print 'Squelch threshold = %i dB' % squelch_thresh
            print 'Channel decimation = %i' % channel_decimation
            print 'Channel sample rate = %i Hz' % channel_sample_rate
            print 'Sound card rate = %i Hz' % snd_card_rate
            print 'Channel list = %s' % str(chanlist)

        # Setup the source
        src = uhd.usrp_source(src_args, uhd.io_type_t.COMPLEX_FLOAT32, 1)
        src.set_samp_rate(src_sample_rate)
        src.set_center_freq(src_center_freq, 0)
        src.set_gain(src_gain, 0)

        # Get USRP true center frequency
        # Do nothing with it as it's only a few Hz error
        #print src.get_center_freq()

        # Create N channel flows---------------------------------------------

        # Design taps for frequency translating FIR filter
        filter_taps = filter.firdes.low_pass(1.0,
                                             src_sample_rate,
                                             8E3,
                                             2E3,
                                             filter.firdes.WIN_HAMMING)

        # N parallel fxlating FIR filter with decimation to channel rate
        # Note how the tune freq is chan-src_center_freq ; reversed from GR 3.6
        fxlate = [filter.freq_xlating_fir_filter_ccc(channel_decimation,
                                                 filter_taps,
                                                 chan - src_center_freq,
                                                 src_sample_rate)
                  for chan in chanlist]

        # Power squelch (complex, non blocking) prior to NBFM
        squelch1 = [analog.pwr_squelch_cc(squelch_thresh,
                                          0.1,
                                          1,
                                          False) for chan in chanlist]

        # NBFM receiver
        nbfm = [analog.nbfm_rx(channel_sample_rate,
                               channel_sample_rate,
                               nbfm_tau,
                               nbfm_maxdev) for chan in chanlist]

        # Power squelch (float, blocking) prior to wav file resampling
        squelch2 = [analog.pwr_squelch_ff(squelch_thresh,
                                          0.1,
                                          1,
                                          True) for chan in chanlist]

        # Rational resampler for channel rate to 8 kHz wav file rate
        resampwav = [filter.rational_resampler_fff(8000,
                                                   int(channel_sample_rate))
                                                   for chan in chanlist]

        # Wav file sink
        wavfile = [blocks.wavfile_sink(str(int(chan))+'.wav',
                                       1,
                                       8000,
                                       8) for chan in chanlist]

        # Connect the blocks
        for chan in range(len(chanlist)):
            self.connect(src, fxlate[chan], squelch1[chan], nbfm[chan],
                         squelch2[chan], resampwav[chan], wavfile[chan])

        # Adder to sum the nbfm outputs for sound card
        adder = blocks.add_vff(1)

        # Rational resampler for channel rate to audio rate
        resampsc = filter.rational_resampler_fff(int(snd_card_rate),
                                                 int(channel_sample_rate))

        # Sound card sink
        sndcard = audio.sink(snd_card_rate, "", True)

        # Connect the blocks
        for chan in range(len(chanlist)):
            self.connect(nbfm[chan], (adder, chan))

        # Connect the blocks
        self.connect(adder, resampsc, sndcard)
Example #16
0
    def __init__(self):
        gr.top_block.__init__(self, "NBFM")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("NBFM")
        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")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.radio_freq = radio_freq = 100
        self.volume = volume = 5
        self.squelch = squelch = -30
        self.samp_rate = samp_rate = 240e4
        self.rf_gain = rf_gain = 10
        self.freq = freq = radio_freq * 1000000

        ##################################################
        # Blocks
        ##################################################
        self._volume_range = Range(0, 10, 1, 5, 200)
        self._volume_win = RangeWidget(self._volume_range, self.set_volume, "Volume", "counter_slider", float)
        self.top_layout.addWidget(self._volume_win)
        self._squelch_range = Range(-70, 0, 10, -30, 200)
        self._squelch_win = RangeWidget(self._squelch_range, self.set_squelch, "Squelch", "counter_slider", int)
        self.top_layout.addWidget(self._squelch_win)
        self._rf_gain_range = Range(0, 50, 1, 10, 200)
        self._rf_gain_win = RangeWidget(self._rf_gain_range, self.set_rf_gain, "RF Gain", "counter_slider", float)
        self.top_layout.addWidget(self._rf_gain_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(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(20, 0)
        self.rtlsdr_source_0.set_bb_gain(20, 0)
        self.rtlsdr_source_0.set_antenna("", 0)
        self.rtlsdr_source_0.set_bandwidth(0, 0)
          
        self.rational_resampler_xxx_1_0 = filter.rational_resampler_fff(
                interpolation=60,
                decimation=35,
                taps=None,
                fractional_bw=None,
        )
        self._radio_freq_tool_bar = Qt.QToolBar(self)
        self._radio_freq_tool_bar.addWidget(Qt.QLabel("Frequency (MHz)"+": "))
        self._radio_freq_line_edit = Qt.QLineEdit(str(self.radio_freq))
        self._radio_freq_tool_bar.addWidget(self._radio_freq_line_edit)
        self._radio_freq_line_edit.returnPressed.connect(
        	lambda: self.set_radio_freq(eng_notation.str_to_num(str(self._radio_freq_line_edit.text().toAscii()))))
        self.top_layout.addWidget(self._radio_freq_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)
        
        if not True:
          self.qtgui_waterfall_sink_x_0.disable_legend()
        
        if complex == type(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_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, 10)
        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_control_panel(False)
        
        if not True:
          self.qtgui_freq_sink_x_0.disable_legend()
        
        if complex == type(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.low_pass_filter_0_0 = filter.fir_filter_ccf(8, firdes.low_pass(
        	1, samp_rate, 5000, 8000, firdes.WIN_HAMMING, 6.76))
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((volume, ))
        self.audio_sink_0 = audio.sink(48000, "", True)
        self.analog_pwr_squelch_xx_0 = analog.pwr_squelch_cc(squelch, 1e-4, 0, True)
        self.analog_nbfm_rx_0 = analog.nbfm_rx(
        	audio_rate=30000,
        	quad_rate=300000,
        	tau=75e-6,
        	max_dev=12.5e3,
        )

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_nbfm_rx_0, 0), (self.rational_resampler_xxx_1_0, 0))    
        self.connect((self.analog_pwr_squelch_xx_0, 0), (self.low_pass_filter_0_0, 0))    
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.audio_sink_0, 0))    
        self.connect((self.low_pass_filter_0_0, 0), (self.analog_nbfm_rx_0, 0))    
        self.connect((self.rational_resampler_xxx_1_0, 0), (self.blocks_multiply_const_vxx_0, 0))    
        self.connect((self.rtlsdr_source_0, 0), (self.analog_pwr_squelch_xx_0, 0))    
        self.connect((self.rtlsdr_source_0, 0), (self.qtgui_freq_sink_x_0, 0))    
        self.connect((self.rtlsdr_source_0, 0), (self.qtgui_waterfall_sink_x_0, 0))    
Example #17
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Fm Radio")
        _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 = 1.024e6
        self.noise_amplitude = noise_amplitude = 0.01
        self.mode = mode = 0
        self.decim = decim = 4
        self.audio_gain = audio_gain = 1
        self.WBFM_frequency = WBFM_frequency = 92.3e6
        self.NBFM_frequency = NBFM_frequency = 162.475e6

        ##################################################
        # Blocks
        ##################################################
        self.notebook_0 = self.notebook_0 = wx.Notebook(self.GetWin(), style=wx.NB_TOP)
        self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "FFT Plot")
        self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "Waterfall Plot")
        self.Add(self.notebook_0)
        _noise_amplitude_sizer = wx.BoxSizer(wx.VERTICAL)
        self._noise_amplitude_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_noise_amplitude_sizer,
        	value=self.noise_amplitude,
        	callback=self.set_noise_amplitude,
        	label='noise_amplitude',
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._noise_amplitude_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_noise_amplitude_sizer,
        	value=self.noise_amplitude,
        	callback=self.set_noise_amplitude,
        	minimum=0,
        	maximum=0.1,
        	num_steps=500,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_noise_amplitude_sizer, 2, 26, 2, 24)
        self._mode_chooser = forms.radio_buttons(
        	parent=self.GetWin(),
        	value=self.mode,
        	callback=self.set_mode,
        	label='mode',
        	choices=[0,1],
        	labels=['WBFM','NBFM'],
        	style=wx.RA_VERTICAL,
        )
        self.GridAdd(self._mode_chooser, 0, 0, 1, 2)
        _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.GridAdd(_audio_gain_sizer, 2, 2, 2, 24)
        _WBFM_frequency_sizer = wx.BoxSizer(wx.VERTICAL)
        self._WBFM_frequency_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_WBFM_frequency_sizer,
        	value=self.WBFM_frequency,
        	callback=self.set_WBFM_frequency,
        	label='WBFM_frequency',
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._WBFM_frequency_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_WBFM_frequency_sizer,
        	value=self.WBFM_frequency,
        	callback=self.set_WBFM_frequency,
        	minimum=88.1e6,
        	maximum=108.1e6,
        	num_steps=100,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_WBFM_frequency_sizer, 0, 2, 2, 24)
        _NBFM_frequency_sizer = wx.BoxSizer(wx.VERTICAL)
        self._NBFM_frequency_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_NBFM_frequency_sizer,
        	value=self.NBFM_frequency,
        	callback=self.set_NBFM_frequency,
        	label='NBFM_frequency',
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._NBFM_frequency_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_NBFM_frequency_sizer,
        	value=self.NBFM_frequency,
        	callback=self.set_NBFM_frequency,
        	minimum=146e6,
        	maximum=170e6,
        	num_steps=100,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_NBFM_frequency_sizer, 0, 26, 2, 24)
        self.wxgui_waterfallsink2_0 = waterfallsink2.waterfall_sink_c(
        	self.notebook_0.GetPage(1).GetWin(),
        	baseband_freq=0,
        	dynamic_range=100,
        	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",
        	size=(480, 360),
        )
        self.notebook_0.GetPage(1).Add(self.wxgui_waterfallsink2_0.win)
        self.wxgui_fftsink2_0 = fftsink2.fft_sink_c(
        	self.notebook_0.GetPage(0).GetWin(),
        	baseband_freq=0,
        	y_per_div=10,
        	y_divs=10,
        	ref_level=0,
        	ref_scale=2.0,
        	sample_rate=samp_rate/decim,
        	fft_size=1024,
        	fft_rate=15,
        	average=False,
        	avg_alpha=None,
        	title="FFT Plot",
        	peak_hold=False,
        	size=(480, 360),
        )
        self.notebook_0.GetPage(0).Add(self.wxgui_fftsink2_0.win)
        self.rational_resampler_xxx_1 = filter.rational_resampler_ccc(
                interpolation=1,
                decimation=8,
                taps=None,
                fractional_bw=None,
        )
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
                interpolation=1,
                decimation=decim,
                taps=None,
                fractional_bw=None,
        )
        self.osmosdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + "rtl=0" )
        self.osmosdr_source_0.set_time_source("gpsdo", 0)
        self.osmosdr_source_0.set_sample_rate(samp_rate)
        self.osmosdr_source_0.set_center_freq(WBFM_frequency if mode==0 else NBFM_frequency, 0)
        self.osmosdr_source_0.set_freq_corr(0, 0)
        self.osmosdr_source_0.set_dc_offset_mode(2, 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(25, 0)
        self.osmosdr_source_0.set_if_gain(24, 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.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((audio_gain, ))
        self.blocks_add_xx_0 = blocks.add_vcc(1)
        self.blks2_selector_1 = grc_blks2.selector(
        	item_size=gr.sizeof_float*1,
        	num_inputs=2,
        	num_outputs=1,
        	input_index=mode,
        	output_index=0,
        )
        self.blks2_selector_0 = grc_blks2.selector(
        	item_size=gr.sizeof_gr_complex*1,
        	num_inputs=1,
        	num_outputs=2,
        	input_index=0,
        	output_index=mode,
        )
        self.audio_sink_0 = audio.sink(32000, "", True)
        self.analog_wfm_rcv_0 = analog.wfm_rcv(
        	quad_rate=256e3,
        	audio_decimation=8,
        )
        self.analog_noise_source_x_0 = analog.noise_source_c(analog.GR_GAUSSIAN, noise_amplitude, 0)
        self.analog_nbfm_rx_0 = analog.nbfm_rx(
        	audio_rate=32000,
        	quad_rate=32000,
        	tau=75e-6,
        	max_dev=5e3,
          )

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_nbfm_rx_0, 0), (self.blks2_selector_1, 1))    
        self.connect((self.analog_noise_source_x_0, 0), (self.blocks_add_xx_0, 1))    
        self.connect((self.analog_wfm_rcv_0, 0), (self.blks2_selector_1, 0))    
        self.connect((self.blks2_selector_0, 0), (self.analog_wfm_rcv_0, 0))    
        self.connect((self.blks2_selector_0, 1), (self.rational_resampler_xxx_1, 0))    
        self.connect((self.blks2_selector_1, 0), (self.blocks_multiply_const_vxx_0, 0))    
        self.connect((self.blocks_add_xx_0, 0), (self.blks2_selector_0, 0))    
        self.connect((self.blocks_add_xx_0, 0), (self.wxgui_waterfallsink2_0, 0))    
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.audio_sink_0, 0))    
        self.connect((self.osmosdr_source_0, 0), (self.rational_resampler_xxx_0, 0))    
        self.connect((self.rational_resampler_xxx_0, 0), (self.blocks_add_xx_0, 0))    
        self.connect((self.rational_resampler_xxx_0, 0), (self.wxgui_fftsink2_0, 0))    
        self.connect((self.rational_resampler_xxx_1, 0), (self.analog_nbfm_rx_0, 0))    
Example #18
0
    def __init__(self):
        gr.top_block.__init__(self, "Ssb Trx")

        ##################################################
        # Variables
        ##################################################
        self.BaseFreq = BaseFreq = 1296250000
        self.USB = USB = True
        self.TxOffset = TxOffset = 0
        self.TxLO = TxLO = BaseFreq-10000
        self.SQL = SQL = 20
        self.RxOffset = RxOffset = 0
        self.PTT = PTT = False
        self.NCW = NCW = False
        self.MicGain = MicGain = 5.0
        self.MON = MON = False
        self.KEY = KEY = False
        self.FMMIC = FMMIC = 50
        self.FM = FM = True
        self.CW = CW = False
        self.AFGain = AFGain = 20

        ##################################################
        # Blocks
        ##################################################
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
                interpolation=12,
                decimation=1,
                taps=None,
                fractional_bw=None,
        )
        self.pluto_source_0 = iio.pluto_source('ip:192.168.2.1', BaseFreq, 529200, 2000000, 0x800, True, True, True, "slow_attack", 64.0, '', True)
        self.pluto_sink_0 = iio.pluto_sink('ip:192.168.2.1', TxLO, 529200, 2000000, 0x800, False, 0, '', True)
        self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(12, (firdes.low_pass(1,529200,12000,6000)), RxOffset, 529200)
        self.blocks_mute_xx_0_0 = blocks.mute_cc(bool(not PTT))
        self.blocks_mute_xx_0 = blocks.mute_ff(bool(PTT and (not MON)))
        self.blocks_multiply_xx_2 = blocks.multiply_vcc(1)
        self.blocks_multiply_xx_1 = blocks.multiply_vcc(1)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_multiply_const_vxx_4 = blocks.multiply_const_vcc((not FM, ))
        self.blocks_multiply_const_vxx_3 = blocks.multiply_const_vcc((FM, ))
        self.blocks_multiply_const_vxx_2_0 = blocks.multiply_const_vff((int(FM) *0.1, ))
        self.blocks_multiply_const_vxx_2 = blocks.multiply_const_vff((not FM, ))
        self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vff((AFGain/10.0, ))
        self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vff((FMMIC/10.0, ))
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff(((MicGain/10.0)*(not CW), ))
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        self.blocks_complex_to_real_0 = blocks.complex_to_real(1)
        self.blocks_add_xx_2 = blocks.add_vcc(1)
        self.blocks_add_xx_1 = blocks.add_vff(1)
        self.blocks_add_xx_0 = blocks.add_vff(1)
        self.band_pass_filter_1 = filter.fir_filter_fff(1, firdes.band_pass(
        	1, 44100, 200, 3000, 100, firdes.WIN_HAMMING, 6.76))
        self.band_pass_filter_0_0 = filter.fir_filter_ccf(1, firdes.band_pass(
        	1, 44100, -3000+USB*3300+10000, -300+USB*3300+10000, 100, firdes.WIN_HAMMING, 6.76))
        self.band_pass_filter_0 = filter.fir_filter_ccc(1, firdes.complex_band_pass(
        	1, 44100, -3000+USB*3300+NCW*CW*250, -300+USB*3300-NCW*CW*1950, 100, firdes.WIN_HAMMING, 6.76))
        self.audio_source_0 = audio.source(44100, "hw:CARD=Device,DEV=0", True)
        self.audio_sink_0 = audio.sink(44100, "hw:CARD=Device,DEV=0", True)
        self.analog_simple_squelch_cc_0 = analog.simple_squelch_cc(-60+SQL, 1)
        self.analog_sig_source_x_1_0 = analog.sig_source_f(44100, analog.GR_COS_WAVE, 800, int(CW and KEY), 0)
        self.analog_sig_source_x_1 = analog.sig_source_c(529200, analog.GR_COS_WAVE, TxOffset, 1, 0)
        self.analog_sig_source_x_0 = analog.sig_source_c(44100, analog.GR_COS_WAVE, 10000, 1, 0)
        self.analog_nbfm_tx_0 = analog.nbfm_tx(
        	audio_rate=44100,
        	quad_rate=44100,
        	tau=75e-6,
        	max_dev=5e3,
        	fh=-1,
                )
        self.analog_nbfm_rx_0 = analog.nbfm_rx(
        	audio_rate=44100,
        	quad_rate=44100,
        	tau=75e-6,
        	max_dev=5e3,
          )
        self.analog_const_source_x_0 = analog.sig_source_f(0, analog.GR_CONST_WAVE, 0, 0, 0)



        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_const_source_x_0, 0), (self.blocks_float_to_complex_0, 1))
        self.connect((self.analog_nbfm_rx_0, 0), (self.blocks_multiply_const_vxx_2_0, 0))
        self.connect((self.analog_nbfm_tx_0, 0), (self.blocks_multiply_xx_2, 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), (self.blocks_multiply_xx_2, 1))
        self.connect((self.analog_sig_source_x_1, 0), (self.blocks_multiply_xx_1, 1))
        self.connect((self.analog_sig_source_x_1_0, 0), (self.blocks_add_xx_0, 1))
        self.connect((self.analog_simple_squelch_cc_0, 0), (self.analog_nbfm_rx_0, 0))
        self.connect((self.audio_source_0, 0), (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.audio_source_0, 0), (self.blocks_multiply_const_vxx_0_0, 0))
        self.connect((self.band_pass_filter_0, 0), (self.blocks_complex_to_real_0, 0))
        self.connect((self.band_pass_filter_0_0, 0), (self.blocks_multiply_const_vxx_4, 0))
        self.connect((self.band_pass_filter_1, 0), (self.analog_nbfm_tx_0, 0))
        self.connect((self.blocks_add_xx_0, 0), (self.blocks_float_to_complex_0, 0))
        self.connect((self.blocks_add_xx_1, 0), (self.blocks_mute_xx_0, 0))
        self.connect((self.blocks_add_xx_2, 0), (self.rational_resampler_xxx_0, 0))
        self.connect((self.blocks_complex_to_real_0, 0), (self.blocks_multiply_const_vxx_2, 0))
        self.connect((self.blocks_float_to_complex_0, 0), (self.blocks_multiply_xx_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.band_pass_filter_1, 0))
        self.connect((self.blocks_multiply_const_vxx_1, 0), (self.audio_sink_0, 0))
        self.connect((self.blocks_multiply_const_vxx_2, 0), (self.blocks_add_xx_1, 0))
        self.connect((self.blocks_multiply_const_vxx_2_0, 0), (self.blocks_add_xx_1, 1))
        self.connect((self.blocks_multiply_const_vxx_3, 0), (self.blocks_add_xx_2, 0))
        self.connect((self.blocks_multiply_const_vxx_4, 0), (self.blocks_add_xx_2, 1))
        self.connect((self.blocks_multiply_xx_0, 0), (self.band_pass_filter_0_0, 0))
        self.connect((self.blocks_multiply_xx_1, 0), (self.blocks_mute_xx_0_0, 0))
        self.connect((self.blocks_multiply_xx_2, 0), (self.blocks_multiply_const_vxx_3, 0))
        self.connect((self.blocks_mute_xx_0, 0), (self.blocks_multiply_const_vxx_1, 0))
        self.connect((self.blocks_mute_xx_0_0, 0), (self.pluto_sink_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.analog_simple_squelch_cc_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.band_pass_filter_0, 0))
        self.connect((self.pluto_source_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0), (self.blocks_multiply_xx_1, 0))
Example #19
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="FM Receiver Block")

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 2.4e6
        self.freq = freq = 104.5e6
        self.cutoff_freq = cutoff_freq = 100000

        ##################################################
        # 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='freq',
        	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=88e6,
        	maximum=108e6,
        	num_steps=200,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_freq_sizer, 0, 0, 1, 1)
        _cutoff_freq_sizer = wx.BoxSizer(wx.VERTICAL)
        self._cutoff_freq_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_cutoff_freq_sizer,
        	value=self.cutoff_freq,
        	callback=self.set_cutoff_freq,
        	label='cutoff_freq',
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._cutoff_freq_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_cutoff_freq_sizer,
        	value=self.cutoff_freq,
        	callback=self.set_cutoff_freq,
        	minimum=1000,
        	maximum=250000,
        	num_steps=100,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_cutoff_freq_sizer, 1, 0, 1, 1)
        self.wxgui_fftsink2_0_0_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=1024,
        	fft_rate=15,
        	average=False,
        	avg_alpha=None,
        	title="Post low pass filter",
        	peak_hold=False,
        	win=window.flattop,
        )
        self.GridAdd(self.wxgui_fftsink2_0_0_0.win, 1, 1, 1, 3)
        self.wxgui_fftsink2_0_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=1024,
        	fft_rate=15,
        	average=False,
        	avg_alpha=None,
        	title="Post resampling",
        	peak_hold=False,
        	win=window.flattop,
        )
        self.GridAdd(self.wxgui_fftsink2_0_0.win, 0, 3, 1, 1)
        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=1024,
        	fft_rate=15,
        	average=False,
        	avg_alpha=None,
        	title="Receiver output",
        	peak_hold=False,
        )
        self.GridAdd(self.wxgui_fftsink2_0.win, 0, 1, 1, 2)
        self.rtlsdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + "rtl=0" )
        self.rtlsdr_source_0.set_clock_source("gpsdo", 0)
        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(106, 0)
        self.rtlsdr_source_0.set_dc_offset_mode(2, 0)
        self.rtlsdr_source_0.set_iq_balance_mode(0, 0)
        self.rtlsdr_source_0.set_gain_mode(True, 0)
        self.rtlsdr_source_0.set_gain(10, 0)
        self.rtlsdr_source_0.set_if_gain(20, 0)
        self.rtlsdr_source_0.set_bb_gain(20, 0)
        self.rtlsdr_source_0.set_antenna("ant0", 0)
        self.rtlsdr_source_0.set_bandwidth(100e3, 0)
          
        self.rational_resampler_xxx_1 = filter.rational_resampler_fff(
                interpolation=48,
                decimation=50,
                taps=None,
                fractional_bw=None,
        )
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
                interpolation=500,
                decimation=2400,
                taps=None,
                fractional_bw=None,
        )
        self.low_pass_filter_0 = filter.fir_filter_ccf(1, firdes.low_pass(
        	1, 500000, cutoff_freq, 8000, firdes.WIN_HAMMING, 6.76))
        self.audio_sink_0 = audio.sink(48000, "", True)
        self.analog_nbfm_rx_0 = analog.nbfm_rx(
        	audio_rate=50000,
        	quad_rate=500000,
        	tau=75e-6,
        	max_dev=10e3,
          )

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_nbfm_rx_0, 0), (self.rational_resampler_xxx_1, 0))    
        self.connect((self.low_pass_filter_0, 0), (self.analog_nbfm_rx_0, 0))    
        self.connect((self.low_pass_filter_0, 0), (self.wxgui_fftsink2_0_0_0, 0))    
        self.connect((self.rational_resampler_xxx_0, 0), (self.low_pass_filter_0, 0))    
        self.connect((self.rational_resampler_xxx_0, 0), (self.wxgui_fftsink2_0_0, 0))    
        self.connect((self.rational_resampler_xxx_1, 0), (self.audio_sink_0, 0))    
        self.connect((self.rtlsdr_source_0, 0), (self.rational_resampler_xxx_0, 0))    
        self.connect((self.rtlsdr_source_0, 0), (self.wxgui_fftsink2_0, 0))    
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="FM radio FFT example")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Variables
        ##################################################
        self.variable_sample_rate_0 = variable_sample_rate_0 = 1.000E6
        self.xlatecenter = xlatecenter = 0
        self.xlate_filter = xlate_filter = firdes.low_pass(1, variable_sample_rate_0, 125000, 25000, firdes.WIN_HAMMING, 6.76)
        self.variable_static_text_0 = variable_static_text_0 = 'RTL R820T'
        self.variable_1 = variable_1 = 0
        self.transition = transition = 1e6
        self.samp_rate = samp_rate = 48000
        self.quadrature = quadrature = 500000
        self.cutoff = cutoff = 1e5
        self.audio_interp = audio_interp = 4
        self.RF_Gain = RF_Gain = 13
        self.CF = CF = 88.5e6

        ##################################################
        # Blocks
        ##################################################
        _xlatecenter_sizer = wx.BoxSizer(wx.VERTICAL)
        self._xlatecenter_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_xlatecenter_sizer,
        	value=self.xlatecenter,
        	callback=self.set_xlatecenter,
        	label="center2",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._xlatecenter_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_xlatecenter_sizer,
        	value=self.xlatecenter,
        	callback=self.set_xlatecenter,
        	minimum=-1e6,
        	maximum=1e6,
        	num_steps=1000,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_xlatecenter_sizer, 8, 0, 1, 5)
        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)
        _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)
        _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=90e6,
        	num_steps=1000,
        	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=variable_sample_rate_0,
        	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.rational_resampler_xxx_1_0 = filter.rational_resampler_fff(
                interpolation=48,
                decimation=50,
                taps=None,
                fractional_bw=None,
        )
        self.rational_resampler_xxx_1 = filter.rational_resampler_fff(
                interpolation=48,
                decimation=50,
                taps=None,
                fractional_bw=None,
        )
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
                interpolation=samp_rate * audio_interp,
                decimation=int(variable_sample_rate_0),
                taps=None,
                fractional_bw=None,
        )
        self.low_pass_filter_0 = filter.fir_filter_ccf(5, firdes.low_pass(
        	1, variable_sample_rate_0, 5000, 8000, firdes.WIN_HAMMING, 6.76))
        self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(5, (xlate_filter), xlatecenter, variable_sample_rate_0)
        self.audio_sink_1_0 = audio.sink(48000, "Radio:NFM-Center", True)
        self.audio_sink_1 = audio.sink(48000, "Radio:NFM", True)
        self.audio_sink_0 = audio.sink(48000, "Radio:WFM", False)
        self.analog_wfm_rcv_0 = analog.wfm_rcv(
        	quad_rate=samp_rate * audio_interp,
        	audio_decimation=audio_interp,
        )
        self.analog_nbfm_rx_0_0 = analog.nbfm_rx(
        	audio_rate=50000,
        	quad_rate=int(variable_sample_rate_0/5),
        	tau=75e-6,
        	max_dev=12500,
        )
        self.analog_nbfm_rx_0 = analog.nbfm_rx(
        	audio_rate=50000,
        	quad_rate=int(variable_sample_rate_0/5),
        	tau=75e-6,
        	max_dev=12500,
        )
        self.RTL820T = osmosdr.source( args="numchan=" + str(1) + " " + "" )
        self.RTL820T.set_sample_rate(variable_sample_rate_0)
        self.RTL820T.set_center_freq(CF, 0)
        self.RTL820T.set_freq_corr(0, 0)
        self.RTL820T.set_dc_offset_mode(2, 0)
        self.RTL820T.set_iq_balance_mode(0, 0)
        self.RTL820T.set_gain_mode(False, 0)
        self.RTL820T.set_gain(RF_Gain, 0)
        self.RTL820T.set_if_gain(20, 0)
        self.RTL820T.set_bb_gain(20, 0)
        self.RTL820T.set_antenna("", 0)
        self.RTL820T.set_bandwidth(1e6, 0)
          

        ##################################################
        # Connections
        ##################################################
        self.connect((self.RTL820T, 0), (self.freq_xlating_fir_filter_xxx_0, 0))    
        self.connect((self.RTL820T, 0), (self.low_pass_filter_0, 0))    
        self.connect((self.RTL820T, 0), (self.rational_resampler_xxx_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_nbfm_rx_0, 0), (self.rational_resampler_xxx_1, 0))    
        self.connect((self.analog_nbfm_rx_0_0, 0), (self.rational_resampler_xxx_1_0, 0))    
        self.connect((self.analog_wfm_rcv_0, 0), (self.audio_sink_0, 0))    
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.analog_nbfm_rx_0_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.analog_wfm_rcv_0, 0))    
        self.connect((self.rational_resampler_xxx_1, 0), (self.audio_sink_1, 0))    
        self.connect((self.rational_resampler_xxx_1_0, 0), (self.audio_sink_1_0, 0))    
Example #21
0
    def __init__(self):
        gr.top_block.__init__(self, "Nbfm Dsd No Gui")

        ##################################################
        # Variables
        ##################################################
        self.decim = decim = 2
        self.adc_rate = adc_rate = 2000000
        self.xlate_offset_fine = xlate_offset_fine = -800
        self.xlate_offset = xlate_offset = 0
        self.xlate_decim = xlate_decim = 4
        self.xlate_bandwidth = xlate_bandwidth = 12500
        self.volume = volume = 2
        self.squelch = squelch = 50
        self.samp_rate = samp_rate = adc_rate/decim
        self.audio_rate = audio_rate = 48000
        self.audio_interp = audio_interp = 4

        ##################################################
        # Blocks
        ##################################################
        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(442.574e6, 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(2, 0)
        self.rtlsdr_source_0.set_gain_mode(True, 0)
        self.rtlsdr_source_0.set_gain(50, 0)
        self.rtlsdr_source_0.set_if_gain(20, 0)
        self.rtlsdr_source_0.set_bb_gain(20, 0)
        self.rtlsdr_source_0.set_antenna("", 0)
        self.rtlsdr_source_0.set_bandwidth(0, 0)
          
        self.rational_resampler_xxx_0_0 = filter.rational_resampler_fff(
                interpolation=48000,
                decimation=8000,
                taps=None,
                fractional_bw=None,
        )
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
                interpolation=audio_rate*audio_interp,
                decimation=samp_rate/xlate_decim,
                taps=None,
                fractional_bw=None,
        )
        self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(xlate_decim, (firdes.low_pass(1, samp_rate, xlate_bandwidth/2, 1000)), xlate_offset + xlate_offset_fine, samp_rate)
        self.dsd_block_ff_1 = dsd.block_ff(dsd.dsd_FRAME_AUTO_DETECT,dsd.dsd_MOD_AUTO_SELECT,3,True,2)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((volume, ))
        self.audio_sink_0 = audio.sink(48000, "", True)
        self.analog_simple_squelch_cc_0 = analog.simple_squelch_cc(squelch*-1, 1)
        self.analog_nbfm_rx_0 = analog.nbfm_rx(
        	audio_rate=audio_rate,
        	quad_rate=audio_rate*audio_interp,
        	tau=75e-6,
        	max_dev=5e3,
        )

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_nbfm_rx_0, 0), (self.dsd_block_ff_1, 0))    
        self.connect((self.analog_simple_squelch_cc_0, 0), (self.analog_nbfm_rx_0, 0))    
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.audio_sink_0, 0))    
        self.connect((self.dsd_block_ff_1, 0), (self.rational_resampler_xxx_0_0, 0))    
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.rational_resampler_xxx_0, 0))    
        self.connect((self.rational_resampler_xxx_0, 0), (self.analog_simple_squelch_cc_0, 0))    
        self.connect((self.rational_resampler_xxx_0_0, 0), (self.blocks_multiply_const_vxx_0, 0))    
        self.connect((self.rtlsdr_source_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0))    
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="FM radio FFT example")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Variables
        ##################################################
        self.variable_sample_rate_0 = variable_sample_rate_0 = 1e6
        self.samp_rate = samp_rate = 44100
        self.xlatecenter_8 = xlatecenter_8 = 0
        self.xlatecenter_7 = xlatecenter_7 = 0
        self.xlatecenter_6 = xlatecenter_6 = 0
        self.xlatecenter_5 = xlatecenter_5 = 0
        self.xlatecenter_4 = xlatecenter_4 = 0
        self.xlatecenter_3 = xlatecenter_3 = 0
        self.xlatecenter_2 = xlatecenter_2 = 0
        self.xlatecenter = xlatecenter = 0
        self.xlate_filter2 = xlate_filter2 = firdes.low_pass(1, samp_rate, 4000, 1000, firdes.WIN_HAMMING, 6.76)
        self.xlate_filter = xlate_filter = firdes.low_pass(1, variable_sample_rate_0, 125000, 25000, firdes.WIN_HAMMING, 6.76)
        self.variable_1 = variable_1 = 0
        self.transition = transition = 1e6
        self.rri = rri = 441
        self.rrd = rrd = 500
        self.quadrature = quadrature = 500000
        self.pscfshift = pscfshift = 0
        self.pscf8 = pscf8 = 0
        self.pscf7 = pscf7 = 0
        self.pscf6 = pscf6 = 0
        self.pscf5 = pscf5 = 0
        self.pscf4 = pscf4 = 0
        self.pscf3 = pscf3 = 0
        self.pscf2 = pscf2 = 0
        self.pscf1 = pscf1 = 0
        self.globaltune = globaltune = 0
        self.cutoff = cutoff = 1e5
        self.bptrans = bptrans = 100
        self.bpsr = bpsr = 200000
        self.bplow_4 = bplow_4 = 100
        self.bplow_3 = bplow_3 = 100
        self.bplow_2 = bplow_2 = 100
        self.bplow_1 = bplow_1 = 100
        self.bphi_4 = bphi_4 = 2.8e3
        self.bphi_3 = bphi_3 = 2.8e3
        self.bphi_2 = bphi_2 = 2.8e3
        self.bphi_1 = bphi_1 = 2.8e3
        self.audio_interp = audio_interp = 4
        self.amp_fm = amp_fm = 1
        self.amp_am = amp_am = 1
        self.amp_8 = amp_8 = 0
        self.amp_7 = amp_7 = 0
        self.amp_6 = amp_6 = 0
        self.amp_5 = amp_5 = 0
        self.amp_4 = amp_4 = 0
        self.amp_3 = amp_3 = 0
        self.amp_2 = amp_2 = 0
        self.amp_1 = amp_1 = 0
        self.RF_Gain = RF_Gain = 35
        self.CF = CF = 125.6e6

        ##################################################
        # Blocks
        ##################################################
        self.wxgui_waterfallsink2_0 = waterfallsink2.waterfall_sink_c(
        	self.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=(924,668),
        )
        self.Add(self.wxgui_waterfallsink2_0.win)
        self.rational_resampler_xxx_1_0_1_0_0_2 = filter.rational_resampler_fff(
                interpolation=rri,
                decimation=rrd,
                taps=None,
                fractional_bw=None,
        )
        self.rational_resampler_xxx_1_0_1_0_0_1 = filter.rational_resampler_fff(
                interpolation=rri,
                decimation=rrd,
                taps=None,
                fractional_bw=None,
        )
        self.rational_resampler_xxx_1_0_1_0_0_0 = filter.rational_resampler_fff(
                interpolation=rri,
                decimation=rrd,
                taps=None,
                fractional_bw=None,
        )
        self.rational_resampler_xxx_1_0_1_0_0 = filter.rational_resampler_fff(
                interpolation=rri,
                decimation=rrd,
                taps=None,
                fractional_bw=None,
        )
        self.rational_resampler_xxx_1_0_1_0 = filter.rational_resampler_fff(
                interpolation=rri,
                decimation=rrd,
                taps=None,
                fractional_bw=None,
        )
        self.rational_resampler_xxx_1_0_1 = filter.rational_resampler_fff(
                interpolation=rri,
                decimation=rrd,
                taps=None,
                fractional_bw=None,
        )
        self.rational_resampler_xxx_1_0_0_1 = filter.rational_resampler_ccc(
                interpolation=rri,
                decimation=rrd,
                taps=None,
                fractional_bw=None,
        )
        self.rational_resampler_xxx_1_0_0_0_0_0_2 = filter.rational_resampler_ccc(
                interpolation=rri,
                decimation=rrd,
                taps=None,
                fractional_bw=None,
        )
        self.rational_resampler_xxx_1_0_0_0_0_0_1 = filter.rational_resampler_ccc(
                interpolation=rri,
                decimation=rrd,
                taps=None,
                fractional_bw=None,
        )
        self.rational_resampler_xxx_1_0_0_0_0_0_0 = filter.rational_resampler_ccc(
                interpolation=rri,
                decimation=rrd,
                taps=None,
                fractional_bw=None,
        )
        self.rational_resampler_xxx_1_0_0_0_0_0 = filter.rational_resampler_ccc(
                interpolation=rri,
                decimation=rrd,
                taps=None,
                fractional_bw=None,
        )
        self.rational_resampler_xxx_1_0_0_0_0 = filter.rational_resampler_ccc(
                interpolation=rri,
                decimation=rrd,
                taps=None,
                fractional_bw=None,
        )
        self.rational_resampler_xxx_1_0_0_0 = filter.rational_resampler_ccc(
                interpolation=rri,
                decimation=rrd,
                taps=None,
                fractional_bw=None,
        )
        self.rational_resampler_xxx_1_0_0 = filter.rational_resampler_ccc(
                interpolation=rri,
                decimation=rrd,
                taps=None,
                fractional_bw=None,
        )
        self.rational_resampler_xxx_1_0 = filter.rational_resampler_fff(
                interpolation=rri,
                decimation=rrd,
                taps=None,
                fractional_bw=None,
        )
        self.rational_resampler_xxx_0 = filter.rational_resampler_fff(
                interpolation=rri,
                decimation=rrd,
                taps=None,
                fractional_bw=None,
        )
        self.freq_xlating_fir_filter_xxx_1_1_0_0_0_2 = filter.freq_xlating_fir_filter_ccc(1, (1, ), pscf8+pscfshift, samp_rate)
        self.freq_xlating_fir_filter_xxx_1_1_0_0_0_1 = filter.freq_xlating_fir_filter_ccc(1, (1, ), pscf7+pscfshift, samp_rate)
        self.freq_xlating_fir_filter_xxx_1_1_0_0_0_0 = filter.freq_xlating_fir_filter_ccc(1, (1, ), pscf6+pscfshift, samp_rate)
        self.freq_xlating_fir_filter_xxx_1_1_0_0_0 = filter.freq_xlating_fir_filter_ccc(1, (1, ), pscf5+pscfshift, samp_rate)
        self.freq_xlating_fir_filter_xxx_1_1_0_0 = filter.freq_xlating_fir_filter_ccc(1, (1, ), pscf4+pscfshift, samp_rate)
        self.freq_xlating_fir_filter_xxx_1_1_0 = filter.freq_xlating_fir_filter_ccc(1, (1, ), pscf3+pscfshift, samp_rate)
        self.freq_xlating_fir_filter_xxx_1_1 = filter.freq_xlating_fir_filter_ccc(1, (1, ), pscf2+pscfshift, samp_rate)
        self.freq_xlating_fir_filter_xxx_1_0_0_0_0_0_2 = filter.freq_xlating_fir_filter_fcc(1, (1, ), pscf8+pscfshift, samp_rate)
        self.freq_xlating_fir_filter_xxx_1_0_0_0_0_0_1 = filter.freq_xlating_fir_filter_fcc(1, (1, ), pscf7+pscfshift, samp_rate)
        self.freq_xlating_fir_filter_xxx_1_0_0_0_0_0_0 = filter.freq_xlating_fir_filter_fcc(1, (1, ), pscf6+pscfshift, samp_rate)
        self.freq_xlating_fir_filter_xxx_1_0_0_0_0_0 = filter.freq_xlating_fir_filter_fcc(1, (1, ), pscf5+pscfshift, samp_rate)
        self.freq_xlating_fir_filter_xxx_1_0_0_0_0 = filter.freq_xlating_fir_filter_fcc(1, (1, ), pscf4+pscfshift, samp_rate)
        self.freq_xlating_fir_filter_xxx_1_0_0_0 = filter.freq_xlating_fir_filter_fcc(1, (1, ), pscf3+pscfshift, samp_rate)
        self.freq_xlating_fir_filter_xxx_1_0_0 = filter.freq_xlating_fir_filter_fcc(1, (1, ), pscf2+pscfshift, samp_rate)
        self.freq_xlating_fir_filter_xxx_1_0 = filter.freq_xlating_fir_filter_fcc(1, (1, ), pscf1+pscfshift, samp_rate)
        self.freq_xlating_fir_filter_xxx_1 = filter.freq_xlating_fir_filter_ccc(1, (1, ), pscf1+pscfshift, samp_rate)
        self.freq_xlating_fir_filter_xxx_0_1 = filter.freq_xlating_fir_filter_ccc(5, (xlate_filter), xlatecenter_3+globaltune, variable_sample_rate_0)
        self.freq_xlating_fir_filter_xxx_0_0_0_0_2 = filter.freq_xlating_fir_filter_ccc(5, (xlate_filter), xlatecenter_8+globaltune, variable_sample_rate_0)
        self.freq_xlating_fir_filter_xxx_0_0_0_0_1 = filter.freq_xlating_fir_filter_ccc(5, (xlate_filter), xlatecenter_7+globaltune, variable_sample_rate_0)
        self.freq_xlating_fir_filter_xxx_0_0_0_0_0 = filter.freq_xlating_fir_filter_ccc(5, (xlate_filter), xlatecenter_6+globaltune, variable_sample_rate_0)
        self.freq_xlating_fir_filter_xxx_0_0_0_0 = filter.freq_xlating_fir_filter_ccc(5, (xlate_filter), xlatecenter_5+globaltune, variable_sample_rate_0)
        self.freq_xlating_fir_filter_xxx_0_0_0 = filter.freq_xlating_fir_filter_ccc(5, (xlate_filter), xlatecenter_4+globaltune, variable_sample_rate_0)
        self.freq_xlating_fir_filter_xxx_0_0 = filter.freq_xlating_fir_filter_ccc(5, (xlate_filter), xlatecenter_2+globaltune, variable_sample_rate_0)
        self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(5, (xlate_filter), xlatecenter+globaltune, variable_sample_rate_0)
        self.blocks_multiply_const_vxx_0_1_0_1_0 = blocks.multiply_const_vff((amp_am, ))
        self.blocks_multiply_const_vxx_0_1_0_1 = blocks.multiply_const_vff((amp_am, ))
        self.blocks_multiply_const_vxx_0_1_0_0 = blocks.multiply_const_vff((amp_fm, ))
        self.blocks_multiply_const_vxx_0_1_0 = blocks.multiply_const_vff((amp_fm, ))
        self.blocks_multiply_const_vxx_0_1 = blocks.multiply_const_vff((amp_1, ))
        self.blocks_multiply_const_vxx_0_0_2 = blocks.multiply_const_vff((amp_2, ))
        self.blocks_multiply_const_vxx_0_0_1_1_2 = blocks.multiply_const_vff((amp_8, ))
        self.blocks_multiply_const_vxx_0_0_1_1_1 = blocks.multiply_const_vff((amp_7, ))
        self.blocks_multiply_const_vxx_0_0_1_1_0 = blocks.multiply_const_vff((amp_6, ))
        self.blocks_multiply_const_vxx_0_0_1_1 = blocks.multiply_const_vff((amp_5, ))
        self.blocks_multiply_const_vxx_0_0_1_0_0_2 = blocks.multiply_const_vff((amp_8, ))
        self.blocks_multiply_const_vxx_0_0_1_0_0_1 = blocks.multiply_const_vff((amp_7, ))
        self.blocks_multiply_const_vxx_0_0_1_0_0_0 = blocks.multiply_const_vff((amp_6, ))
        self.blocks_multiply_const_vxx_0_0_1_0_0 = blocks.multiply_const_vff((amp_5, ))
        self.blocks_multiply_const_vxx_0_0_1_0 = blocks.multiply_const_vff((amp_4, ))
        self.blocks_multiply_const_vxx_0_0_1 = blocks.multiply_const_vff((amp_4, ))
        self.blocks_multiply_const_vxx_0_0_0_0 = blocks.multiply_const_vff((amp_3, ))
        self.blocks_multiply_const_vxx_0_0_0 = blocks.multiply_const_vff((amp_3, ))
        self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vff((amp_2, ))
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((amp_1, ))
        self.blocks_complex_to_float_7 = blocks.complex_to_float(1)
        self.blocks_complex_to_float_6_0_2 = blocks.complex_to_float(1)
        self.blocks_complex_to_float_6_0_1 = blocks.complex_to_float(1)
        self.blocks_complex_to_float_6_0_0 = blocks.complex_to_float(1)
        self.blocks_complex_to_float_6_0 = blocks.complex_to_float(1)
        self.blocks_complex_to_float_6 = blocks.complex_to_float(1)
        self.blocks_complex_to_float_5_0_2 = blocks.complex_to_float(1)
        self.blocks_complex_to_float_5_0_1 = blocks.complex_to_float(1)
        self.blocks_complex_to_float_5_0_0 = blocks.complex_to_float(1)
        self.blocks_complex_to_float_5_0 = blocks.complex_to_float(1)
        self.blocks_complex_to_float_5 = blocks.complex_to_float(1)
        self.blocks_complex_to_float_4 = blocks.complex_to_float(1)
        self.blocks_complex_to_float_3 = blocks.complex_to_float(1)
        self.blocks_complex_to_float_2 = blocks.complex_to_float(1)
        self.blocks_complex_to_float_1 = blocks.complex_to_float(1)
        self.blocks_complex_to_float_0 = blocks.complex_to_float(1)
        self.blocks_add_xx_1_1_0_0_0 = blocks.add_vff(1)
        self.blocks_add_xx_1_1_0_0 = blocks.add_vff(1)
        self.blocks_add_xx_1_1_0 = blocks.add_vff(1)
        self.blocks_add_xx_1_1 = blocks.add_vff(1)
        self.blocks_add_xx_1_0 = blocks.add_vff(1)
        self.blocks_add_xx_1 = blocks.add_vff(1)
        self.band_pass_filter_0_0_0_0_1 = filter.fir_filter_ccf(4, firdes.band_pass(
        	1, bpsr, bplow_3, bphi_3, bptrans, firdes.WIN_HAMMING, 6.76))
        self.band_pass_filter_0_0_0_0_0_0_0_2 = filter.fir_filter_ccf(4, firdes.band_pass(
        	1, bpsr, bplow_4, bphi_4, bptrans, firdes.WIN_HAMMING, 6.76))
        self.band_pass_filter_0_0_0_0_0_0_0_1 = filter.fir_filter_ccf(4, firdes.band_pass(
        	1, bpsr, bplow_4, bphi_4, bptrans, firdes.WIN_HAMMING, 6.76))
        self.band_pass_filter_0_0_0_0_0_0_0_0 = filter.fir_filter_ccf(4, firdes.band_pass(
        	1, bpsr, bplow_4, bphi_4, bptrans, firdes.WIN_HAMMING, 6.76))
        self.band_pass_filter_0_0_0_0_0_0_0 = filter.fir_filter_ccf(4, firdes.band_pass(
        	1, bpsr, bplow_4, bphi_4, bptrans, firdes.WIN_HAMMING, 6.76))
        self.band_pass_filter_0_0_0_0_0_0 = filter.fir_filter_ccf(4, firdes.band_pass(
        	1, bpsr, bplow_4, bphi_4, bptrans, firdes.WIN_HAMMING, 6.76))
        self.band_pass_filter_0_0_0_0_0 = filter.fir_filter_ccf(4, firdes.band_pass(
        	1, bpsr, bplow_2, bphi_2, bptrans, firdes.WIN_HAMMING, 6.76))
        self.band_pass_filter_0_0_0_0 = filter.fir_filter_ccf(4, firdes.band_pass(
        	1, bpsr, bplow_1, bphi_1, bptrans, firdes.WIN_HAMMING, 6.76))
        self.audio_sink_4 = audio.sink(44100, "Radio:AM2", True)
        self.audio_sink_3 = audio.sink(44100, "Radio:NFM2", True)
        self.audio_sink_2 = audio.sink(44100, "Radio:AM1", True)
        self.audio_sink_1 = audio.sink(44100, "Radio:NFM1", True)
        self.analog_nbfm_rx_0_0_1 = analog.nbfm_rx(
        	audio_rate=50000,
        	quad_rate=int(variable_sample_rate_0/5),
        	tau=75e-6,
        	max_dev=12500,
        )
        self.analog_nbfm_rx_0_0_0_0_0_2 = analog.nbfm_rx(
        	audio_rate=50000,
        	quad_rate=int(variable_sample_rate_0/5),
        	tau=75e-6,
        	max_dev=12500,
        )
        self.analog_nbfm_rx_0_0_0_0_0_1 = analog.nbfm_rx(
        	audio_rate=50000,
        	quad_rate=int(variable_sample_rate_0/5),
        	tau=75e-6,
        	max_dev=12500,
        )
        self.analog_nbfm_rx_0_0_0_0_0_0 = analog.nbfm_rx(
        	audio_rate=50000,
        	quad_rate=int(variable_sample_rate_0/5),
        	tau=75e-6,
        	max_dev=12500,
        )
        self.analog_nbfm_rx_0_0_0_0_0 = analog.nbfm_rx(
        	audio_rate=50000,
        	quad_rate=int(variable_sample_rate_0/5),
        	tau=75e-6,
        	max_dev=12500,
        )
        self.analog_nbfm_rx_0_0_0_0 = analog.nbfm_rx(
        	audio_rate=50000,
        	quad_rate=int(variable_sample_rate_0/5),
        	tau=75e-6,
        	max_dev=12500,
        )
        self.analog_nbfm_rx_0_0_0 = analog.nbfm_rx(
        	audio_rate=50000,
        	quad_rate=int(variable_sample_rate_0/5),
        	tau=75e-6,
        	max_dev=12500,
        )
        self.analog_nbfm_rx_0_0 = analog.nbfm_rx(
        	audio_rate=50000,
        	quad_rate=int(variable_sample_rate_0/5),
        	tau=75e-6,
        	max_dev=12500,
        )
        self.RTL820T = osmosdr.source( args="numchan=" + str(1) + " " + "" )
        self.RTL820T.set_sample_rate(variable_sample_rate_0)
        self.RTL820T.set_center_freq(CF, 0)
        self.RTL820T.set_freq_corr(0, 0)
        self.RTL820T.set_dc_offset_mode(2, 0)
        self.RTL820T.set_iq_balance_mode(0, 0)
        self.RTL820T.set_gain_mode(False, 0)
        self.RTL820T.set_gain(RF_Gain, 0)
        self.RTL820T.set_if_gain(20, 0)
        self.RTL820T.set_bb_gain(20, 0)
        self.RTL820T.set_antenna("", 0)
        self.RTL820T.set_bandwidth(1e6, 0)
          

        ##################################################
        # Connections
        ##################################################
        self.connect((self.RTL820T, 0), (self.freq_xlating_fir_filter_xxx_0, 0))    
        self.connect((self.RTL820T, 0), (self.freq_xlating_fir_filter_xxx_0_0, 0))    
        self.connect((self.RTL820T, 0), (self.freq_xlating_fir_filter_xxx_0_0_0, 0))    
        self.connect((self.RTL820T, 0), (self.freq_xlating_fir_filter_xxx_0_0_0_0, 0))    
        self.connect((self.RTL820T, 0), (self.freq_xlating_fir_filter_xxx_0_0_0_0_0, 0))    
        self.connect((self.RTL820T, 0), (self.freq_xlating_fir_filter_xxx_0_0_0_0_1, 0))    
        self.connect((self.RTL820T, 0), (self.freq_xlating_fir_filter_xxx_0_0_0_0_2, 0))    
        self.connect((self.RTL820T, 0), (self.freq_xlating_fir_filter_xxx_0_1, 0))    
        self.connect((self.RTL820T, 0), (self.wxgui_waterfallsink2_0, 0))    
        self.connect((self.analog_nbfm_rx_0_0, 0), (self.rational_resampler_xxx_1_0, 0))    
        self.connect((self.analog_nbfm_rx_0_0_0, 0), (self.rational_resampler_xxx_1_0_1, 0))    
        self.connect((self.analog_nbfm_rx_0_0_0_0, 0), (self.rational_resampler_xxx_1_0_1_0, 0))    
        self.connect((self.analog_nbfm_rx_0_0_0_0_0, 0), (self.rational_resampler_xxx_1_0_1_0_0, 0))    
        self.connect((self.analog_nbfm_rx_0_0_0_0_0_0, 0), (self.rational_resampler_xxx_1_0_1_0_0_0, 0))    
        self.connect((self.analog_nbfm_rx_0_0_0_0_0_1, 0), (self.rational_resampler_xxx_1_0_1_0_0_1, 0))    
        self.connect((self.analog_nbfm_rx_0_0_0_0_0_2, 0), (self.rational_resampler_xxx_1_0_1_0_0_2, 0))    
        self.connect((self.analog_nbfm_rx_0_0_1, 0), (self.rational_resampler_xxx_0, 0))    
        self.connect((self.band_pass_filter_0_0_0_0, 0), (self.rational_resampler_xxx_1_0_0, 0))    
        self.connect((self.band_pass_filter_0_0_0_0_0, 0), (self.rational_resampler_xxx_1_0_0_0, 0))    
        self.connect((self.band_pass_filter_0_0_0_0_0_0, 0), (self.rational_resampler_xxx_1_0_0_0_0, 0))    
        self.connect((self.band_pass_filter_0_0_0_0_0_0_0, 0), (self.rational_resampler_xxx_1_0_0_0_0_0, 0))    
        self.connect((self.band_pass_filter_0_0_0_0_0_0_0_0, 0), (self.rational_resampler_xxx_1_0_0_0_0_0_0, 0))    
        self.connect((self.band_pass_filter_0_0_0_0_0_0_0_1, 0), (self.rational_resampler_xxx_1_0_0_0_0_0_1, 0))    
        self.connect((self.band_pass_filter_0_0_0_0_0_0_0_2, 0), (self.rational_resampler_xxx_1_0_0_0_0_0_2, 0))    
        self.connect((self.band_pass_filter_0_0_0_0_1, 0), (self.rational_resampler_xxx_1_0_0_1, 0))    
        self.connect((self.blocks_add_xx_1, 0), (self.blocks_multiply_const_vxx_0_1_0, 0))    
        self.connect((self.blocks_add_xx_1_0, 0), (self.blocks_multiply_const_vxx_0_1_0_1, 0))    
        self.connect((self.blocks_add_xx_1_1, 0), (self.blocks_multiply_const_vxx_0_1_0_0, 0))    
        self.connect((self.blocks_add_xx_1_1_0, 0), (self.blocks_multiply_const_vxx_0_1_0_1_0, 0))    
        self.connect((self.blocks_add_xx_1_1_0_0, 0), (self.blocks_add_xx_1_1, 2))    
        self.connect((self.blocks_add_xx_1_1_0_0_0, 0), (self.blocks_add_xx_1_1_0, 2))    
        self.connect((self.blocks_complex_to_float_0, 0), (self.blocks_multiply_const_vxx_0, 0))    
        self.connect((self.blocks_complex_to_float_1, 0), (self.blocks_multiply_const_vxx_0_1, 0))    
        self.connect((self.blocks_complex_to_float_2, 0), (self.blocks_multiply_const_vxx_0_0, 0))    
        self.connect((self.blocks_complex_to_float_3, 0), (self.blocks_multiply_const_vxx_0_0_2, 0))    
        self.connect((self.blocks_complex_to_float_4, 0), (self.blocks_multiply_const_vxx_0_0_0_0, 0))    
        self.connect((self.blocks_complex_to_float_5, 0), (self.blocks_multiply_const_vxx_0_0_1_0, 0))    
        self.connect((self.blocks_complex_to_float_5_0, 0), (self.blocks_multiply_const_vxx_0_0_1_0_0, 0))    
        self.connect((self.blocks_complex_to_float_5_0_0, 0), (self.blocks_multiply_const_vxx_0_0_1_0_0_0, 0))    
        self.connect((self.blocks_complex_to_float_5_0_1, 0), (self.blocks_multiply_const_vxx_0_0_1_0_0_1, 0))    
        self.connect((self.blocks_complex_to_float_5_0_2, 0), (self.blocks_multiply_const_vxx_0_0_1_0_0_2, 0))    
        self.connect((self.blocks_complex_to_float_6, 0), (self.blocks_multiply_const_vxx_0_0_1, 0))    
        self.connect((self.blocks_complex_to_float_6_0, 0), (self.blocks_multiply_const_vxx_0_0_1_1, 0))    
        self.connect((self.blocks_complex_to_float_6_0_0, 0), (self.blocks_multiply_const_vxx_0_0_1_1_0, 0))    
        self.connect((self.blocks_complex_to_float_6_0_1, 0), (self.blocks_multiply_const_vxx_0_0_1_1_1, 0))    
        self.connect((self.blocks_complex_to_float_6_0_2, 0), (self.blocks_multiply_const_vxx_0_0_1_1_2, 0))    
        self.connect((self.blocks_complex_to_float_7, 0), (self.blocks_multiply_const_vxx_0_0_0, 0))    
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_add_xx_1, 0))    
        self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.blocks_add_xx_1, 1))    
        self.connect((self.blocks_multiply_const_vxx_0_0_0, 0), (self.blocks_add_xx_1_1, 0))    
        self.connect((self.blocks_multiply_const_vxx_0_0_0_0, 0), (self.blocks_add_xx_1_1_0, 0))    
        self.connect((self.blocks_multiply_const_vxx_0_0_1, 0), (self.blocks_add_xx_1_1, 1))    
        self.connect((self.blocks_multiply_const_vxx_0_0_1_0, 0), (self.blocks_add_xx_1_1_0, 1))    
        self.connect((self.blocks_multiply_const_vxx_0_0_1_0_0, 0), (self.blocks_add_xx_1_1_0_0_0, 0))    
        self.connect((self.blocks_multiply_const_vxx_0_0_1_0_0_0, 0), (self.blocks_add_xx_1_1_0_0_0, 1))    
        self.connect((self.blocks_multiply_const_vxx_0_0_1_0_0_1, 0), (self.blocks_add_xx_1_1_0_0_0, 2))    
        self.connect((self.blocks_multiply_const_vxx_0_0_1_0_0_2, 0), (self.blocks_add_xx_1_1_0_0_0, 3))    
        self.connect((self.blocks_multiply_const_vxx_0_0_1_1, 0), (self.blocks_add_xx_1_1_0_0, 0))    
        self.connect((self.blocks_multiply_const_vxx_0_0_1_1_0, 0), (self.blocks_add_xx_1_1_0_0, 1))    
        self.connect((self.blocks_multiply_const_vxx_0_0_1_1_1, 0), (self.blocks_add_xx_1_1_0_0, 2))    
        self.connect((self.blocks_multiply_const_vxx_0_0_1_1_2, 0), (self.blocks_add_xx_1_1_0_0, 3))    
        self.connect((self.blocks_multiply_const_vxx_0_0_2, 0), (self.blocks_add_xx_1_0, 1))    
        self.connect((self.blocks_multiply_const_vxx_0_1, 0), (self.blocks_add_xx_1_0, 0))    
        self.connect((self.blocks_multiply_const_vxx_0_1_0, 0), (self.audio_sink_1, 0))    
        self.connect((self.blocks_multiply_const_vxx_0_1_0_0, 0), (self.audio_sink_3, 0))    
        self.connect((self.blocks_multiply_const_vxx_0_1_0_1, 0), (self.audio_sink_2, 0))    
        self.connect((self.blocks_multiply_const_vxx_0_1_0_1_0, 0), (self.audio_sink_4, 0))    
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.analog_nbfm_rx_0_0, 0))    
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.band_pass_filter_0_0_0_0, 0))    
        self.connect((self.freq_xlating_fir_filter_xxx_0_0, 0), (self.analog_nbfm_rx_0_0_0, 0))    
        self.connect((self.freq_xlating_fir_filter_xxx_0_0, 0), (self.band_pass_filter_0_0_0_0_0, 0))    
        self.connect((self.freq_xlating_fir_filter_xxx_0_0_0, 0), (self.analog_nbfm_rx_0_0_0_0, 0))    
        self.connect((self.freq_xlating_fir_filter_xxx_0_0_0, 0), (self.band_pass_filter_0_0_0_0_0_0, 0))    
        self.connect((self.freq_xlating_fir_filter_xxx_0_0_0_0, 0), (self.analog_nbfm_rx_0_0_0_0_0, 0))    
        self.connect((self.freq_xlating_fir_filter_xxx_0_0_0_0, 0), (self.band_pass_filter_0_0_0_0_0_0_0, 0))    
        self.connect((self.freq_xlating_fir_filter_xxx_0_0_0_0_0, 0), (self.analog_nbfm_rx_0_0_0_0_0_0, 0))    
        self.connect((self.freq_xlating_fir_filter_xxx_0_0_0_0_0, 0), (self.band_pass_filter_0_0_0_0_0_0_0_0, 0))    
        self.connect((self.freq_xlating_fir_filter_xxx_0_0_0_0_1, 0), (self.analog_nbfm_rx_0_0_0_0_0_1, 0))    
        self.connect((self.freq_xlating_fir_filter_xxx_0_0_0_0_1, 0), (self.band_pass_filter_0_0_0_0_0_0_0_1, 0))    
        self.connect((self.freq_xlating_fir_filter_xxx_0_0_0_0_2, 0), (self.analog_nbfm_rx_0_0_0_0_0_2, 0))    
        self.connect((self.freq_xlating_fir_filter_xxx_0_0_0_0_2, 0), (self.band_pass_filter_0_0_0_0_0_0_0_2, 0))    
        self.connect((self.freq_xlating_fir_filter_xxx_0_1, 0), (self.analog_nbfm_rx_0_0_1, 0))    
        self.connect((self.freq_xlating_fir_filter_xxx_0_1, 0), (self.band_pass_filter_0_0_0_0_1, 0))    
        self.connect((self.freq_xlating_fir_filter_xxx_1, 0), (self.blocks_complex_to_float_1, 0))    
        self.connect((self.freq_xlating_fir_filter_xxx_1_0, 0), (self.blocks_complex_to_float_0, 0))    
        self.connect((self.freq_xlating_fir_filter_xxx_1_0_0, 0), (self.blocks_complex_to_float_2, 0))    
        self.connect((self.freq_xlating_fir_filter_xxx_1_0_0_0, 0), (self.blocks_complex_to_float_7, 0))    
        self.connect((self.freq_xlating_fir_filter_xxx_1_0_0_0_0, 0), (self.blocks_complex_to_float_6, 0))    
        self.connect((self.freq_xlating_fir_filter_xxx_1_0_0_0_0_0, 0), (self.blocks_complex_to_float_6_0, 0))    
        self.connect((self.freq_xlating_fir_filter_xxx_1_0_0_0_0_0_0, 0), (self.blocks_complex_to_float_6_0_0, 0))    
        self.connect((self.freq_xlating_fir_filter_xxx_1_0_0_0_0_0_1, 0), (self.blocks_complex_to_float_6_0_1, 0))    
        self.connect((self.freq_xlating_fir_filter_xxx_1_0_0_0_0_0_2, 0), (self.blocks_complex_to_float_6_0_2, 0))    
        self.connect((self.freq_xlating_fir_filter_xxx_1_1, 0), (self.blocks_complex_to_float_3, 0))    
        self.connect((self.freq_xlating_fir_filter_xxx_1_1_0, 0), (self.blocks_complex_to_float_4, 0))    
        self.connect((self.freq_xlating_fir_filter_xxx_1_1_0_0, 0), (self.blocks_complex_to_float_5, 0))    
        self.connect((self.freq_xlating_fir_filter_xxx_1_1_0_0_0, 0), (self.blocks_complex_to_float_5_0, 0))    
        self.connect((self.freq_xlating_fir_filter_xxx_1_1_0_0_0_0, 0), (self.blocks_complex_to_float_5_0_0, 0))    
        self.connect((self.freq_xlating_fir_filter_xxx_1_1_0_0_0_1, 0), (self.blocks_complex_to_float_5_0_1, 0))    
        self.connect((self.freq_xlating_fir_filter_xxx_1_1_0_0_0_2, 0), (self.blocks_complex_to_float_5_0_2, 0))    
        self.connect((self.rational_resampler_xxx_0, 0), (self.freq_xlating_fir_filter_xxx_1_0_0_0, 0))    
        self.connect((self.rational_resampler_xxx_1_0, 0), (self.freq_xlating_fir_filter_xxx_1_0, 0))    
        self.connect((self.rational_resampler_xxx_1_0_0, 0), (self.freq_xlating_fir_filter_xxx_1, 0))    
        self.connect((self.rational_resampler_xxx_1_0_0_0, 0), (self.freq_xlating_fir_filter_xxx_1_1, 0))    
        self.connect((self.rational_resampler_xxx_1_0_0_0_0, 0), (self.freq_xlating_fir_filter_xxx_1_1_0_0, 0))    
        self.connect((self.rational_resampler_xxx_1_0_0_0_0_0, 0), (self.freq_xlating_fir_filter_xxx_1_1_0_0_0, 0))    
        self.connect((self.rational_resampler_xxx_1_0_0_0_0_0_0, 0), (self.freq_xlating_fir_filter_xxx_1_1_0_0_0_0, 0))    
        self.connect((self.rational_resampler_xxx_1_0_0_0_0_0_1, 0), (self.freq_xlating_fir_filter_xxx_1_1_0_0_0_1, 0))    
        self.connect((self.rational_resampler_xxx_1_0_0_0_0_0_2, 0), (self.freq_xlating_fir_filter_xxx_1_1_0_0_0_2, 0))    
        self.connect((self.rational_resampler_xxx_1_0_0_1, 0), (self.freq_xlating_fir_filter_xxx_1_1_0, 0))    
        self.connect((self.rational_resampler_xxx_1_0_1, 0), (self.freq_xlating_fir_filter_xxx_1_0_0, 0))    
        self.connect((self.rational_resampler_xxx_1_0_1_0, 0), (self.freq_xlating_fir_filter_xxx_1_0_0_0_0, 0))    
        self.connect((self.rational_resampler_xxx_1_0_1_0_0, 0), (self.freq_xlating_fir_filter_xxx_1_0_0_0_0_0, 0))    
        self.connect((self.rational_resampler_xxx_1_0_1_0_0_0, 0), (self.freq_xlating_fir_filter_xxx_1_0_0_0_0_0_0, 0))    
        self.connect((self.rational_resampler_xxx_1_0_1_0_0_1, 0), (self.freq_xlating_fir_filter_xxx_1_0_0_0_0_0_1, 0))    
        self.connect((self.rational_resampler_xxx_1_0_1_0_0_2, 0), (self.freq_xlating_fir_filter_xxx_1_0_0_0_0_0_2, 0))    
    def __init__(self):
        gr.top_block.__init__(self, "Top Block")

        ##################################################
        # Variables
        ##################################################
        self.audio_rate = audio_rate = int(48e3)
        self.rtl_rate = rtl_rate = int(240e3)
        self.out_intermediary_rate = out_intermediary_rate = audio_rate*4
        self.out_gain = out_gain = .25
        self.out_frequency_offset = out_frequency_offset = -50e3
        self.out_frequency = out_frequency = 145.521e6
        self.out_audio_inverted = out_audio_inverted = True
        self.in_frequency_offset = in_frequency_offset = 0
        self.in_frequency = in_frequency = 145.551e6
        self.in_final_gain = in_final_gain = 0.5
        self.in_decimation_factor = in_decimation_factor = 8
        self.in_audio_inverted = in_audio_inverted = True
        self.hackrf_rate = hackrf_rate = 2e6
        self.dstar_bandwidth = dstar_bandwidth = 6.5e3

        ##################################################
        # Blocks
        ##################################################
        self.rtlsdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + "" )
        self.rtlsdr_source_0.set_sample_rate(rtl_rate)
        self.rtlsdr_source_0.set_center_freq(in_frequency+in_frequency_offset, 0)
        self.rtlsdr_source_0.set_freq_corr(69, 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(10, 0)
        self.rtlsdr_source_0.set_if_gain(20, 0)
        self.rtlsdr_source_0.set_bb_gain(20, 0)
        self.rtlsdr_source_0.set_antenna("", 0)
        self.rtlsdr_source_0.set_bandwidth(0, 0)
          
        self.rational_resampler_xxx_3 = filter.rational_resampler_ccc(
                interpolation=int(hackrf_rate),
                decimation=out_intermediary_rate,
                taps=None,
                fractional_bw=None,
        )
        self.osmosdr_sink_0 = osmosdr.sink( args="numchan=" + str(1) + " " + "" )
        self.osmosdr_sink_0.set_sample_rate(hackrf_rate)
        self.osmosdr_sink_0.set_center_freq(out_frequency-out_frequency_offset, 0)
        self.osmosdr_sink_0.set_freq_corr(4, 0)
        self.osmosdr_sink_0.set_gain(14, 0)
        self.osmosdr_sink_0.set_if_gain(0, 0)
        self.osmosdr_sink_0.set_bb_gain(0, 0)
        self.osmosdr_sink_0.set_antenna("0", 0)
        self.osmosdr_sink_0.set_bandwidth(100e3, 0)
          
        self.low_pass_filter_1 = filter.fir_filter_ccf(5, firdes.low_pass(
        	1, rtl_rate, dstar_bandwidth*2, 500, firdes.WIN_HAMMING, 6.76))
        self.low_pass_filter_0 = filter.fir_filter_fff(1, firdes.low_pass(
        	1, audio_rate, dstar_bandwidth*2, 200, firdes.WIN_KAISER, 6.76))
        self.freq_xlating_fft_filter_ccc_0 = filter.freq_xlating_fft_filter_ccc(1, (1, ), 0-out_frequency_offset, out_intermediary_rate)
        self.freq_xlating_fft_filter_ccc_0.set_nthreads(1)
        self.freq_xlating_fft_filter_ccc_0.declare_sample_delay(0)
        self.dc_blocker_xx_0 = filter.dc_blocker_ff(128, True)
        self.blocks_multiply_const_vxx_2 = blocks.multiply_const_vff(((-1 if out_audio_inverted else 1)*out_gain, ))
        self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vff((0-in_final_gain if in_audio_inverted else in_final_gain, ))
        self.audio_source_0 = audio.source(audio_rate, "hw:10,1", True)
        self.audio_sink_1 = audio.sink(audio_rate, "plughw:11,0", True)
        self.analog_pwr_squelch_xx_1 = analog.pwr_squelch_cc(-30, 1, 1, False)
        self.analog_pwr_squelch_xx_0 = analog.pwr_squelch_ff(-60, 1, 1, True)
        self.analog_nbfm_tx_0 = analog.nbfm_tx(
        	audio_rate=int(audio_rate),
        	quad_rate=int(out_intermediary_rate),
        	tau=0,
        	max_dev=dstar_bandwidth,
        )
        self.analog_nbfm_rx_0 = analog.nbfm_rx(
        	audio_rate=audio_rate,
        	quad_rate=audio_rate,
        	tau=0.000000000000000000001,
        	max_dev=dstar_bandwidth*2,
        )

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_nbfm_rx_0, 0), (self.blocks_multiply_const_vxx_1, 0))    
        self.connect((self.analog_nbfm_tx_0, 0), (self.freq_xlating_fft_filter_ccc_0, 0))    
        self.connect((self.analog_pwr_squelch_xx_0, 0), (self.blocks_multiply_const_vxx_2, 0))    
        self.connect((self.analog_pwr_squelch_xx_1, 0), (self.analog_nbfm_rx_0, 0))    
        self.connect((self.audio_source_0, 0), (self.dc_blocker_xx_0, 0))    
        self.connect((self.blocks_multiply_const_vxx_1, 0), (self.audio_sink_1, 0))    
        self.connect((self.blocks_multiply_const_vxx_2, 0), (self.low_pass_filter_0, 0))    
        self.connect((self.dc_blocker_xx_0, 0), (self.analog_pwr_squelch_xx_0, 0))    
        self.connect((self.freq_xlating_fft_filter_ccc_0, 0), (self.rational_resampler_xxx_3, 0))    
        self.connect((self.low_pass_filter_0, 0), (self.analog_nbfm_tx_0, 0))    
        self.connect((self.low_pass_filter_1, 0), (self.analog_pwr_squelch_xx_1, 0))    
        self.connect((self.rational_resampler_xxx_3, 0), (self.osmosdr_sink_0, 0))    
        self.connect((self.rtlsdr_source_0, 0), (self.low_pass_filter_1, 0))    
Example #24
0
    def __init__(self):
        gr.top_block.__init__(self, "NBFM")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("NBFM")
        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")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.radio_freq = radio_freq = 100
        self.volume = volume = 5
        self.squelch = squelch = -30
        self.samp_rate = samp_rate = 240e4
        self.rf_gain = rf_gain = 10
        self.freq = freq = radio_freq * 1000000

        ##################################################
        # Blocks
        ##################################################
        self._volume_range = Range(0, 10, 1, 5, 200)
        self._volume_win = RangeWidget(self._volume_range, self.set_volume,
                                       "Volume", "counter_slider", float)
        self.top_layout.addWidget(self._volume_win)
        self._squelch_range = Range(-70, 0, 10, -30, 200)
        self._squelch_win = RangeWidget(self._squelch_range, self.set_squelch,
                                        "Squelch", "counter_slider", int)
        self.top_layout.addWidget(self._squelch_win)
        self._rf_gain_range = Range(0, 50, 1, 10, 200)
        self._rf_gain_win = RangeWidget(self._rf_gain_range, self.set_rf_gain,
                                        "RF Gain", "counter_slider", float)
        self.top_layout.addWidget(self._rf_gain_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(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(20, 0)
        self.rtlsdr_source_0.set_bb_gain(20, 0)
        self.rtlsdr_source_0.set_antenna("", 0)
        self.rtlsdr_source_0.set_bandwidth(0, 0)

        self.rational_resampler_xxx_1_0 = filter.rational_resampler_fff(
            interpolation=60,
            decimation=35,
            taps=None,
            fractional_bw=None,
        )
        self._radio_freq_tool_bar = Qt.QToolBar(self)
        self._radio_freq_tool_bar.addWidget(Qt.QLabel("Frequency (MHz)" +
                                                      ": "))
        self._radio_freq_line_edit = Qt.QLineEdit(str(self.radio_freq))
        self._radio_freq_tool_bar.addWidget(self._radio_freq_line_edit)
        self._radio_freq_line_edit.returnPressed.connect(
            lambda: self.set_radio_freq(
                eng_notation.str_to_num(
                    str(self._radio_freq_line_edit.text().toAscii()))))
        self.top_layout.addWidget(self._radio_freq_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)

        if not True:
            self.qtgui_waterfall_sink_x_0.disable_legend()

        if complex == type(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_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, 10)
        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_control_panel(False)

        if not True:
            self.qtgui_freq_sink_x_0.disable_legend()

        if complex == type(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.low_pass_filter_0_0 = filter.fir_filter_ccf(
            8,
            firdes.low_pass(1, samp_rate, 5000, 8000, firdes.WIN_HAMMING,
                            6.76))
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff(
            (volume, ))
        self.audio_sink_0 = audio.sink(48000, "", True)
        self.analog_pwr_squelch_xx_0 = analog.pwr_squelch_cc(
            squelch, 1e-4, 0, True)
        self.analog_nbfm_rx_0 = analog.nbfm_rx(
            audio_rate=30000,
            quad_rate=300000,
            tau=75e-6,
            max_dev=12.5e3,
        )

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_nbfm_rx_0, 0),
                     (self.rational_resampler_xxx_1_0, 0))
        self.connect((self.analog_pwr_squelch_xx_0, 0),
                     (self.low_pass_filter_0_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.audio_sink_0, 0))
        self.connect((self.low_pass_filter_0_0, 0), (self.analog_nbfm_rx_0, 0))
        self.connect((self.rational_resampler_xxx_1_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.rtlsdr_source_0, 0),
                     (self.analog_pwr_squelch_xx_0, 0))
        self.connect((self.rtlsdr_source_0, 0), (self.qtgui_freq_sink_x_0, 0))
        self.connect((self.rtlsdr_source_0, 0),
                     (self.qtgui_waterfall_sink_x_0, 0))
Example #25
0
    def __init__(self):
        gr.top_block.__init__(self, "Lang Rx")

        ##################################################
        # Variables
        ##################################################
        plutoip = os.environ.get('PLUTO_IP')
        if plutoip == None:
            plutoip = 'pluto.local'
        plutoip = 'ip:' + plutoip
        self.SQL = SQL = 50
        self.RxOffset = RxOffset = 0
        self.Mute = Mute = False
        self.Mode = Mode = 3
        self.Filt_Low = Filt_Low = 300
        self.Filt_High = Filt_High = 3000
        self.FFTEn = FFTEn = 0
        self.AFGain = AFGain = 20

        ##################################################
        # Blocks
        ##################################################
        self.pluto_source_0 = iio.pluto_source(plutoip, 1000000000, 528000,
                                               2000000, 0x800, True, True,
                                               True, "slow_attack", 64.0, '',
                                               True)
        self.logpwrfft_x_0 = logpwrfft.logpwrfft_c(
            sample_rate=48000,
            fft_size=512,
            ref_scale=2,
            frame_rate=15,
            avg_alpha=0.9,
            average=True,
        )
        self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(
            11, (firdes.low_pass(1, 529200, 23000, 2000)), RxOffset, 528000)
        self.blocks_udp_sink_0 = blocks.udp_sink(gr.sizeof_float * 512,
                                                 '127.0.0.1', 7373, 1472,
                                                 False)
        self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_float * 512)
        self.blocks_multiply_const_vxx_2_1_0 = blocks.multiply_const_vff(
            (1.0 + (Mode == 5), ))
        self.blocks_multiply_const_vxx_2_1 = blocks.multiply_const_vff(
            (Mode == 5, ))
        self.blocks_multiply_const_vxx_2_0 = blocks.multiply_const_vff(
            ((Mode == 4) * 0.2, ))
        self.blocks_multiply_const_vxx_2 = blocks.multiply_const_vff(
            (Mode < 4, ))
        self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vff(
            ((AFGain / 100.0) * (not Mute), ))
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        self.blocks_complex_to_real_0_0 = blocks.complex_to_real(1)
        self.blocks_complex_to_real_0 = blocks.complex_to_real(1)
        self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1)
        self.blocks_add_xx_1_0 = blocks.add_vff(1)
        self.blocks_add_xx_1 = blocks.add_vff(1)
        self.blks2_selector_0 = grc_blks2.selector(
            item_size=gr.sizeof_float * 512,
            num_inputs=1,
            num_outputs=2,
            input_index=0,
            output_index=FFTEn,
        )
        self.band_pass_filter_0 = filter.fir_filter_ccc(
            1,
            firdes.complex_band_pass(1, 48000, Filt_Low, Filt_High, 100,
                                     firdes.WIN_HAMMING, 6.76))
        self.audio_sink_0 = audio.sink(48000, "hw:CARD=Device,DEV=0", False)
        self.analog_pwr_squelch_xx_0 = analog.pwr_squelch_cc(
            SQL - 100, 0.001, 0, False)
        self.analog_nbfm_rx_0 = analog.nbfm_rx(
            audio_rate=48000,
            quad_rate=48000,
            tau=75e-6,
            max_dev=5e3,
        )
        self.analog_agc3_xx_0 = analog.agc3_cc(1e-2, 5e-7, 0.1, 1.0, 1)
        self.analog_agc3_xx_0.set_max_gain(1000)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_agc3_xx_0, 0),
                     (self.blocks_complex_to_real_0_0, 0))
        self.connect((self.analog_nbfm_rx_0, 0),
                     (self.blocks_multiply_const_vxx_2_0, 0))
        self.connect((self.analog_pwr_squelch_xx_0, 0),
                     (self.analog_nbfm_rx_0, 0))
        self.connect((self.band_pass_filter_0, 0),
                     (self.analog_pwr_squelch_xx_0, 0))
        self.connect((self.band_pass_filter_0, 0),
                     (self.blocks_complex_to_mag_0, 0))
        self.connect((self.band_pass_filter_0, 0),
                     (self.blocks_complex_to_real_0, 0))
        self.connect((self.blks2_selector_0, 0), (self.blocks_null_sink_0, 0))
        self.connect((self.blks2_selector_0, 1), (self.blocks_udp_sink_0, 0))
        self.connect((self.blocks_add_xx_1, 0),
                     (self.blocks_multiply_const_vxx_1, 0))
        self.connect((self.blocks_add_xx_1_0, 0),
                     (self.blocks_float_to_complex_0, 0))
        self.connect((self.blocks_complex_to_mag_0, 0),
                     (self.blocks_multiply_const_vxx_2_1, 0))
        self.connect((self.blocks_complex_to_real_0, 0),
                     (self.blocks_multiply_const_vxx_2, 0))
        self.connect((self.blocks_complex_to_real_0_0, 0),
                     (self.blocks_multiply_const_vxx_2_1_0, 0))
        self.connect((self.blocks_float_to_complex_0, 0),
                     (self.analog_agc3_xx_0, 0))
        self.connect((self.blocks_multiply_const_vxx_1, 0),
                     (self.audio_sink_0, 0))
        self.connect((self.blocks_multiply_const_vxx_2, 0),
                     (self.blocks_add_xx_1_0, 0))
        self.connect((self.blocks_multiply_const_vxx_2_0, 0),
                     (self.blocks_add_xx_1, 1))
        self.connect((self.blocks_multiply_const_vxx_2_1, 0),
                     (self.blocks_add_xx_1_0, 1))
        self.connect((self.blocks_multiply_const_vxx_2_1_0, 0),
                     (self.blocks_add_xx_1, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0),
                     (self.band_pass_filter_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0),
                     (self.logpwrfft_x_0, 0))
        self.connect((self.logpwrfft_x_0, 0), (self.blks2_selector_0, 0))
        self.connect((self.pluto_source_0, 0),
                     (self.freq_xlating_fir_filter_xxx_0, 0))
Example #26
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Nbfm Wav Out")

        ##################################################
        # Variables
        ##################################################
        self.decim = decim = 2
        self.adc_rate = adc_rate = 2000000
        self.xlate_offset_fine = xlate_offset_fine = 4000
        self.xlate_offset = xlate_offset = 0
        self.xlate_decim = xlate_decim = 4
        self.xlate_bandwidth = xlate_bandwidth = 12500
        self.volume = volume = 1
        self.squelch = squelch = 50
        self.samp_rate = samp_rate = adc_rate/decim
        self.main_freq = main_freq = 167.99e6
        self.audio_rate = audio_rate = 48000
        self.audio_interp = audio_interp = 4

        ##################################################
        # Blocks
        ##################################################
        self.main_notebook = self.main_notebook = wx.Notebook(self.GetWin(), style=wx.NB_TOP)
        self.main_notebook.AddPage(grc_wxgui.Panel(self.main_notebook), "Baseband")
        self.main_notebook.AddPage(grc_wxgui.Panel(self.main_notebook), "Scope")
        self.main_notebook.AddPage(grc_wxgui.Panel(self.main_notebook), "Waterfall")
        self.main_notebook.AddPage(grc_wxgui.Panel(self.main_notebook), "Quad demod")
        self.Add(self.main_notebook)
        _xlate_offset_fine_sizer = wx.BoxSizer(wx.VERTICAL)
        self._xlate_offset_fine_text_box = forms.text_box(
        	parent=self.main_notebook.GetPage(0).GetWin(),
        	sizer=_xlate_offset_fine_sizer,
        	value=self.xlate_offset_fine,
        	callback=self.set_xlate_offset_fine,
        	label="Fine Offset",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._xlate_offset_fine_slider = forms.slider(
        	parent=self.main_notebook.GetPage(0).GetWin(),
        	sizer=_xlate_offset_fine_sizer,
        	value=self.xlate_offset_fine,
        	callback=self.set_xlate_offset_fine,
        	minimum=-10000,
        	maximum=10000,
        	num_steps=100,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.main_notebook.GetPage(0).Add(_xlate_offset_fine_sizer)
        self._xlate_offset_text_box = forms.text_box(
        	parent=self.main_notebook.GetPage(0).GetWin(),
        	value=self.xlate_offset,
        	callback=self.set_xlate_offset,
        	label="Xlate Offset",
        	converter=forms.float_converter(),
        )
        self.main_notebook.GetPage(0).Add(self._xlate_offset_text_box)
        _xlate_bandwidth_sizer = wx.BoxSizer(wx.VERTICAL)
        self._xlate_bandwidth_text_box = forms.text_box(
        	parent=self.main_notebook.GetPage(0).GetWin(),
        	sizer=_xlate_bandwidth_sizer,
        	value=self.xlate_bandwidth,
        	callback=self.set_xlate_bandwidth,
        	label="Xlate Bandwidth",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._xlate_bandwidth_slider = forms.slider(
        	parent=self.main_notebook.GetPage(0).GetWin(),
        	sizer=_xlate_bandwidth_sizer,
        	value=self.xlate_bandwidth,
        	callback=self.set_xlate_bandwidth,
        	minimum=2500,
        	maximum=250000,
        	num_steps=100,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.main_notebook.GetPage(0).Add(_xlate_bandwidth_sizer)
        _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=10,
        	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=0,
        	maximum=100,
        	num_steps=100,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.Add(_squelch_sizer)
        self._main_freq_text_box = forms.text_box(
        	parent=self.main_notebook.GetPage(0).GetWin(),
        	value=self.main_freq,
        	callback=self.set_main_freq,
        	label="Main Freq",
        	converter=forms.float_converter(),
        )
        self.main_notebook.GetPage(0).Add(self._main_freq_text_box)
        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(main_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(2, 0)
        self.rtlsdr_source_0.set_gain_mode(True, 0)
        self.rtlsdr_source_0.set_gain(50, 0)
        self.rtlsdr_source_0.set_if_gain(20, 0)
        self.rtlsdr_source_0.set_bb_gain(20, 0)
        self.rtlsdr_source_0.set_antenna("", 0)
        self.rtlsdr_source_0.set_bandwidth(0, 0)
          
        self.rational_resampler_xxx_0_0 = filter.rational_resampler_fff(
                interpolation=audio_rate*audio_interp,
                decimation=samp_rate/xlate_decim,
                taps=None,
                fractional_bw=None,
        )
        self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(xlate_decim, (firdes.low_pass(1, samp_rate, xlate_bandwidth/2, 1000)), xlate_offset + xlate_offset_fine, samp_rate)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((volume, ))
        self.audio_sink_0 = audio.sink(48000, "", True)
        self.analog_pwr_squelch_xx_0 = analog.pwr_squelch_cc(squelch*-1, 0.1, 1, False)
        self.analog_nbfm_rx_0 = analog.nbfm_rx(
        	audio_rate=audio_rate,
        	quad_rate=audio_rate*audio_interp,
        	tau=75e-6,
        	max_dev=5e3,
        )

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_nbfm_rx_0, 0), (self.rational_resampler_xxx_0_0, 0))    
        self.connect((self.analog_pwr_squelch_xx_0, 0), (self.analog_nbfm_rx_0, 0))    
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.audio_sink_0, 0))    
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.analog_pwr_squelch_xx_0, 0))    
        self.connect((self.rational_resampler_xxx_0_0, 0), (self.blocks_multiply_const_vxx_0, 0))    
        self.connect((self.rtlsdr_source_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0))    
    def __init__(self):
        gr.top_block.__init__(self, "Multimon Flex Rtl 0")

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 2.4e6
        self.channel_1 = channel_1 = 929.65e6
        self.channel_0 = channel_0 = 929.6e6
        self.xlate_filter_taps = xlate_filter_taps = firdes.low_pass(1, samp_rate, 125000, 25000, firdes.WIN_HAMMING, 6.76)
        self.sqlch = sqlch = -50
        self.if_gain = if_gain = -14
        self.gain = gain = 50
        self.firdes_tap = firdes_tap = firdes.low_pass(1, samp_rate, 125000, 25000, firdes.WIN_HAMMING, 6.76)
        self.corr = corr = -14
        self.center_freq_0 = center_freq_0 = sum([channel_0, channel_1] ) / float(len([channel_0, channel_1]))
        self.bb_gain = bb_gain = 40

        ##################################################
        # Blocks
        ##################################################
        self.osmosdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + 'rtl=0' )
        self.osmosdr_source_0.set_sample_rate(samp_rate)
        self.osmosdr_source_0.set_center_freq(center_freq_0 - 100000, 0)
        self.osmosdr_source_0.set_freq_corr(corr, 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(True, 0)
        self.osmosdr_source_0.set_gain(gain, 0)
        self.osmosdr_source_0.set_if_gain(if_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(0, 0)

        self.low_pass_filter_0_0 = filter.fir_filter_ccf(1, firdes.low_pass(
        	1, 48e3, 6.5e3, 2e3, firdes.WIN_HAMMING, 6.76))
        self.low_pass_filter_0 = filter.fir_filter_ccf(1, firdes.low_pass(
        	1, 48e3, 6.5e3, 2e3, firdes.WIN_HAMMING, 6.76))
        self.freq_xlating_fir_filter_xxx_0_0 = filter.freq_xlating_fir_filter_ccc(int(samp_rate / 48000), (firdes_tap), channel_1 - center_freq_0, samp_rate)
        self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(int(samp_rate / 48000), (firdes_tap), channel_0 - center_freq_0, samp_rate)
        self.blocks_udp_sink_1 = blocks.udp_sink(gr.sizeof_short*1, '127.0.0.1', 7301, 1472, True)
        self.blocks_udp_sink_0 = blocks.udp_sink(gr.sizeof_short*1, '127.0.0.1', 7300, 1472, True)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_multiply_const_vxx_0_2 = blocks.multiply_const_vff((0.1, ))
        self.blocks_multiply_const_vxx_0_0_1 = blocks.multiply_const_vff((0.1, ))
        self.blocks_float_to_short_0_1 = blocks.float_to_short(1, 32767)
        self.blocks_float_to_short_0_0 = blocks.float_to_short(1, 32767)
        self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, -100000, 1, 0)
        self.analog_pwr_squelch_xx_0_2 = analog.pwr_squelch_cc(sqlch, 1, 1, True)
        self.analog_pwr_squelch_xx_0_0_1 = analog.pwr_squelch_cc(sqlch, 1, 1, True)
        self.analog_nbfm_rx_0_0 = analog.nbfm_rx(
        	audio_rate=48000,
        	quad_rate=48000,
        	tau=75e-6,
        	max_dev=5000,
          )
        self.analog_nbfm_rx_0 = analog.nbfm_rx(
        	audio_rate=48000,
        	quad_rate=48000,
        	tau=75e-6,
        	max_dev=5000,
          )

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_nbfm_rx_0, 0), (self.blocks_multiply_const_vxx_0_2, 0))
        self.connect((self.analog_nbfm_rx_0_0, 0), (self.blocks_multiply_const_vxx_0_0_1, 0))
        self.connect((self.analog_pwr_squelch_xx_0_0_1, 0), (self.low_pass_filter_0_0, 0))
        self.connect((self.analog_pwr_squelch_xx_0_2, 0), (self.low_pass_filter_0, 0))
        self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1))
        self.connect((self.blocks_float_to_short_0_0, 0), (self.blocks_udp_sink_0, 0))
        self.connect((self.blocks_float_to_short_0_1, 0), (self.blocks_udp_sink_1, 0))
        self.connect((self.blocks_multiply_const_vxx_0_0_1, 0), (self.blocks_float_to_short_0_1, 0))
        self.connect((self.blocks_multiply_const_vxx_0_2, 0), (self.blocks_float_to_short_0_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0), (self.freq_xlating_fir_filter_xxx_0_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.analog_pwr_squelch_xx_0_2, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0_0, 0), (self.analog_pwr_squelch_xx_0_0_1, 0))
        self.connect((self.low_pass_filter_0, 0), (self.analog_nbfm_rx_0, 0))
        self.connect((self.low_pass_filter_0_0, 0), (self.analog_nbfm_rx_0_0, 0))
        self.connect((self.osmosdr_source_0, 0), (self.blocks_multiply_xx_0, 0))
Example #28
0
    def __init__(self):
        gr.top_block.__init__(self, "Lms6 To Wav")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Lms6 To Wav")
        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", "lms6_to_wav")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 50e3
        self.decim = decim = 1
        self.baud = baud = 4800

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

        self.samps_per_symb = samps_per_symb = samp_rate / decim * 24 / 25 / baud
        self.offset = offset = .5e3
        self.fsk_deviation_hz = fsk_deviation_hz = 4000
        self.delay = delay = 0

        ##################################################
        # Blocks
        ##################################################
        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_layout.addWidget(self._offset_tool_bar)
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
            interpolation=24,
            decimation=25,
            taps=None,
            fractional_bw=None,
        )
        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(-80, 0)
        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(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, 0, 0, 3,
                                       3)
        self.low_pass_filter_0 = filter.fir_filter_ccf(
            decim,
            firdes.low_pass(1, samp_rate, 6e3, 2e3, 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._delay_range = Range(0, 1000, 1, 0, 200)
        self._delay_win = RangeWidget(self._delay_range, self.set_delay,
                                      "delay", "counter_slider", float)
        self.top_layout.addWidget(self._delay_win)
        self.blocks_wavfile_sink_0 = blocks.wavfile_sink(
            '/home/zleffke/captures/radiosonde/lms6_1.wav', 1, 48000, 8)
        self.blocks_file_source_0 = blocks.file_source(
            gr.sizeof_gr_complex * 1,
            '/home/zleffke/captures/radiosonde/BBNWS_LMS6_USRP_20171203_010607.352482_UTC_50k.fc32',
            False)
        self.blocks_file_source_0.set_begin_tag(pmt.PMT_NIL)
        self.analog_nbfm_rx_0 = analog.nbfm_rx(
            audio_rate=int(samp_rate / decim * 24 / 25),
            quad_rate=int(samp_rate / decim * 24 / 25),
            tau=75e-6,
            max_dev=5e3,
        )
        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.connect((self.analog_agc2_xx_0, 0),
                     (self.freq_xlating_fir_filter_xxx_0, 0))
        self.connect((self.analog_nbfm_rx_0, 0),
                     (self.blocks_wavfile_sink_0, 0))
        self.connect((self.blocks_file_source_0, 0),
                     (self.analog_agc2_xx_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0),
                     (self.low_pass_filter_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.rational_resampler_xxx_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.analog_nbfm_rx_0, 0))
    def __init__(self):
        gr.top_block.__init__(self, "NBFM_transceiver")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("NBFM_transceiver")
        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_transceiver")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 48000
        self.rx_freq = rx_freq = 141050000
        self.offset = offset = 5000000
        self.tx_gain = tx_gain = 15
        self.tx_freq = tx_freq = rx_freq - offset
        self.sqch = sqch = -60
        self.sdr_samp_rate = sdr_samp_rate = samp_rate * 12
        self.rx_tx = rx_tx = 0
        self.rx_gain = rx_gain = 10
        self.rx_freq_fine = rx_freq_fine = 0
        self.rx_aud = rx_aud = 0.300

        ##################################################
        # Blocks
        ##################################################
        self._tx_gain_range = Range(0, 90, 1, 15, 200)
        self._tx_gain_win = RangeWidget(self._tx_gain_range, self.set_tx_gain,
                                        'tx_gain', "counter_slider", float)
        self.top_grid_layout.addWidget(self._tx_gain_win, 2, 2, 1, 1)
        for r in range(2, 3):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(2, 3):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._sqch_range = Range(-110, -50, 1, -60, 200)
        self._sqch_win = RangeWidget(self._sqch_range, self.set_sqch,
                                     'rx_sqlch', "counter_slider", float)
        self.top_grid_layout.addWidget(self._sqch_win, 3, 0, 1, 1)
        for r in range(3, 4):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 1):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._sdr_samp_rate_range = Range(520833, 61440000, 100000,
                                          samp_rate * 12, 200)
        self._sdr_samp_rate_win = RangeWidget(self._sdr_samp_rate_range,
                                              self.set_sdr_samp_rate,
                                              'sdr_sample_rate',
                                              "counter_slider", float)
        self.top_grid_layout.addWidget(self._sdr_samp_rate_win, 0, 1, 1, 1)
        for r in range(0, 1):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(1, 2):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._rx_tx_options = (
            0,
            1,
        )
        self._rx_tx_labels = (
            'RX',
            'TX',
        )
        self._rx_tx_group_box = Qt.QGroupBox('rx_tx_pushbutton')
        self._rx_tx_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._rx_tx_button_group = variable_chooser_button_group()
        self._rx_tx_group_box.setLayout(self._rx_tx_box)
        for i, label in enumerate(self._rx_tx_labels):
            radio_button = Qt.QRadioButton(label)
            self._rx_tx_box.addWidget(radio_button)
            self._rx_tx_button_group.addButton(radio_button, i)
        self._rx_tx_callback = lambda i: Qt.QMetaObject.invokeMethod(
            self._rx_tx_button_group, "updateButtonChecked",
            Qt.Q_ARG("int", self._rx_tx_options.index(i)))
        self._rx_tx_callback(self.rx_tx)
        self._rx_tx_button_group.buttonClicked[int].connect(
            lambda i: self.set_rx_tx(self._rx_tx_options[i]))
        self.top_grid_layout.addWidget(self._rx_tx_group_box, 0, 0, 1, 1)
        for r in range(0, 1):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 1):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._rx_gain_range = Range(0, 50, 1, 10, 200)
        self._rx_gain_win = RangeWidget(self._rx_gain_range, self.set_rx_gain,
                                        'rx_gain', "counter_slider", float)
        self.top_grid_layout.addWidget(self._rx_gain_win, 2, 0, 1, 1)
        for r in range(2, 3):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 1):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._rx_freq_range = Range(88000000, 174000000, 25000, 141050000, 200)
        self._rx_freq_win = RangeWidget(self._rx_freq_range, self.set_rx_freq,
                                        'rx_freq', "counter_slider", float)
        self.top_grid_layout.addWidget(self._rx_freq_win, 1, 0, 1, 2)
        for r in range(1, 2):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 2):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._rx_aud_range = Range(0, 0.5, 0.05, 0.300, 200)
        self._rx_aud_win = RangeWidget(self._rx_aud_range, self.set_rx_aud,
                                       'rx_audio_gain', "counter_slider",
                                       float)
        self.top_grid_layout.addWidget(self._rx_aud_win, 2, 1, 1, 1)
        for r in range(2, 3):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(1, 2):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._offset_options = (
            5000000,
            600000,
        )
        self._offset_labels = (
            '5Mhz',
            '600kHz',
        )
        self._offset_tool_bar = Qt.QToolBar(self)
        self._offset_tool_bar.addWidget(Qt.QLabel('rx_tx_offset' + ": "))
        self._offset_combo_box = Qt.QComboBox()
        self._offset_tool_bar.addWidget(self._offset_combo_box)
        for label in self._offset_labels:
            self._offset_combo_box.addItem(label)
        self._offset_callback = lambda i: Qt.QMetaObject.invokeMethod(
            self._offset_combo_box, "setCurrentIndex",
            Qt.Q_ARG("int", self._offset_options.index(i)))
        self._offset_callback(self.offset)
        self._offset_combo_box.currentIndexChanged.connect(
            lambda i: self.set_offset(self._offset_options[i]))
        self.top_grid_layout.addWidget(self._offset_tool_bar, 0, 2, 1, 1)
        for r in range(0, 1):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(2, 3):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._tx_freq_tool_bar = Qt.QToolBar(self)

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

        self._tx_freq_tool_bar.addWidget(Qt.QLabel('tx_freq' + ": "))
        self._tx_freq_label = Qt.QLabel(
            str(self._tx_freq_formatter(self.tx_freq)))
        self._tx_freq_tool_bar.addWidget(self._tx_freq_label)
        self.top_grid_layout.addWidget(self._tx_freq_tool_bar, 1, 2, 1, 1)
        for r in range(1, 2):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(2, 3):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._rx_freq_fine_range = Range(-10000, 10000, 100, 0, 200)
        self._rx_freq_fine_win = RangeWidget(self._rx_freq_fine_range,
                                             self.set_rx_freq_fine,
                                             'rx_freq_fine', "counter_slider",
                                             float)
        self.top_grid_layout.addWidget(self._rx_freq_fine_win, 3, 1, 1, 1)
        for r in range(3, 4):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(1, 2):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.rational_resampler_xxx_0_1 = filter.rational_resampler_ccf(
            interpolation=samp_rate,
            decimation=sdr_samp_rate,
            taps=None,
            fractional_bw=None,
        )
        self.rational_resampler_xxx_0_0 = filter.rational_resampler_ccc(
            interpolation=samp_rate,
            decimation=sdr_samp_rate,
            taps=None,
            fractional_bw=None,
        )
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
            interpolation=sdr_samp_rate,
            decimation=samp_rate,
            taps=None,
            fractional_bw=None,
        )
        self.qtgui_sink_x_0 = qtgui.sink_c(
            256,  #fftsize
            firdes.WIN_HAMMING,  #wintype
            rx_freq,  #fc
            25000,  #bw
            "",  #name
            True,  #plotfreq
            True,  #plotwaterfall
            False,  #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, 4, 0, 6, 3)
        for r in range(4, 10):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 3):
            self.top_grid_layout.setColumnStretch(c, 1)

        self.qtgui_sink_x_0.enable_rf_freq(True)

        self.pluto_source_0 = iio.pluto_source('', rx_freq, sdr_samp_rate,
                                               15000, 0x4000, True, True, True,
                                               "manual",
                                               rx_gain * ((-rx_tx) + 1), '',
                                               True)
        self.pluto_sink_0 = iio.pluto_sink('192.168.2.1', rx_freq - offset,
                                           sdr_samp_rate, 5000, 0x4000, False,
                                           -tx_gain * (rx_tx), '', True)
        self.low_pass_filter_1 = filter.fir_filter_fff(
            1,
            firdes.low_pass(1, samp_rate, 20000, 500, firdes.WIN_HAMMING,
                            6.76))
        self.low_pass_filter_0_0 = filter.fir_filter_ccf(
            1,
            firdes.low_pass(1, samp_rate, 10e3, 2e3, firdes.WIN_HAMMING, 6.76))
        self.low_pass_filter_0 = filter.fir_filter_ccf(
            1,
            firdes.low_pass(1, samp_rate, 16000, 200, firdes.WIN_HAMMING,
                            6.76))
        self.blocks_multiply_xx_1 = blocks.multiply_vff(1)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff(
            (rx_aud * (-(rx_tx) + 1), ))
        self.audio_sink_0 = audio.sink(48000,
                                       "Speakers (Conexant SmartAudio HD)",
                                       True)
        self.analog_simple_squelch_cc_0 = analog.simple_squelch_cc(sqch, 1)
        self.analog_sig_source_x_0_0_0 = analog.sig_source_f(
            samp_rate, analog.GR_COS_WAVE, 0, 1, 0)
        self.analog_sig_source_x_0_0 = analog.sig_source_c(
            sdr_samp_rate, analog.GR_COS_WAVE, 0, 1, 0)
        self.analog_nbfm_tx_0 = analog.nbfm_tx(
            audio_rate=samp_rate,
            quad_rate=samp_rate,
            tau=75e-6,
            max_dev=5e3,
            fh=-1.0,
        )
        self.analog_nbfm_rx_0 = analog.nbfm_rx(
            audio_rate=48000,
            quad_rate=48000,
            tau=50e-6,
            max_dev=12.5e3,
        )
        self.Internal_Microphone = audio.source(48000, '', True)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.Internal_Microphone, 0),
                     (self.low_pass_filter_1, 0))
        self.connect((self.analog_nbfm_rx_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.analog_nbfm_tx_0, 0), (self.low_pass_filter_0, 0))
        self.connect((self.analog_sig_source_x_0_0, 0),
                     (self.blocks_multiply_xx_0, 1))
        self.connect((self.analog_sig_source_x_0_0_0, 0),
                     (self.blocks_multiply_xx_1, 1))
        self.connect((self.analog_simple_squelch_cc_0, 0),
                     (self.analog_nbfm_rx_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.rational_resampler_xxx_0_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0),
                     (self.rational_resampler_xxx_0_1, 0))
        self.connect((self.blocks_multiply_xx_1, 0),
                     (self.analog_nbfm_tx_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),
                     (self.analog_simple_squelch_cc_0, 0))
        self.connect((self.low_pass_filter_1, 0),
                     (self.blocks_multiply_xx_1, 0))
        self.connect((self.pluto_source_0, 0), (self.blocks_multiply_xx_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.pluto_sink_0, 0))
        self.connect((self.rational_resampler_xxx_0_0, 0),
                     (self.low_pass_filter_0_0, 0))
        self.connect((self.rational_resampler_xxx_0_1, 0),
                     (self.qtgui_sink_x_0, 0))
Example #30
0
    def __init__(self):
        gr.top_block.__init__(self, "FCD FM Receiver")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("FCD FM Receiver")
        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", "fcd_nfm_rx")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 96000
        self.offset_fine = offset_fine = 0
        self.offset_coarse = offset_coarse = 0
        self.freq = freq = 144.47e6
        self.xlate_filter_taps = xlate_filter_taps = firdes.low_pass(
            1, samp_rate, 48000, 5000, firdes.WIN_HAMMING, 6.76)
        self.width = width = 10000
        self.trans = trans = 1500
        self.sql_lev = sql_lev = -100
        self.rx_freq = rx_freq = freq + (offset_coarse + offset_fine)
        self.rf_gain = rf_gain = 20
        self.display_selector = display_selector = 0
        self.af_gain = af_gain = 1

        ##################################################
        # Blocks
        ##################################################
        self._width_range = Range(2000, 40000, 100, 10000, 200)
        self._width_win = RangeWidget(self._width_range, self.set_width,
                                      "Filter", "counter", float)
        self.top_grid_layout.addWidget(self._width_win, 7, 0, 1, 1)
        self._trans_range = Range(500, 5000, 1, 1500, 200)
        self._trans_win = RangeWidget(self._trans_range, self.set_trans,
                                      "Trans", "counter", float)
        self.top_grid_layout.addWidget(self._trans_win, 8, 0, 1, 1)
        self._sql_lev_range = Range(-100, 0, 1, -100, 200)
        self._sql_lev_win = RangeWidget(self._sql_lev_range, self.set_sql_lev,
                                        "SQL", "counter", float)
        self.top_grid_layout.addWidget(self._sql_lev_win, 7, 2, 1, 1)
        self._rx_freq_tool_bar = Qt.QToolBar(self)

        if None:
            self._rx_freq_formatter = None
        else:
            self._rx_freq_formatter = lambda x: x

        self._rx_freq_tool_bar.addWidget(Qt.QLabel("Receive" + ": "))
        self._rx_freq_label = Qt.QLabel(
            str(self._rx_freq_formatter(self.rx_freq)))
        self._rx_freq_tool_bar.addWidget(self._rx_freq_label)
        self.top_grid_layout.addWidget(self._rx_freq_tool_bar, 4, 3, 1, 1)

        self._offset_fine_range = Range(-1000, 1000, 1, 0, 200)
        self._offset_fine_win = RangeWidget(self._offset_fine_range,
                                            self.set_offset_fine, "Fine Tune",
                                            "counter", float)
        self.top_grid_layout.addWidget(self._offset_fine_win, 6, 0, 1, 2)
        self._offset_coarse_range = Range(-48000, 48000, 100, 0, 200)
        self._offset_coarse_win = RangeWidget(self._offset_coarse_range,
                                              self.set_offset_coarse,
                                              "Coarse Tune", "counter", float)
        self.top_grid_layout.addWidget(self._offset_coarse_win, 6, 2, 1, 2)
        self._display_selector_options = [0, 1]
        self._display_selector_labels = ['Baseband', 'RF']
        self._display_selector_tool_bar = Qt.QToolBar(self)
        self._display_selector_tool_bar.addWidget(Qt.QLabel("Spectrum" + ": "))
        self._display_selector_combo_box = Qt.QComboBox()
        self._display_selector_tool_bar.addWidget(
            self._display_selector_combo_box)
        for label in self._display_selector_labels:
            self._display_selector_combo_box.addItem(label)
        self._display_selector_callback = lambda i: Qt.QMetaObject.invokeMethod(
            self._display_selector_combo_box, "setCurrentIndex",
            Qt.Q_ARG("int", self._display_selector_options.index(i)))
        self._display_selector_callback(self.display_selector)
        self._display_selector_combo_box.currentIndexChanged.connect(
            lambda i: self.set_display_selector(self._display_selector_options[
                i]))
        self.top_grid_layout.addWidget(self._display_selector_tool_bar, 5, 0,
                                       1, 1)
        self._af_gain_range = Range(0, 5, 0.1, 1, 200)
        self._af_gain_win = RangeWidget(self._af_gain_range, self.set_af_gain,
                                        "VOL", "counter", float)
        self.top_grid_layout.addWidget(self._af_gain_win, 8, 1, 1, 1)
        self.rtlsdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " +
                                              "")
        self.rtlsdr_source_0.set_time_now(osmosdr.time_spec_t(time.time()),
                                          osmosdr.ALL_MBOARDS)
        self.rtlsdr_source_0.set_sample_rate(samp_rate)
        self.rtlsdr_source_0.set_center_freq(107.9e6, 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(10, 0)
        self.rtlsdr_source_0.set_if_gain(20, 0)
        self.rtlsdr_source_0.set_bb_gain(20, 0)
        self.rtlsdr_source_0.set_antenna("", 0)
        self.rtlsdr_source_0.set_bandwidth(3000, 0)

        self._rf_gain_range = Range(-5, 30, 1, 20, 200)
        self._rf_gain_win = RangeWidget(self._rf_gain_range, self.set_rf_gain,
                                        "RF", "counter", float)
        self.top_grid_layout.addWidget(self._rf_gain_win, 7, 1, 1, 1)
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c(
            512,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            rx_freq * display_selector,  #fc
            samp_rate,  #bw
            "",  #name
            1  #number of inputs
        )
        self.qtgui_freq_sink_x_0.set_update_time(0.05)
        self.qtgui_freq_sink_x_0.set_y_axis(-140, 10)
        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_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, 0, 0, 5,
                                       4)
        self.low_pass_filter = filter.fir_filter_ccf(
            1,
            firdes.low_pass(1, samp_rate, width / 2, trans, firdes.WIN_HAMMING,
                            6.76))
        self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(
            1, (xlate_filter_taps), -(offset_coarse + offset_fine), samp_rate)
        self._freq_tool_bar = Qt.QToolBar(self)
        self._freq_tool_bar.addWidget(Qt.QLabel("FCD 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, 5, 1, 1, 1)
        self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vff(
            (af_gain, ))
        self.audio_sink = audio.sink(48000, "", True)
        self.analog_simple_squelch_cc_0 = analog.simple_squelch_cc(sql_lev, 1)
        self.analog_nbfm_rx_0 = analog.nbfm_rx(
            audio_rate=48000,
            quad_rate=96000,
            tau=75e-6,
            max_dev=5e3,
        )

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_nbfm_rx_0, 0),
                     (self.blocks_multiply_const_vxx_1, 0))
        self.connect((self.analog_simple_squelch_cc_0, 0),
                     (self.analog_nbfm_rx_0, 0))
        self.connect((self.blocks_multiply_const_vxx_1, 0),
                     (self.audio_sink, 0))
        self.connect((self.blocks_multiply_const_vxx_1, 0),
                     (self.audio_sink, 1))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0),
                     (self.low_pass_filter, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0),
                     (self.qtgui_freq_sink_x_0, 0))
        self.connect((self.low_pass_filter, 0),
                     (self.analog_simple_squelch_cc_0, 0))
        self.connect((self.rtlsdr_source_0, 0),
                     (self.freq_xlating_fir_filter_xxx_0, 0))
Example #31
0
    def __init__(self):
        gr.top_block.__init__(self, "FM radio FFT example")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("FM radio FFT example")
        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", "Exp1")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.variable_sample_rate_0 = variable_sample_rate_0 = 1e6
        self.samp_rate = samp_rate = 44100
        self.xlatecenter_4 = xlatecenter_4 = 0
        self.xlatecenter_3 = xlatecenter_3 = 0
        self.xlatecenter_2 = xlatecenter_2 = 0
        self.xlatecenter = xlatecenter = 0
        self.xlate_filter2 = xlate_filter2 = firdes.low_pass(1, samp_rate, 4000, 1000, firdes.WIN_HAMMING, 6.76)
        self.xlate_filter = xlate_filter = firdes.low_pass(1, variable_sample_rate_0, 125000, 25000, firdes.WIN_HAMMING, 6.76)
        self.variable_1 = variable_1 = 0
        self.transition = transition = 1e6
        self.rri = rri = 441
        self.rrd = rrd = 500
        self.quadrature = quadrature = 500000
        self.pscf4 = pscf4 = 0
        self.pscf3 = pscf3 = 0
        self.pscf2 = pscf2 = 0
        self.pscf1 = pscf1 = 0
        self.cutoff = cutoff = 1e5
        self.bptrans = bptrans = 100
        self.bpsr = bpsr = 200000
        self.bplow_4 = bplow_4 = 100
        self.bplow_3 = bplow_3 = 100
        self.bplow_2 = bplow_2 = 100
        self.bplow_1 = bplow_1 = 100
        self.bphi_4 = bphi_4 = 2.8e3
        self.bphi_3 = bphi_3 = 2.8e3
        self.bphi_2 = bphi_2 = 2.8e3
        self.bphi_1 = bphi_1 = 2.8e3
        self.audio_interp = audio_interp = 4
        self.amp_4 = amp_4 = 0
        self.amp_3 = amp_3 = 0
        self.amp_2 = amp_2 = 0
        self.amp_1 = amp_1 = 1
        self.RF_Gain = RF_Gain = 35
        self.CF = CF = 88.5e6

        ##################################################
        # Blocks
        ##################################################
        self._pscf1_range = Range(-10000, 10000, 50, 0, 200)
        self._pscf1_win = RangeWidget(self._pscf1_range, self.set_pscf1, "pscf1", "counter_slider", float)
        self.top_layout.addWidget(self._pscf1_win)
        self._amp_1_range = Range(0, 1, 0.01, 1, 200)
        self._amp_1_win = RangeWidget(self._amp_1_range, self.set_amp_1, "Amp", "counter_slider", float)
        self.top_layout.addWidget(self._amp_1_win)
        self.rational_resampler_xxx_1_0_0 = filter.rational_resampler_ccc(
                interpolation=rri,
                decimation=rrd,
                taps=None,
                fractional_bw=None,
        )
        self.rational_resampler_xxx_1_0 = filter.rational_resampler_fff(
                interpolation=rri,
                decimation=rrd,
                taps=None,
                fractional_bw=None,
        )
        self.freq_xlating_fir_filter_xxx_1_0 = filter.freq_xlating_fir_filter_fcc(1, (1, ), pscf1, samp_rate)
        self.freq_xlating_fir_filter_xxx_1 = filter.freq_xlating_fir_filter_ccc(1, (1, ), pscf1, samp_rate)
        self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(5, (xlate_filter), xlatecenter, variable_sample_rate_0)
        self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vff((amp_1, ))
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((amp_1, ))
        self.blocks_complex_to_float_1 = blocks.complex_to_float(1)
        self.blocks_complex_to_float_0 = blocks.complex_to_float(1)
        self.band_pass_filter_0_0_0_0 = filter.fir_filter_ccf(4, firdes.band_pass(
        	1, bpsr, bplow_1, bphi_1, bptrans, firdes.WIN_HAMMING, 6.76))
        self.audio_sink_1 = audio.sink(48000, "Radio:NFM1", True)
        self.analog_nbfm_rx_0_0 = analog.nbfm_rx(
        	audio_rate=50000,
        	quad_rate=int(variable_sample_rate_0/5),
        	tau=75e-6,
        	max_dev=12500,
        )
        self.RTL820T = osmosdr.source( args="numchan=" + str(1) + " " + "" )
        self.RTL820T.set_sample_rate(variable_sample_rate_0)
        self.RTL820T.set_center_freq(CF, 0)
        self.RTL820T.set_freq_corr(0, 0)
        self.RTL820T.set_dc_offset_mode(2, 0)
        self.RTL820T.set_iq_balance_mode(0, 0)
        self.RTL820T.set_gain_mode(False, 0)
        self.RTL820T.set_gain(RF_Gain, 0)
        self.RTL820T.set_if_gain(20, 0)
        self.RTL820T.set_bb_gain(20, 0)
        self.RTL820T.set_antenna("", 0)
        self.RTL820T.set_bandwidth(1e6, 0)
          

        ##################################################
        # Connections
        ##################################################
        self.connect((self.RTL820T, 0), (self.freq_xlating_fir_filter_xxx_0, 0))    
        self.connect((self.analog_nbfm_rx_0_0, 0), (self.rational_resampler_xxx_1_0, 0))    
        self.connect((self.band_pass_filter_0_0_0_0, 0), (self.rational_resampler_xxx_1_0_0, 0))    
        self.connect((self.blocks_complex_to_float_0, 0), (self.blocks_multiply_const_vxx_0, 0))    
        self.connect((self.blocks_complex_to_float_1, 0), (self.blocks_multiply_const_vxx_0_0, 0))    
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.audio_sink_1, 0))    
        self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.audio_sink_1, 1))    
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.analog_nbfm_rx_0_0, 0))    
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.band_pass_filter_0_0_0_0, 0))    
        self.connect((self.freq_xlating_fir_filter_xxx_1, 0), (self.blocks_complex_to_float_1, 0))    
        self.connect((self.freq_xlating_fir_filter_xxx_1_0, 0), (self.blocks_complex_to_float_0, 0))    
        self.connect((self.rational_resampler_xxx_1_0, 0), (self.freq_xlating_fir_filter_xxx_1_0, 0))    
        self.connect((self.rational_resampler_xxx_1_0_0, 0), (self.freq_xlating_fir_filter_xxx_1, 0))    
Example #32
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))
Example #33
0
  def build_blocks(self,config):
    if not self.device_found:
      return
      
    self.error = False

    fft_size = self.main.fft_size_control.get_value()
    
    frame_rate = self.main.framerate_control.get_value()
    average = self.main.average_control.get_value()
    ssb_lo = self.ssb_lo
    ssb_hi = self.ssb_hi
    
    USB = self.mode == self.main.MODE_USB or self.mode == self.main.MODE_CW_USB
      
    self.audio_dec_nrw = 1
    
    self.dec_nrw, self.interp_nrw = self.compute_dec_interp(self.sample_rate,self.audio_rate)
    
    self.audio_dec_wid = self.if_sample_rate / self.audio_rate
    
    self.dec_wid, self.interp_wid = self.compute_dec_interp(self.sample_rate,self.if_sample_rate)
          
    volume = .1
    
    self.configure_source_controls()
    
    self.create_update_freq_xlating_fir_filter()
    
    self.analog_agc_cc = analog.agc2_cc(1e-1, 1e-2, 1.0, 1.0)
    self.analog_agc_cc.set_max_gain(1)
    
    self.analog_agc_ff = analog.agc2_ff(1e-1, 1e-2, 1.0, 1.0)
    self.analog_agc_ff.set_max_gain(1)
        
    self.rational_resampler_wid = filter.rational_resampler_ccc(
      decimation=int(self.dec_wid),
      interpolation=int(self.interp_wid),
      taps=None,
      fractional_bw=None,
        )
        
    self.rational_resampler_nrw = filter.rational_resampler_ccc(
      decimation=int(self.dec_nrw),
      interpolation=int(self.interp_nrw),
      taps=None,
      fractional_bw=None,
        )
        
    self.analog_pwr_squelch = analog.pwr_squelch_cc(self.squelch_level, 1e-4, 0, True)
    
    self.analog_pwr_squelch_ssb = analog.pwr_squelch_ff(self.squelch_level, 1e-4, 0, True)
        
    self.blocks_multiply = blocks.multiply_vcc(1)
    self.blocks_complex_to_real = blocks.complex_to_real(1)
    
    #self.rebuild_filters(config)
     
    self.blocks_complex_to_mag_am = blocks.complex_to_mag(1)
      
    self.analog_nbfm_rcv = analog.nbfm_rx(
        audio_rate=self.audio_rate,
        quad_rate=self.audio_rate,
        tau=75e-6,
        max_dev=6e3,
        )
      
    self.analog_wfm_rcv = analog.wfm_rcv(
        quad_rate=self.if_sample_rate,
        audio_decimation=self.audio_dec_wid,
      )
      
    self.hilbert_fc_2 = filter.hilbert_fc(self.hilbert_taps_ssb, firdes.WIN_HAMMING, 6.76)
    self.hilbert_fc_1 = filter.hilbert_fc(self.hilbert_taps_ssb, firdes.WIN_HAMMING, 6.76)
    
    self.blocks_multiply_ssb = blocks.multiply_vcc(1)
    
    self.blocks_complex_to_float_ssb = blocks.complex_to_float(1)
    
    self.create_usb_lsb_switch()
    
    self.blocks_add = blocks.add_vff(1)
    
    self.blocks_complex_to_real = blocks.complex_to_real(1)
    self.blocks_complex_to_imag = blocks.complex_to_imag(1)
         
    # this is the source for the FFT display's data  
    self.logpwrfft = logpwrfft.logpwrfft_c(
      sample_rate=self.sample_rate,
      fft_size=fft_size,
      ref_scale=2,
      frame_rate=frame_rate,
      avg_alpha=average,
      average=(average != 1),
        )

    # this is the main FFT display
    self.fft_vector_sink = MyVectorSink(self.main,fft_size)
    
    self.blocks_multiply_const_volume = blocks.multiply_const_vff((volume, ))
        
    # only create this once
    if self.audio_sink == None:
      try:
        self.audio_sink = audio.sink(self.audio_rate, config['audio_device'], True)
      except Exception as e:
        self.main.message_dialog("Audio Error","A problem has come up while accessing the audio system: %s" % e)
        self.error = True
        self.audio_sink = None

    self.main.af_gain_control.set_value()
    def __init__(self):
        gr.top_block.__init__(self, "Outernet Flatsat Flowgraph")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Outernet Flatsat Flowgraph")
        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.afsk_space = afsk_space = 2200
        self.afsk_mark = afsk_mark = 1200
        self.bitrate = bitrate = 1200
        self.afsk_deviation = afsk_deviation = (afsk_space - afsk_mark)/2
        self.uhd_samp_rate = uhd_samp_rate = 614400
        self.tx_gain = tx_gain = 0
        self.rx_gain = rx_gain = 0
        self.rf_tx_freq = rf_tx_freq = 145e6
        self.rf_rx_freq = rf_rx_freq = 401e6
        self.rf_offset_freq = rf_offset_freq = 80e3
        self.rf_bw = rf_bw = 100e3
        self.interpolation = interpolation = 16
        self.afsk_sensitivity = afsk_sensitivity = 2.0*afsk_deviation/bitrate
        self.afsk_centre_freq = afsk_centre_freq = afsk_mark + afsk_deviation

        ##################################################
        # Blocks
        ##################################################
        self._tx_gain_range = Range(0, 90, 1, 0, 200)
        self._tx_gain_win = RangeWidget(self._tx_gain_range, self.set_tx_gain, "TX Gain", "counter_slider", float)
        self.top_layout.addWidget(self._tx_gain_win)
        self._rx_gain_range = Range(0, 90, 1, 0, 200)
        self._rx_gain_win = RangeWidget(self._rx_gain_range, self.set_rx_gain, "RX Gain", "counter_slider", float)
        self.top_layout.addWidget(self._rx_gain_win)
        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_rate(30.72e6, uhd.ALL_MBOARDS)
        self.uhd_usrp_source_0.set_samp_rate(uhd_samp_rate)
        self.uhd_usrp_source_0.set_center_freq(rf_rx_freq, 0)
        self.uhd_usrp_source_0.set_gain(rx_gain, 0)
        self.uhd_usrp_source_0.set_bandwidth(rf_bw, 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_clock_rate(30.72e6, uhd.ALL_MBOARDS)
        self.uhd_usrp_sink_0.set_samp_rate(uhd_samp_rate)
        self.uhd_usrp_sink_0.set_center_freq(rf_tx_freq, 0)
        self.uhd_usrp_sink_0.set_gain(tx_gain, 0)
        self.uhd_usrp_sink_0.set_bandwidth(rf_bw, 0)
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
                interpolation=4,
                decimation=1,
                taps=None,
                fractional_bw=0.25,
        )
        self.qtgui_sink_x_0_0 = qtgui.sink_c(
        	1024, #fftsize
        	firdes.WIN_BLACKMAN_hARRIS, #wintype
        	0, #fc
        	uhd_samp_rate, #bw
        	"", #name
        	True, #plotfreq
        	True, #plotwaterfall
        	True, #plottime
        	True, #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.low_pass_filter_0 = filter.fir_filter_ccf(1, firdes.low_pass(
        	1, bitrate*interpolation, 1.2*afsk_deviation, 50, firdes.WIN_HAMMING, 6.76))
        self.ec_ax25_decoder_b_0 = ec.ax25_decoder_b(True, 0, "")
        self.bruninga_fsk_demod_0 = bruninga.fsk_demod(19200)
        self.blocks_tagged_stream_multiply_length_0 = blocks.tagged_stream_multiply_length(gr.sizeof_gr_complex*1, "packet_len", 4096)
        self.blocks_socket_pdu_1_0 = blocks.socket_pdu("TCP_CLIENT", "127.0.0.1", "51423", 10000, False)
        self.blocks_socket_pdu_1 = blocks.socket_pdu("TCP_CLIENT", "127.0.0.1", "51423", 10000, False)
        self.blocks_packed_to_unpacked_xx_0 = blocks.packed_to_unpacked_bb(1, gr.GR_MSB_FIRST)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_complex_to_real_0 = blocks.complex_to_real(1)
        self.ax25_nrzi_encoder_0 = ax25.nrzi_encoder(0)
        self.ax25_encode_heir_0 = ax25_encode_heir(
            destination_callsign="SPACE",
            destination_ssid=0,
            post_flag_quantity=16,
            post_sync_quantity=16,
            pre_flag_quantity=16,
            pre_sync_quantity=128,
            source_callsign="EARTH",
            source_ssid=0,
            sync_value=85,
        )
        self.analog_sig_source_x_0 = analog.sig_source_c(bitrate*interpolation, analog.GR_COS_WAVE, afsk_centre_freq, 1, 0)
        self.analog_nbfm_tx_0 = analog.nbfm_tx(
        	audio_rate=bitrate*interpolation,
        	quad_rate=uhd_samp_rate/4,
        	tau=75e-6*0,
        	max_dev=2.5e3,
        	fh=-1.0,
                )
        self.analog_nbfm_rx_0 = analog.nbfm_rx(
        	audio_rate=19200,
        	quad_rate=4*153600,
        	tau=0.01,
        	max_dev=2.5e3,
          )
        self.analog_cpfsk_bc_0 = analog.cpfsk_bc(afsk_sensitivity, 1, interpolation)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_socket_pdu_1_0, 'pdus'), (self.ax25_encode_heir_0, 'pdus in'))    
        self.msg_connect((self.ec_ax25_decoder_b_0, 'pdus'), (self.blocks_socket_pdu_1, 'pdus'))    
        self.connect((self.analog_cpfsk_bc_0, 0), (self.low_pass_filter_0, 0))    
        self.connect((self.analog_nbfm_rx_0, 0), (self.bruninga_fsk_demod_0, 0))    
        self.connect((self.analog_nbfm_tx_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.ax25_encode_heir_0, 0), (self.blocks_packed_to_unpacked_xx_0, 0))    
        self.connect((self.ax25_nrzi_encoder_0, 0), (self.analog_cpfsk_bc_0, 0))    
        self.connect((self.blocks_complex_to_real_0, 0), (self.analog_nbfm_tx_0, 0))    
        self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_complex_to_real_0, 0))    
        self.connect((self.blocks_packed_to_unpacked_xx_0, 0), (self.ax25_nrzi_encoder_0, 0))    
        self.connect((self.blocks_tagged_stream_multiply_length_0, 0), (self.qtgui_sink_x_0_0, 0))    
        self.connect((self.blocks_tagged_stream_multiply_length_0, 0), (self.uhd_usrp_sink_0, 0))    
        self.connect((self.bruninga_fsk_demod_0, 0), (self.ec_ax25_decoder_b_0, 0))    
        self.connect((self.low_pass_filter_0, 0), (self.blocks_multiply_xx_0, 0))    
        self.connect((self.rational_resampler_xxx_0, 0), (self.blocks_tagged_stream_multiply_length_0, 0))    
        self.connect((self.uhd_usrp_source_0, 0), (self.analog_nbfm_rx_0, 0))    
    def __init__(self):
        gr.top_block.__init__(self, "PFB Channelizer Demo")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("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", "pfb_channelizer_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_width = noaa_band_width = noaa_chan_width * noaa_num_chans
        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, 2500, firdes.WIN_HAMMING, 6.76)
          
        
        self.lpf_taps = lpf_taps = firdes.low_pass(1.0, hardware_rate, noaa_band_width / 2, noaa_chan_width, firdes.WIN_HAMMING, 6.76)
          
        self.channel_map = channel_map = range(0, noaa_num_chans+1)
        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_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.channel_names = channel_names = map(lambda x: "%.3fMHz" % (162.4 + (x*0.025)), channel_map)
        self.chan_num = chan_num = channel_map[0]

        ##################################################
        # Blocks
        ##################################################
        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,2)
        self.qtgui_waterfall_sink_x_0_0_0 = qtgui.waterfall_sink_c(
        	fftwidth, #size
        	firdes.WIN_BLACKMAN_hARRIS, #wintype
        	target_freq, #fc
        	oversampled_width, #bw
        	"Band Monitor", #name
                1 #number of inputs
        )
        self.qtgui_waterfall_sink_x_0_0_0.set_update_time(fft_interval)
        self.qtgui_waterfall_sink_x_0_0_0.enable_grid(True)
        
        if not True:
          self.qtgui_waterfall_sink_x_0_0_0.disable_legend()
        
        if "complex" == "float" or "complex" == "msg_float":
          self.qtgui_waterfall_sink_x_0_0_0.set_plot_pos_half(not True)
        
        labels = ["", "", "", "", "",
                  "", "", "", "", ""]
        colors = [5, 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_0_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_waterfall_sink_x_0_0_0.set_line_label(i, labels[i])
            self.qtgui_waterfall_sink_x_0_0_0.set_color_map(i, colors[i])
            self.qtgui_waterfall_sink_x_0_0_0.set_line_alpha(i, alphas[i])
        
        self.qtgui_waterfall_sink_x_0_0_0.set_intensity_range(-80, -35)
        
        self._qtgui_waterfall_sink_x_0_0_0_win = sip.wrapinstance(self.qtgui_waterfall_sink_x_0_0_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_waterfall_sink_x_0_0_0_win, 1,0,1,2)
        self.qtgui_waterfall_sink_x_0_0 = qtgui.waterfall_sink_c(
        	fftwidth, #size
        	firdes.WIN_BLACKMAN_hARRIS, #wintype
        	0, #fc
        	noaa_chan_width, #bw
        	"Channel Monitor", #name
                1 #number of inputs
        )
        self.qtgui_waterfall_sink_x_0_0.set_update_time(fft_interval)
        self.qtgui_waterfall_sink_x_0_0.enable_grid(True)
        
        if not True:
          self.qtgui_waterfall_sink_x_0_0.disable_legend()
        
        if "complex" == "float" or "complex" == "msg_float":
          self.qtgui_waterfall_sink_x_0_0.set_plot_pos_half(not True)
        
        labels = ["", "", "", "", "",
                  "", "", "", "", ""]
        colors = [5, 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_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_waterfall_sink_x_0_0.set_line_label(i, labels[i])
            self.qtgui_waterfall_sink_x_0_0.set_color_map(i, colors[i])
            self.qtgui_waterfall_sink_x_0_0.set_line_alpha(i, alphas[i])
        
        self.qtgui_waterfall_sink_x_0_0.set_intensity_range(-67, -37)
        
        self._qtgui_waterfall_sink_x_0_0_win = sip.wrapinstance(self.qtgui_waterfall_sink_x_0_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_waterfall_sink_x_0_0_win, 1,2,1,2)
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c(
        	fftwidth, #size
        	firdes.WIN_BLACKMAN_hARRIS, #wintype
        	0, #fc
        	noaa_chan_width, #bw
        	"Channelizer Output", #name
        	noaa_num_chans +1 #number of inputs
        )
        self.qtgui_freq_sink_x_0.set_update_time(fft_interval)
        self.qtgui_freq_sink_x_0.set_y_axis(-80, -35)
        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(0.1)
        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 = [channel_names[0], channel_names[1], channel_names[2], channel_names[3], channel_names[4],
                  channel_names[5], channel_names[6], channel_names[7], "", ""]
        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(noaa_num_chans +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, 2,0,1,4)
        self._ppm_range = Range(-20, 20, 0.5, 0, 100)
        self._ppm_win = RangeWidget(self._ppm_range, self.set_ppm, "ppm", "counter_slider", float)
        self.top_grid_layout.addWidget(self._ppm_win, 0,2,1,2)
        self.pfb_channelizer_ccf_0 = pfb.channelizer_ccf(
        	  noaa_num_chans+1,
        	  (pfb_taps),
        	  1,
        	  100)
        self.pfb_channelizer_ccf_0.set_channel_map((channel_map))
        self.pfb_channelizer_ccf_0.declare_sample_delay(0)
        	
        self.osmosdr_source_0_0 = osmosdr.source( args="numchan=" + str(1) + " " + "type=usrp2" )
        self.osmosdr_source_0_0.set_sample_rate(hardware_rate)
        self.osmosdr_source_0_0.set_center_freq(tuner_freq, 0)
        self.osmosdr_source_0_0.set_freq_corr(0, 0)
        self.osmosdr_source_0_0.set_dc_offset_mode(2, 0)
        self.osmosdr_source_0_0.set_iq_balance_mode(2, 0)
        self.osmosdr_source_0_0.set_gain_mode(True, 0)
        self.osmosdr_source_0_0.set_gain(10, 0)
        self.osmosdr_source_0_0.set_if_gain(20, 0)
        self.osmosdr_source_0_0.set_bb_gain(20, 0)
        self.osmosdr_source_0_0.set_antenna("TX/RX", 0)
        self.osmosdr_source_0_0.set_bandwidth(0, 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_5_0 = blocks.multiply_const_vcc((1, ))
        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(24000, "", 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,
          )
        (self.analog_nbfm_rx_0).set_max_output_buffer(512)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_nbfm_rx_0, 0), (self.audio_sink_0, 0))    
        self.connect((self.blocks_add_xx_0, 0), (self.analog_nbfm_rx_0, 0))    
        self.connect((self.blocks_add_xx_0, 0), (self.qtgui_waterfall_sink_x_0_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.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_waterfall_sink_x_0_0_0, 0))    
        self.connect((self.osmosdr_source_0_0, 0), (self.freq_xlating_fft_filter_ccc_0, 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))    
        self.connect((self.pfb_channelizer_ccf_0, 0), (self.qtgui_freq_sink_x_0, 0))    
        self.connect((self.pfb_channelizer_ccf_0, 1), (self.qtgui_freq_sink_x_0, 1))    
        self.connect((self.pfb_channelizer_ccf_0, 2), (self.qtgui_freq_sink_x_0, 2))    
        self.connect((self.pfb_channelizer_ccf_0, 3), (self.qtgui_freq_sink_x_0, 3))    
        self.connect((self.pfb_channelizer_ccf_0, 4), (self.qtgui_freq_sink_x_0, 4))    
        self.connect((self.pfb_channelizer_ccf_0, 5), (self.qtgui_freq_sink_x_0, 5))    
        self.connect((self.pfb_channelizer_ccf_0, 6), (self.qtgui_freq_sink_x_0, 6))    
        self.connect((self.pfb_channelizer_ccf_0, 7), (self.qtgui_freq_sink_x_0, 7))    
    def __init__(self):
        gr.top_block.__init__(self, "NOAA Weather Radio")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("NOAA Weather Radio")
        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_weather")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.valid_gains = valid_gains = [0.0, 0.9, 1.4, 2.7, 3.7, 7.7, 8.7, 12.5, 14.4, 15.7, 16.6, 19.7, 20.7, 22.9, 25.4, 28.0, 29.7, 32.8, 33.8, 36.4, 37.2, 38.6, 40.2, 42.1, 43.4, 43.9, 44.5, 48.0, 49.6]
        self.noaa_stations = noaa_stations = [(162.400e6,'WX2') , (162.425e6, 'WX4'), (162.450e6, 'WX5'), (162.475e6,'WX3'), (162.500e6, 'WX6'), (162.525e6, 'WX7'), (162.550e6, 'WX1')]
        self.samp_rate = samp_rate = 250e3
        self.range_ppm_corr = range_ppm_corr = 9
        self.noaa_stations_labels = noaa_stations_labels = ['{:>7.3f} MHz (Channel {:3})'.format(f[0]/1e6, f[1]) for f in noaa_stations]
        self.chooser_gain = chooser_gain = valid_gains[-1]
        self.chooser_frequency = chooser_frequency = noaa_stations[0][0]

        ##################################################
        # Blocks
        ##################################################
        self.notebook_top = Qt.QTabWidget()
        self.notebook_top_widget_0 = Qt.QWidget()
        self.notebook_top_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.notebook_top_widget_0)
        self.notebook_top_grid_layout_0 = Qt.QGridLayout()
        self.notebook_top_layout_0.addLayout(self.notebook_top_grid_layout_0)
        self.notebook_top.addTab(self.notebook_top_widget_0, "RF")
        self.notebook_top_widget_1 = Qt.QWidget()
        self.notebook_top_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.notebook_top_widget_1)
        self.notebook_top_grid_layout_1 = Qt.QGridLayout()
        self.notebook_top_layout_1.addLayout(self.notebook_top_grid_layout_1)
        self.notebook_top.addTab(self.notebook_top_widget_1, "Audio")
        self.top_grid_layout.addWidget(self.notebook_top, 2, 0, 1, 2)
        self._range_ppm_corr_range = Range(-50, 50, 1, 9, 200)
        self._range_ppm_corr_win = RangeWidget(self._range_ppm_corr_range, self.set_range_ppm_corr, "PPM Correction", "counter_slider", int)
        self.notebook_top_grid_layout_0.addWidget(self._range_ppm_corr_win, 0, 1, 1, 1)
        self.notebook_rf = Qt.QTabWidget()
        self.notebook_rf_widget_0 = Qt.QWidget()
        self.notebook_rf_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.notebook_rf_widget_0)
        self.notebook_rf_grid_layout_0 = Qt.QGridLayout()
        self.notebook_rf_layout_0.addLayout(self.notebook_rf_grid_layout_0)
        self.notebook_rf.addTab(self.notebook_rf_widget_0, "Spectrum")
        self.notebook_rf_widget_1 = Qt.QWidget()
        self.notebook_rf_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.notebook_rf_widget_1)
        self.notebook_rf_grid_layout_1 = Qt.QGridLayout()
        self.notebook_rf_layout_1.addLayout(self.notebook_rf_grid_layout_1)
        self.notebook_rf.addTab(self.notebook_rf_widget_1, "Waterfall")
        self.notebook_top_layout_0.addWidget(self.notebook_rf)
        self._chooser_gain_options = valid_gains
        self._chooser_gain_labels = ['{}'.format(g) for g in valid_gains]
        self._chooser_gain_tool_bar = Qt.QToolBar(self)
        self._chooser_gain_tool_bar.addWidget(Qt.QLabel("RF Gain"+": "))
        self._chooser_gain_combo_box = Qt.QComboBox()
        self._chooser_gain_tool_bar.addWidget(self._chooser_gain_combo_box)
        for label in self._chooser_gain_labels: self._chooser_gain_combo_box.addItem(label)
        self._chooser_gain_callback = lambda i: Qt.QMetaObject.invokeMethod(self._chooser_gain_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._chooser_gain_options.index(i)))
        self._chooser_gain_callback(self.chooser_gain)
        self._chooser_gain_combo_box.currentIndexChanged.connect(
        	lambda i: self.set_chooser_gain(self._chooser_gain_options[i]))
        self.notebook_top_grid_layout_0.addWidget(self._chooser_gain_tool_bar, 0, 0, 1, 1)
        self._chooser_frequency_options = [f[0] for f in noaa_stations]
        self._chooser_frequency_labels = noaa_stations_labels
        self._chooser_frequency_tool_bar = Qt.QToolBar(self)
        self._chooser_frequency_tool_bar.addWidget(Qt.QLabel("NOAA Frequency"+": "))
        self._chooser_frequency_combo_box = Qt.QComboBox()
        self._chooser_frequency_tool_bar.addWidget(self._chooser_frequency_combo_box)
        for label in self._chooser_frequency_labels: self._chooser_frequency_combo_box.addItem(label)
        self._chooser_frequency_callback = lambda i: Qt.QMetaObject.invokeMethod(self._chooser_frequency_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._chooser_frequency_options.index(i)))
        self._chooser_frequency_callback(self.chooser_frequency)
        self._chooser_frequency_combo_box.currentIndexChanged.connect(
        	lambda i: self.set_chooser_frequency(self._chooser_frequency_options[i]))
        self.top_grid_layout.addWidget(self._chooser_frequency_tool_bar, 0, 0, 1, 1)
        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(chooser_frequency, 0)
        self.rtlsdr_source_0.set_freq_corr(range_ppm_corr, 0)
        self.rtlsdr_source_0.set_dc_offset_mode(2, 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(chooser_gain, 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("", 0)
        self.rtlsdr_source_0.set_bandwidth(0, 0)
          
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
                interpolation=int(16e3),
                decimation=int(samp_rate),
                taps=None,
                fractional_bw=None,
        )
        self.qtgui_waterfall_sink_x_1 = qtgui.waterfall_sink_f(
        	1024, #size
        	firdes.WIN_BLACKMAN_hARRIS, #wintype
        	0, #fc
        	16e3, #bw
        	"", #name
                1 #number of inputs
        )
        self.qtgui_waterfall_sink_x_1.set_update_time(0.10)
        self.qtgui_waterfall_sink_x_1.enable_grid(False)
        
        if not True:
          self.qtgui_waterfall_sink_x_1.disable_legend()
        
        if "float" == "float" or "float" == "msg_float":
          self.qtgui_waterfall_sink_x_1.set_plot_pos_half(not False)
        
        labels = ["", "", "", "", "",
                  "", "", "", "", ""]
        colors = [3, 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_1.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_waterfall_sink_x_1.set_line_label(i, labels[i])
            self.qtgui_waterfall_sink_x_1.set_color_map(i, colors[i])
            self.qtgui_waterfall_sink_x_1.set_line_alpha(i, alphas[i])
        
        self.qtgui_waterfall_sink_x_1.set_intensity_range(-80, -40)
        
        self._qtgui_waterfall_sink_x_1_win = sip.wrapinstance(self.qtgui_waterfall_sink_x_1.pyqwidget(), Qt.QWidget)
        self.notebook_top_grid_layout_1.addWidget(self._qtgui_waterfall_sink_x_1_win, 0,1,1,1)
        self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c(
        	1024, #size
        	firdes.WIN_BLACKMAN_hARRIS, #wintype
        	0, #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)
        
        if not False:
          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(-80, -20)
        
        self._qtgui_waterfall_sink_x_0_win = sip.wrapinstance(self.qtgui_waterfall_sink_x_0.pyqwidget(), Qt.QWidget)
        self.notebook_rf_layout_1.addWidget(self._qtgui_waterfall_sink_x_0_win)
        self.qtgui_freq_sink_x_0_0 = qtgui.freq_sink_f(
        	1024, #size
        	firdes.WIN_BLACKMAN_hARRIS, #wintype
        	0, #fc
        	16e3, #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(-80, -40)
        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(0.1)
        self.qtgui_freq_sink_x_0_0.enable_control_panel(False)
        
        if not False:
          self.qtgui_freq_sink_x_0_0.disable_legend()
        
        if "float" == "float" or "float" == "msg_float":
          self.qtgui_freq_sink_x_0_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_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.notebook_top_grid_layout_1.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
        	chooser_frequency, #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(-80, -20)
        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(0.1)
        self.qtgui_freq_sink_x_0.enable_control_panel(False)
        
        if not False:
          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.notebook_rf_layout_0.addWidget(self._qtgui_freq_sink_x_0_win)
        self.low_pass_filter_0 = filter.fir_filter_ccf(1, firdes.low_pass(
        	1, samp_rate, 6e3, 1e3, firdes.WIN_HAMMING, 6.76))
        self.high_pass_filter_0 = filter.fir_filter_fff(1, firdes.high_pass(
        	1, 16e3, 15, 5, firdes.WIN_HAMMING, 6.76))
        self.audio_sink_0 = audio.sink(16000, "", True)
        self.analog_nbfm_rx_0 = analog.nbfm_rx(
        	audio_rate=int(16e3),
        	quad_rate=int(16e3),
        	tau=75e-6,
        	max_dev=4e3,
        )

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_nbfm_rx_0, 0), (self.high_pass_filter_0, 0))    
        self.connect((self.high_pass_filter_0, 0), (self.audio_sink_0, 0))    
        self.connect((self.high_pass_filter_0, 0), (self.qtgui_freq_sink_x_0_0, 0))    
        self.connect((self.high_pass_filter_0, 0), (self.qtgui_waterfall_sink_x_1, 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.rtlsdr_source_0, 0), (self.low_pass_filter_0, 0))    
        self.connect((self.rtlsdr_source_0, 0), (self.qtgui_freq_sink_x_0, 0))    
        self.connect((self.rtlsdr_source_0, 0), (self.qtgui_waterfall_sink_x_0, 0))    
Example #37
0
    def __init__(self, args, spec, antenna, gain, audio_output):
	gr.hier_block2.__init__(self, "receive_path",
				gr.io_signature(0, 0, 0), # Input signature
				gr.io_signature(0, 0, 0)) # Output signature

        self.u = uhd.usrp_source(device_addr=args,
                                 io_type=uhd.io_type.COMPLEX_FLOAT32,
                                 num_channels=1)

        self.if_rate    = 256e3
        self.quad_rate  = 64e3
        self.audio_rate = 32e3

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

        # Create filter to get actual channel we want
        nfilts = 32
        chan_coeffs = filter.firdes.low_pass(nfilts,             # gain
                                             nfilts*dev_rate,    # sampling rate
                                             13e3,               # low pass cutoff freq
                                             4e3,                # width of trans. band
                                             filter.firdes.WIN_HANN) # filter type

        rrate = self.quad_rate / dev_rate
        self.resamp = filter.pfb.arb_resampler_ccf(rrate, chan_coeffs, nfilts)

        # instantiate the guts of the single channel receiver
        self.fmrx = analog.nbfm_rx(self.audio_rate, self.quad_rate)

        # standard squelch block
        self.squelch = analog.standard_squelch(self.audio_rate)

        # audio gain / mute block
        self._audio_gain = blocks.multiply_const_ff(1.0)

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

        # now wire it all together
        self.connect(self.u, self.resamp, self.fmrx, self.squelch,
                     self._audio_gain, audio_sink)

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

        self.enabled = True
        self.set_gain(gain)
        v = self.volume_range()
        self.set_volume((v[0]+v[1])/2)
        s = self.squelch_range()
        self.set_squelch((s[0]+s[1])/2)

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

        # Set the antenna
        if(antenna):
            self.u.set_antenna(antenna, 0)
    def __init__(self, pluto_uri='usb:1.5.5'):
        gr.top_block.__init__(self, "Aprs Full Duplex Pluto")

        ##################################################
        # Parameters
        ##################################################
        self.pluto_uri = pluto_uri

        ##################################################
        # Variables
        ##################################################
        self.audio_samp = audio_samp = 24000
        self.source_samp = source_samp = 44100
        self.samp_rate = samp_rate = audio_samp * 22
        self.refresh_rate = refresh_rate = 10
        self.cutoff_frequency = cutoff_frequency = 100e3
        self.center_frequency = center_frequency = 435e6
        self.Decay = Decay = 0.1
        self.Attack = Attack = 0.8

        ##################################################
        # Blocks
        ##################################################
        self.rational_resampler_xxx_0_0_0_0 = filter.rational_resampler_ccc(
            interpolation=samp_rate,
            decimation=source_samp,
            taps=None,
            fractional_bw=None,
        )
        self.rational_resampler_xxx_0 = filter.rational_resampler_fff(
            interpolation=1,
            decimation=1,
            taps=None,
            fractional_bw=None,
        )
        self.pluto_source_0 = iio.pluto_source(pluto_uri,
                                               int(center_frequency),
                                               samp_rate, 20000000, 0x8000,
                                               True, True, True, "manual",
                                               64.0, '', True)
        self.pluto_sink_0 = iio.pluto_sink(pluto_uri, int(center_frequency),
                                           samp_rate, 20000000, 0x8000, False,
                                           10.0, '', True)
        self.detectMarkSpace_1_0_0 = detectMarkSpace(
            decay=Decay,
            samp_rate=audio_samp,
            attack=Attack,
            Frequency=2200,
        )
        self.detectMarkSpace_0_0_0 = detectMarkSpace(
            decay=Decay,
            samp_rate=audio_samp,
            attack=Attack,
            Frequency=1200,
        )
        self.blocks_wavfile_source_0 = blocks.wavfile_source(
            '/home/pi/aprs_web_client/aprs_test_message.wav', True)
        self.blocks_sub_xx_0_0_0_0 = blocks.sub_ff(1)
        self.blocks_file_sink_0_0 = blocks.file_sink(
            gr.sizeof_char * 1, '/home/pi/aprs_web_client/full_duplex.log',
            True)
        self.blocks_file_sink_0_0.set_unbuffered(True)
        self.band_pass_filter_0_0_0 = filter.fir_filter_fff(
            1,
            firdes.band_pass(1, audio_samp, 950, 2450, 100, firdes.WIN_HAMMING,
                             6.76))
        self.analog_nbfm_tx_0 = analog.nbfm_tx(
            audio_rate=source_samp,
            quad_rate=source_samp,
            tau=75e-6,
            max_dev=5e3,
            fh=-1.0,
        )
        self.analog_nbfm_rx_0 = analog.nbfm_rx(
            audio_rate=audio_samp,
            quad_rate=int(samp_rate),
            tau=75e-6,
            max_dev=5e3,
        )
        self.afsk_ax25decode_1_0 = afsk.ax25decode(audio_samp, 5)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.afsk_ax25decode_1_0, 0),
                     (self.blocks_file_sink_0_0, 0))
        self.connect((self.analog_nbfm_rx_0, 0),
                     (self.rational_resampler_xxx_0, 0))
        self.connect((self.analog_nbfm_tx_0, 0),
                     (self.rational_resampler_xxx_0_0_0_0, 0))
        self.connect((self.band_pass_filter_0_0_0, 0),
                     (self.detectMarkSpace_0_0_0, 0))
        self.connect((self.band_pass_filter_0_0_0, 0),
                     (self.detectMarkSpace_1_0_0, 0))
        self.connect((self.blocks_sub_xx_0_0_0_0, 0),
                     (self.afsk_ax25decode_1_0, 0))
        self.connect((self.blocks_wavfile_source_0, 0),
                     (self.analog_nbfm_tx_0, 0))
        self.connect((self.detectMarkSpace_0_0_0, 0),
                     (self.blocks_sub_xx_0_0_0_0, 0))
        self.connect((self.detectMarkSpace_1_0_0, 0),
                     (self.blocks_sub_xx_0_0_0_0, 1))
        self.connect((self.pluto_source_0, 0), (self.analog_nbfm_rx_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.band_pass_filter_0_0_0, 0))
        self.connect((self.rational_resampler_xxx_0_0_0_0, 0),
                     (self.pluto_sink_0, 0))
Example #39
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))    
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="HAM 2m FM Receiver")

        ##################################################
        # Variables
        ##################################################
        self.repeaters = repeaters = struct({"a": 145270000, "b": 145410000, "c": 146685000, "d": 147030000, "e": 441700000, })
        self.repeater_chooser = repeater_chooser = repeaters.e
        self.variable_static_text_0 = variable_static_text_0 = repeater_chooser
        self.samp_rate = samp_rate = 2.4e6
        self.frequency = frequency = 441.700e6

        ##################################################
        # Blocks
        ##################################################
        self._repeater_chooser_chooser = forms.drop_down(
        	parent=self.GetWin(),
        	value=self.repeater_chooser,
        	callback=self.set_repeater_chooser,
        	label='repeater_chooser',
        	choices=[repeaters.a, repeaters.b, repeaters.c, repeaters.d, repeaters.e],
        	labels=["W3PVI", "KD3WT", "WM3PEN", "W3QV", "W3WAN"],
        )
        self.Add(self._repeater_chooser_chooser)
        self.wxgui_fftsink2_0_1 = fftsink2.fft_sink_c(
        	self.GetWin(),
        	baseband_freq=repeater_chooser,
        	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="RF Spectrum",
        	peak_hold=False,
        )
        self.Add(self.wxgui_fftsink2_0_1.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='variable_static_text_0',
        	converter=forms.float_converter(),
        )
        self.Add(self._variable_static_text_0_static_text)
        self.rtlsdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + "rtl=0" )
        self.rtlsdr_source_0.set_sample_rate(samp_rate)
        self.rtlsdr_source_0.set_center_freq(repeater_chooser, 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(True, 0)
        self.rtlsdr_source_0.set_gain(10, 0)
        self.rtlsdr_source_0.set_if_gain(20, 0)
        self.rtlsdr_source_0.set_bb_gain(20, 0)
        self.rtlsdr_source_0.set_antenna("", 0)
        self.rtlsdr_source_0.set_bandwidth(0, 0)
          
        self.rational_resampler_xxx_1 = filter.rational_resampler_ccc(
                interpolation=500,
                decimation=2400,
                taps=None,
                fractional_bw=None,
        )
        self.rational_resampler_xxx_0 = filter.rational_resampler_fff(
                interpolation=48,
                decimation=50,
                taps=None,
                fractional_bw=None,
        )
        self.low_pass_filter_0 = filter.fir_filter_ccf(1, firdes.low_pass(
        	1, 500000, 100000, 8000, firdes.WIN_HAMMING, 6.76))
        self.audio_sink_0 = audio.sink(48000, "", True)
        self.analog_nbfm_rx_0 = analog.nbfm_rx(
        	audio_rate=50,
        	quad_rate=500000,
        	tau=75e-6,
        	max_dev=10e3,
          )

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_nbfm_rx_0, 0), (self.rational_resampler_xxx_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.audio_sink_0, 0))    
        self.connect((self.rational_resampler_xxx_1, 0), (self.low_pass_filter_0, 0))    
        self.connect((self.rtlsdr_source_0, 0), (self.rational_resampler_xxx_1, 0))    
        self.connect((self.rtlsdr_source_0, 0), (self.wxgui_fftsink2_0_1, 0))    
Example #41
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(
            self, title="narrow fm demod on high freq police radio bands")
        _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 = 2400000
        self.rx_freq = rx_freq = 854.388e6
        self.rx_fine = rx_fine = 0
        self.rx_coarse = rx_coarse = 0
        self.xlate_filter_taps = xlate_filter_taps = firdes.low_pass(
            1, samp_rate, 125000, 25000, firdes.WIN_HAMMING, 6.76)
        self.width = width = 12500
        self.variable_chooser_1 = variable_chooser_1 = 1
        self.tv_freq = tv_freq = 500.25e6
        self.trans = trans = 25000
        self.squelch = squelch = -55
        self.sql_lev = sql_lev = -20
        self.rx_freq_val = rx_freq_val = rx_freq + (rx_coarse + rx_fine)
        self.freq = freq = 155e6
        self.dev = dev = 7500
        self.decimation = decimation = 50
        self.af_gain = af_gain = 1

        ##################################################
        # Blocks
        ##################################################
        _width_sizer = wx.BoxSizer(wx.VERTICAL)
        self._width_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_width_sizer,
            value=self.width,
            callback=self.set_width,
            label="LP Filter",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._width_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_width_sizer,
            value=self.width,
            callback=self.set_width,
            minimum=2000,
            maximum=40000,
            num_steps=760,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_width_sizer, 2, 4, 1, 4)
        _trans_sizer = wx.BoxSizer(wx.VERTICAL)
        self._trans_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_trans_sizer,
            value=self.trans,
            callback=self.set_trans,
            label="LP Trans",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._trans_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_trans_sizer,
            value=self.trans,
            callback=self.set_trans,
            minimum=500,
            maximum=50000,
            num_steps=900,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_trans_sizer, 2, 8, 1, 4)
        _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 level",
            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=-100,
            maximum=0,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.Add(_squelch_sizer)
        _rx_freq_sizer = wx.BoxSizer(wx.VERTICAL)
        self._rx_freq_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_rx_freq_sizer,
            value=self.rx_freq,
            callback=self.set_rx_freq,
            label="RX Center ",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._rx_freq_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_rx_freq_sizer,
            value=self.rx_freq,
            callback=self.set_rx_freq,
            minimum=840000000,
            maximum=860000000,
            num_steps=1000,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_rx_freq_sizer, 0, 0, 1, 16)
        _rx_fine_sizer = wx.BoxSizer(wx.VERTICAL)
        self._rx_fine_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_rx_fine_sizer,
            value=self.rx_fine,
            callback=self.set_rx_fine,
            label="RX Fine",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._rx_fine_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_rx_fine_sizer,
            value=self.rx_fine,
            callback=self.set_rx_fine,
            minimum=0,
            maximum=10000,
            num_steps=1000,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_rx_fine_sizer, 1, 4, 1, 4)
        _rx_coarse_sizer = wx.BoxSizer(wx.VERTICAL)
        self._rx_coarse_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_rx_coarse_sizer,
            value=self.rx_coarse,
            callback=self.set_rx_coarse,
            label="RX Offset",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._rx_coarse_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_rx_coarse_sizer,
            value=self.rx_coarse,
            callback=self.set_rx_coarse,
            minimum=0,
            maximum=1e6,
            num_steps=1000,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_rx_coarse_sizer, 1, 0, 1, 4)
        _dev_sizer = wx.BoxSizer(wx.VERTICAL)
        self._dev_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_dev_sizer,
            value=self.dev,
            callback=self.set_dev,
            label="NBFM deviation",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._dev_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_dev_sizer,
            value=self.dev,
            callback=self.set_dev,
            minimum=4000,
            maximum=16000,
            num_steps=24,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.Add(_dev_sizer)
        self.wxgui_waterfallsink2_1 = waterfallsink2.waterfall_sink_c(
            self.GetWin(),
            baseband_freq=rx_freq + rx_coarse + rx_fine,
            dynamic_range=100,
            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_1.win)
        self._variable_chooser_1_chooser = forms.drop_down(
            parent=self.GetWin(),
            value=self.variable_chooser_1,
            callback=self.set_variable_chooser_1,
            label='variable_chooser_1',
            choices=[1, 2, 3],
            labels=[],
        )
        self.Add(self._variable_chooser_1_chooser)
        _sql_lev_sizer = wx.BoxSizer(wx.VERTICAL)
        self._sql_lev_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_sql_lev_sizer,
            value=self.sql_lev,
            callback=self.set_sql_lev,
            label="SQL",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._sql_lev_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_sql_lev_sizer,
            value=self.sql_lev,
            callback=self.set_sql_lev,
            minimum=-100,
            maximum=100,
            num_steps=200,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_sql_lev_sizer, 1, 12, 1, 4)
        self._rx_freq_val_static_text = forms.static_text(
            parent=self.GetWin(),
            value=self.rx_freq_val,
            callback=self.set_rx_freq_val,
            label="Receive",
            converter=forms.float_converter(),
        )
        self.GridAdd(self._rx_freq_val_static_text, 0, 16, 1, 1)
        self.rtlsdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " +
                                              "")
        self.rtlsdr_source_0.set_time_now(osmosdr.time_spec_t(time.time()),
                                          osmosdr.ALL_MBOARDS)
        self.rtlsdr_source_0.set_sample_rate(samp_rate)
        self.rtlsdr_source_0.set_center_freq(rx_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(10, 0)
        self.rtlsdr_source_0.set_if_gain(20, 0)
        self.rtlsdr_source_0.set_bb_gain(20, 0)
        self.rtlsdr_source_0.set_antenna("", 0)
        self.rtlsdr_source_0.set_bandwidth(0, 0)

        self.low_pass_filter_0 = filter.fir_filter_ccf(
            decimation,
            firdes.low_pass(1, samp_rate, width, trans, firdes.WIN_HAMMING,
                            6.76))
        self.audio_sink_0 = audio.sink(48000, "", True)
        self.analog_simple_squelch_cc_0 = analog.simple_squelch_cc(squelch, 1)
        self.analog_nbfm_rx_0 = analog.nbfm_rx(
            audio_rate=48000,
            quad_rate=48000,
            tau=50e-6,
            max_dev=dev,
        )
        _af_gain_sizer = wx.BoxSizer(wx.VERTICAL)
        self._af_gain_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_af_gain_sizer,
            value=self.af_gain,
            callback=self.set_af_gain,
            label="VOL",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._af_gain_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_af_gain_sizer,
            value=self.af_gain,
            callback=self.set_af_gain,
            minimum=0,
            maximum=5,
            num_steps=50,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_af_gain_sizer, 2, 12, 1, 4)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_nbfm_rx_0, 0), (self.audio_sink_0, 0))
        self.connect((self.analog_simple_squelch_cc_0, 0),
                     (self.analog_nbfm_rx_0, 0))
        self.connect((self.low_pass_filter_0, 0),
                     (self.analog_simple_squelch_cc_0, 0))
        self.connect((self.rtlsdr_source_0, 0), (self.low_pass_filter_0, 0))
        self.connect((self.rtlsdr_source_0, 0),
                     (self.wxgui_waterfallsink2_1, 0))
    def __init__(self, args, spec, antenna, gain, audio_output):
	gr.hier_block2.__init__(self, "receive_path",
				gr.io_signature(0, 0, 0), # Input signature
				gr.io_signature(0, 0, 0)) # Output signature

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

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

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

        self.if_rate    = 256e3
        self.quad_rate  = 64e3
        self.audio_rate = 32e3

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

        # Create filter to get actual channel we want
        nfilts = 32
        chan_coeffs = filter.firdes.low_pass(nfilts,              # gain
                                             nfilts*dev_rate,     # sampling rate
                                             8e3,                 # low pass cutoff freq
                                             2e3,                 # width of trans. band
                                             filter.firdes.WIN_HANN)  # filter type
        rrate = self.quad_rate / dev_rate
        self.resamp = filter.pfb.arb_resampler_ccf(rrate, chan_coeffs, nfilts)

        if USE_SIMPLE_SQUELCH:
            self.squelch = analog.simple_squelch_cc(20)
        else:
            self.squelch = analog.standard_squelch(self.audio_rate)

        # instantiate the guts of the single channel receiver
        self.fmrx = analog.nbfm_rx(self.audio_rate, self.quad_rate)

        # audio gain / mute block
        self._audio_gain = blocks.multiply_const_ff(1.0)

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

        # now wire it all together
        if USE_SIMPLE_SQUELCH:
            self.connect (self.u, self.resamp, self.squelch, self.fmrx,
                          self._audio_gain, audio_sink)
        else:
            self.connect (self.u, self.resamp, self.fmrx, self.squelch,
                          self._audio_gain, audio_sink)

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

        self.set_gain(gain)

        v = self.volume_range()
        self.set_volume((v[0]+v[1])/2)

        s = self.squelch_range()
        self.set_squelch((s[0]+s[1])/2)
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="B200 VHF NBFM 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_rx_choice = tx_rx_choice = 1
        self.tx_gain = tx_gain = .615
        self.tune_minus_20 = tune_minus_20 = 0
        self.tune_minus_10 = tune_minus_10 = 0
        self.tune_20 = tune_20 = 0
        self.tune_10 = tune_10 = 0
        self.tone = tone = 100
        self.squelch = squelch = -70.32
        self.samp_rate = samp_rate = 4000000
        self.rx_offset = rx_offset = 0
        self.rit_tune = rit_tune = 0
        self.offset = offset = 600000
        self.chooser_fm = chooser_fm = 147.34e6
        self.audio_gain = audio_gain = .7

        ##################################################
        # Blocks
        ##################################################
        self._tx_rx_choice_chooser = forms.button(
        	parent=self.GetWin(),
        	value=self.tx_rx_choice,
        	callback=self.set_tx_rx_choice,
        	label="TX-RX",
        	choices=[0, 1],
        	labels=['TX', 'RX'],
        )
        self.GridAdd(self._tx_rx_choice_chooser, 0, 3, 1, 1)
        _tx_gain_sizer = wx.BoxSizer(wx.VERTICAL)
        self._tx_gain_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_tx_gain_sizer,
        	value=self.tx_gain,
        	callback=self.set_tx_gain,
        	label="TX Gain: 144= .6, 220= .70, 440= .72",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._tx_gain_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_tx_gain_sizer,
        	value=self.tx_gain,
        	callback=self.set_tx_gain,
        	minimum=.6,
        	maximum=.75,
        	num_steps=1000,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.Add(_tx_gain_sizer)
        self._tune_minus_20_chooser = forms.button(
        	parent=self.GetWin(),
        	value=self.tune_minus_20,
        	callback=self.set_tune_minus_20,
        	label="-20 Tune",
        	choices=[0, 20e3, 40e3, 60e3, 80e3, 100e3, 120e3, 140e3, 0],
        	labels=[0, -20, -40, -60, -80, -100, -120, -140, 0],
        )
        self.GridAdd(self._tune_minus_20_chooser, 0, 1, 1, 1)
        self._tune_minus_10_chooser = forms.button(
        	parent=self.GetWin(),
        	value=self.tune_minus_10,
        	callback=self.set_tune_minus_10,
        	label="-10 Tune",
        	choices=[0,-10e3, -20e3, -30e3, -40e3,-50e3,0],
        	labels=[0, -10, -20, -30, -40,-50,0],
        )
        self.GridAdd(self._tune_minus_10_chooser, 1, 1, 1, 1)
        self._tune_20_chooser = forms.button(
        	parent=self.GetWin(),
        	value=self.tune_20,
        	callback=self.set_tune_20,
        	label="+20 Tune",
        	choices=[0, 20e3, 40e3, 60e3, 80e3, 100e3, 120e3, 140e3,0],
        	labels=[0, '+20', '+40', '+60', '+80', '+100', '+120', '+140','0'],
        )
        self.GridAdd(self._tune_20_chooser, 0, 0, 1, 1)
        self._tune_10_chooser = forms.button(
        	parent=self.GetWin(),
        	value=self.tune_10,
        	callback=self.set_tune_10,
        	label="+10 Tune",
        	choices=[0,10e3, 20e3, 30e3, 40e3,50e3,0],
        	labels=[0,'+10', '+20', '+30', '+40','+50','0'],
        )
        self.GridAdd(self._tune_10_chooser, 1, 0, 1, 1)
        self._tone_chooser = forms.radio_buttons(
        	parent=self.GetWin(),
        	value=self.tone,
        	callback=self.set_tone,
        	label="CTCSS",
        	choices=[100,103.5, 110.9, 118.8, 123.0,127.3,179.5],
        	labels=['100', '103.5', '110.9','118.8', '123.0', '127.3','179.5'],
        	style=wx.RA_HORIZONTAL,
        )
        self.GridAdd(self._tone_chooser, 0, 5, 1, 1)
        _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=-95,
        	maximum=-55,
        	num_steps=1000,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_squelch_sizer, 0, 6, 1, 1)
        self._rx_offset_chooser = forms.radio_buttons(
        	parent=self.GetWin(),
        	value=self.rx_offset,
        	callback=self.set_rx_offset,
        	label="RX offset",
        	choices=[0, 600000, -600000,5e6],
        	labels=['0', '+', '-','+5M'],
        	style=wx.RA_HORIZONTAL,
        )
        self.GridAdd(self._rx_offset_chooser, 1, 6, 1, 1)
        _rit_tune_sizer = wx.BoxSizer(wx.VERTICAL)
        self._rit_tune_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_rit_tune_sizer,
        	value=self.rit_tune,
        	callback=self.set_rit_tune,
        	label="RIT",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._rit_tune_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_rit_tune_sizer,
        	value=self.rit_tune,
        	callback=self.set_rit_tune,
        	minimum=-30e3,
        	maximum=+30e3,
        	num_steps=1000,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_rit_tune_sizer, 1, 2, 1, 3)
        self._offset_chooser = forms.radio_buttons(
        	parent=self.GetWin(),
        	value=self.offset,
        	callback=self.set_offset,
        	label="TX offset",
        	choices=[600000, -600000, 0,5e6],
        	labels=['+', '-', '0','5MHz'],
        	style=wx.RA_HORIZONTAL,
        )
        self.GridAdd(self._offset_chooser, 0, 4, 1, 1)
        self._chooser_fm_chooser = forms.radio_buttons(
        	parent=self.GetWin(),
        	value=self.chooser_fm,
        	callback=self.set_chooser_fm,
        	label="Preset",
        	choices=[145.13e6,145.33e6, 145.88e6, 146.46e6, 146.49e6, 146.52e6,146.58e6, 146.64e6,146.74e6, 146.82e6, 146.86e6, 146.92e6, 146.96e6, 147.0e6,147.06e6, 147.08e6, 147.20e6, 147.22e6, 147.34e6, 223.5e6,441.825e6, 432.25e6],
        	labels=[145.13,145.33, 145.88, 146.46, 146.49, 146.52, 146.58, 146.64, 146.74, 146.82, 146.860, 146.92, 146.96,  147.00, 147.06, 147.08,147.200, 147.220, 147.34, 223.5,441.825, 432.25],
        	style=wx.RA_HORIZONTAL,
        )
        self.Add(self._chooser_fm_chooser)
        _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=.1,
        	maximum=4,
        	num_steps=1000,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_audio_gain_sizer, 0, 2, 1, 1)
        self.wxgui_fftsink2_0 = fftsink2.fft_sink_c(
        	self.GetWin(),
        	baseband_freq=(((((chooser_fm+tune_20)-tune_minus_20)+tune_10)+tune_minus_10)+rx_offset),
        	y_per_div=5,
        	y_divs=16,
        	ref_level=-55,
        	ref_scale=2.0,
        	sample_rate=samp_rate/2,
        	fft_size=1024*0+2048*0+4096,
        	fft_rate=12,
        	average=True,
        	avg_alpha=.4,
        	title="RF Bandpass",
        	peak_hold=False,
        )
        self.GridAdd(self.wxgui_fftsink2_0.win, 2, 0, 5, 14)
        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((((((chooser_fm+tune_20)-tune_minus_20)+tune_10)+tune_minus_10)+rx_offset)-10e3, 0)
        self.uhd_usrp_source_0.set_normalized_gain(.520*.8, 0)
        self.uhd_usrp_source_0.set_antenna("RX2", 0)
        self.uhd_usrp_source_0.set_bandwidth(1.99e6, 0)
        self.uhd_usrp_sink_1 = uhd.usrp_sink(
        	",".join(("", "")),
        	uhd.stream_args(
        		cpu_format="fc32",
        		channels=range(1),
        	),
        )
        self.uhd_usrp_sink_1.set_samp_rate(320000)
        self.uhd_usrp_sink_1.set_center_freq((((((chooser_fm+offset)+tune_20)-tune_minus_20)+tune_10)+tune_minus_10)+rit_tune, 0)
        self.uhd_usrp_sink_1.set_normalized_gain((.83*0+.72)*0+tx_gain, 0)
        self.uhd_usrp_sink_1.set_antenna("TX/RX", 0)
        self.uhd_usrp_sink_1.set_bandwidth(200000, 0)
        self.rational_resampler_xxx_1 = filter.rational_resampler_ccc(
                interpolation=32000,
                decimation=40000,
                taps=None,
                fractional_bw=None,
        )
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
                interpolation=samp_rate/2,
                decimation=samp_rate,
                taps=None,
                fractional_bw=None,
        )
        self.pfb_decimator_ccf_0 = pfb.decimator_ccf(
        	  2,
        	  (firdes.low_pass(.1, (samp_rate), (samp_rate)/4.05,10e3)),
        	  0,
        	  100,
                  True,
                  True)
        self.pfb_decimator_ccf_0.declare_sample_delay(0)
        	
        self.low_pass_filter_1 = filter.fir_filter_fff(1, firdes.low_pass(
        	1, 32000, 4400, 300, firdes.WIN_HAMMING, 6.76))
        self.low_pass_filter_0 = filter.fir_filter_fff(1, firdes.low_pass(
        	1, 32000, 4500, 600, firdes.WIN_HAMMING, 6.76))
        self.high_pass_filter_0 = filter.fir_filter_fff(1, firdes.high_pass(
        	1, 32000, 300, 100, firdes.WIN_HAMMING, 6.76))
        self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(50, (firdes.low_pass(1,samp_rate/2,18e3,600)), 0+rit_tune+10e3, samp_rate/2)
        self.blocks_null_source_0 = blocks.null_source(gr.sizeof_gr_complex*1)
        self.blocks_multiply_const_vxx_2 = blocks.multiply_const_vcc((.8, ))
        self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vff((125, ))
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((audio_gain*tx_rx_choice, ))
        self.blocks_add_xx_1 = blocks.add_vff(1)
        self.blks2_selector_0_1 = grc_blks2.selector(
        	item_size=gr.sizeof_gr_complex*1,
        	num_inputs=2,
        	num_outputs=1,
        	input_index=1+(tx_rx_choice),
        	output_index=0,
        )
        self.audio_source_1 = audio.source(32000, "", True)
        self.audio_sink_0 = audio.sink(32000, "", True)
        self.analog_simple_squelch_cc_0 = analog.simple_squelch_cc(squelch, .0001)
        self.analog_sig_source_x_0 = analog.sig_source_f(32000, analog.GR_COS_WAVE, tone, .091, 0)
        self.analog_nbfm_tx_1 = analog.nbfm_tx(
        	audio_rate=32000,
        	quad_rate=320000,
        	tau=(75e-6)*0+90e-6,
        	max_dev=5e3,
                )
        self.analog_nbfm_rx_0 = analog.nbfm_rx(
        	audio_rate=32000,
        	quad_rate=32000,
        	tau=75e-6,
        	max_dev=5e3,
          )
        self.analog_fm_preemph_0 = analog.fm_preemph(fs=32e3, tau=75e-6)
        self.analog_fm_deemph_0 = analog.fm_deemph(fs=32000, tau=75e-6)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_fm_deemph_0, 0), (self.low_pass_filter_1, 0))    
        self.connect((self.analog_fm_preemph_0, 0), (self.blocks_add_xx_1, 0))    
        self.connect((self.analog_nbfm_rx_0, 0), (self.analog_fm_deemph_0, 0))    
        self.connect((self.analog_nbfm_tx_1, 0), (self.blocks_multiply_const_vxx_2, 0))    
        self.connect((self.analog_sig_source_x_0, 0), (self.blocks_add_xx_1, 1))    
        self.connect((self.analog_simple_squelch_cc_0, 0), (self.rational_resampler_xxx_1, 0))    
        self.connect((self.audio_source_1, 0), (self.blocks_multiply_const_vxx_1, 0))    
        self.connect((self.blks2_selector_0_1, 0), (self.uhd_usrp_sink_1, 0))    
        self.connect((self.blocks_add_xx_1, 0), (self.analog_nbfm_tx_1, 0))    
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.audio_sink_0, 0))    
        self.connect((self.blocks_multiply_const_vxx_1, 0), (self.high_pass_filter_0, 0))    
        self.connect((self.blocks_multiply_const_vxx_2, 0), (self.blks2_selector_0_1, 1))    
        self.connect((self.blocks_null_source_0, 0), (self.blks2_selector_0_1, 0))    
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.analog_simple_squelch_cc_0, 0))    
        self.connect((self.high_pass_filter_0, 0), (self.low_pass_filter_0, 0))    
        self.connect((self.low_pass_filter_0, 0), (self.analog_fm_preemph_0, 0))    
        self.connect((self.low_pass_filter_1, 0), (self.blocks_multiply_const_vxx_0, 0))    
        self.connect((self.pfb_decimator_ccf_0, 0), (self.wxgui_fftsink2_0, 0))    
        self.connect((self.rational_resampler_xxx_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0))    
        self.connect((self.rational_resampler_xxx_1, 0), (self.analog_nbfm_rx_0, 0))    
        self.connect((self.uhd_usrp_source_0, 0), (self.pfb_decimator_ccf_0, 0))    
        self.connect((self.uhd_usrp_source_0, 0), (self.rational_resampler_xxx_0, 0))    
Example #44
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Audio 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 = 195312
        self.variable_slider_0 = variable_slider_0 = 80e6
        self.FILT = FILT = firdes.low_pass(1, samp_rate, 10000, 1000,
                                           firdes.WIN_HAMMING, 6.76)

        ##################################################
        # Blocks
        ##################################################
        _variable_slider_0_sizer = wx.BoxSizer(wx.VERTICAL)
        self._variable_slider_0_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_variable_slider_0_sizer,
            value=self.variable_slider_0,
            callback=self.set_variable_slider_0,
            label='variable_slider_0',
            converter=forms.float_converter(),
            proportion=0,
        )
        self._variable_slider_0_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_variable_slider_0_sizer,
            value=self.variable_slider_0,
            callback=self.set_variable_slider_0,
            minimum=80e6,
            maximum=150e6,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.Add(_variable_slider_0_sizer)
        self.wxgui_fftsink2_0 = fftsink2.fft_sink_c(
            self.GetWin(),
            baseband_freq=variable_slider_0,
            y_per_div=10,
            y_divs=10,
            ref_level=0,
            ref_scale=2.0,
            sample_rate=195312,
            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.uhd_usrp_source_0 = uhd.usrp_source(
            device_addr="",
            stream_args=uhd.stream_args(
                cpu_format="fc32",
                otw_format="sc16",
                channels=range(1),
            ),
        )
        self.uhd_usrp_source_0.set_samp_rate(195312)
        self.uhd_usrp_source_0.set_center_freq(variable_slider_0, 0)
        self.uhd_usrp_source_0.set_gain(20, 0)
        self.uhd_usrp_source_0.set_antenna("J1", 0)
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
            interpolation=44100,
            decimation=195312,
            taps=None,
            fractional_bw=None,
        )
        self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(
            1, (FILT), -100e6, samp_rate)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((3, ))
        self.audio_sink_0_0 = audio.sink(44100, "", True)
        self.analog_nbfm_rx_0 = analog.nbfm_rx(
            audio_rate=44100,
            quad_rate=44100,
            tau=75e-6,
            max_dev=2.5e3,
        )

        ##################################################
        # Connections
        ##################################################
        self.connect((self.uhd_usrp_source_0, 0),
                     (self.freq_xlating_fir_filter_xxx_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.analog_nbfm_rx_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0),
                     (self.rational_resampler_xxx_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0),
                     (self.wxgui_fftsink2_0, 0))
        self.connect((self.analog_nbfm_rx_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.audio_sink_0_0, 0))
Example #45
0
    def __init__(self):
        gr.top_block.__init__(self, "Multimon Flex Rtl Tcp")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Multimon Flex Rtl Tcp")
        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", "multimon_flex_rtl_tcp")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 2.4e6
        self.channel_9 = channel_9 = 931.45e6
        self.channel_8 = channel_8 = 931.4e6
        self.channel_7 = channel_7 = 931.85e6
        self.channel_6 = channel_6 = 931.5e6
        self.channel_5 = channel_5 = 929.7e6
        self.channel_4 = channel_4 = 929.650e6
        self.channel_3 = channel_3 = 929.6e6
        self.channel_2 = channel_2 = 929.5e6
        self.channel_12 = channel_12 = 929.85e6
        self.channel_11 = channel_11 = 929.8e6
        self.channel_10 = channel_10 = 929.65e6
        self.channel_1 = channel_1 = 929.65e6
        self.channel_0 = channel_0 = 929.6e6
        self.xlate_filter_taps = xlate_filter_taps = firdes.low_pass(1, samp_rate, 125000, 25000, firdes.WIN_HAMMING, 6.76)
        self.variable_qtgui_range_0 = variable_qtgui_range_0 = 50
        self.sqlch = sqlch = -50
        self.if_gain = if_gain = 40
        self.gain = gain = 50
        self.firdes_tap = firdes_tap = firdes.low_pass(1, samp_rate, 125000, 25000, firdes.WIN_HAMMING, 6.76)
        self.corr = corr = -13.5
        self.channel_13 = channel_13 = 929.625e6
        self.center_freq_1 = center_freq_1 = sum([channel_6, channel_7] ) / float(len([channel_6, channel_7]))
        self.center_freq_0 = center_freq_0 = sum([channel_0, channel_1] ) / float(len([channel_0, channel_1]))
        self.center_freq = center_freq = sum([channel_0, channel_1, channel_2, channel_3, channel_4, channel_5, channel_6, channel_7, channel_8, channel_9, channel_10, channel_11, channel_12] ) / float(len([channel_0, channel_1, channel_2, channel_3, channel_4, channel_5, channel_6, channel_7, channel_8, channel_9, channel_10, channel_11, channel_12]))
        self.bb_gain = bb_gain = 40

        ##################################################
        # Blocks
        ##################################################
        self._sqlch_range = Range(-150, -20, 500, -50, 200)
        self._sqlch_win = RangeWidget(self._sqlch_range, self.set_sqlch, "sqlch", "counter_slider", float)
        self.top_layout.addWidget(self._sqlch_win)
        self._if_gain_range = Range(0, 60, 100, 40, 200)
        self._if_gain_win = RangeWidget(self._if_gain_range, self.set_if_gain, "if_gain", "counter", float)
        self.top_layout.addWidget(self._if_gain_win)
        self._gain_range = Range(0, 100, 100, 50, 200)
        self._gain_win = RangeWidget(self._gain_range, self.set_gain, "gain", "counter", float)
        self.top_layout.addWidget(self._gain_win)
        self._corr_range = Range(-100, 100, 100, -13.5, 200)
        self._corr_win = RangeWidget(self._corr_range, self.set_corr, "corr", "counter", float)
        self.top_layout.addWidget(self._corr_win)
        self._channel_7_tool_bar = Qt.QToolBar(self)
        self._channel_7_tool_bar.addWidget(Qt.QLabel("channel_7"+": "))
        self._channel_7_line_edit = Qt.QLineEdit(str(self.channel_7))
        self._channel_7_tool_bar.addWidget(self._channel_7_line_edit)
        self._channel_7_line_edit.returnPressed.connect(
        	lambda: self.set_channel_7(eng_notation.str_to_num(str(self._channel_7_line_edit.text().toAscii()))))
        self.top_layout.addWidget(self._channel_7_tool_bar)
        self._channel_6_tool_bar = Qt.QToolBar(self)
        self._channel_6_tool_bar.addWidget(Qt.QLabel("channel_6"+": "))
        self._channel_6_line_edit = Qt.QLineEdit(str(self.channel_6))
        self._channel_6_tool_bar.addWidget(self._channel_6_line_edit)
        self._channel_6_line_edit.returnPressed.connect(
        	lambda: self.set_channel_6(eng_notation.str_to_num(str(self._channel_6_line_edit.text().toAscii()))))
        self.top_layout.addWidget(self._channel_6_tool_bar)
        self._channel_1_tool_bar = Qt.QToolBar(self)
        self._channel_1_tool_bar.addWidget(Qt.QLabel("channel_1"+": "))
        self._channel_1_line_edit = Qt.QLineEdit(str(self.channel_1))
        self._channel_1_tool_bar.addWidget(self._channel_1_line_edit)
        self._channel_1_line_edit.returnPressed.connect(
        	lambda: self.set_channel_1(eng_notation.str_to_num(str(self._channel_1_line_edit.text().toAscii()))))
        self.top_layout.addWidget(self._channel_1_tool_bar)
        self._channel_0_tool_bar = Qt.QToolBar(self)
        self._channel_0_tool_bar.addWidget(Qt.QLabel("channel_0"+": "))
        self._channel_0_line_edit = Qt.QLineEdit(str(self.channel_0))
        self._channel_0_tool_bar.addWidget(self._channel_0_line_edit)
        self._channel_0_line_edit.returnPressed.connect(
        	lambda: self.set_channel_0(eng_notation.str_to_num(str(self._channel_0_line_edit.text().toAscii()))))
        self.top_layout.addWidget(self._channel_0_tool_bar)
        self._bb_gain_range = Range(0, 100, 100, 40, 200)
        self._bb_gain_win = RangeWidget(self._bb_gain_range, self.set_bb_gain, "bb_gain", "counter", float)
        self.top_layout.addWidget(self._bb_gain_win)
        self._variable_qtgui_range_0_range = Range(0, 100, 1, 50, 200)
        self._variable_qtgui_range_0_win = RangeWidget(self._variable_qtgui_range_0_range, self.set_variable_qtgui_range_0, "variable_qtgui_range_0", "counter_slider", float)
        self.top_layout.addWidget(self._variable_qtgui_range_0_win)
        self.osmosdr_source_0_0 = osmosdr.source( args="numchan=" + str(1) + " " + 'rtl=1' )
        self.osmosdr_source_0_0.set_sample_rate(samp_rate)
        self.osmosdr_source_0_0.set_center_freq(center_freq_1 - 100000, 0)
        self.osmosdr_source_0_0.set_freq_corr(corr, 0)
        self.osmosdr_source_0_0.set_dc_offset_mode(0, 0)
        self.osmosdr_source_0_0.set_iq_balance_mode(2, 0)
        self.osmosdr_source_0_0.set_gain_mode(True, 0)
        self.osmosdr_source_0_0.set_gain(gain, 0)
        self.osmosdr_source_0_0.set_if_gain(if_gain, 0)
        self.osmosdr_source_0_0.set_bb_gain(bb_gain, 0)
        self.osmosdr_source_0_0.set_antenna('', 0)
        self.osmosdr_source_0_0.set_bandwidth(0, 0)

        self.osmosdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + 'rtl=0' )
        self.osmosdr_source_0.set_sample_rate(samp_rate)
        self.osmosdr_source_0.set_center_freq(center_freq_0 - 100000, 0)
        self.osmosdr_source_0.set_freq_corr(corr, 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(True, 0)
        self.osmosdr_source_0.set_gain(gain, 0)
        self.osmosdr_source_0.set_if_gain(if_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(0, 0)

        self.low_pass_filter_0_0_0_0_1 = filter.fir_filter_ccf(1, firdes.low_pass(
        	1, 48e3, 7.5e3, 5e3, firdes.WIN_HAMMING, 6.76))
        self.low_pass_filter_0_0_0_0_0_0 = filter.fir_filter_ccf(1, firdes.low_pass(
        	1, 48e3, 7.5e3, 5e3, firdes.WIN_HAMMING, 6.76))
        self.low_pass_filter_0_0 = filter.fir_filter_ccf(1, firdes.low_pass(
        	1, 48e3, 7.5e3, 5e3, firdes.WIN_HAMMING, 6.76))
        self.low_pass_filter_0 = filter.fir_filter_ccf(1, firdes.low_pass(
        	1, 48e3, 7.5e3, 5e3, firdes.WIN_HAMMING, 6.76))
        self.freq_xlating_fir_filter_xxx_0_0_0_0_1 = filter.freq_xlating_fir_filter_ccc(int(samp_rate / 48000), (firdes_tap), channel_6 - center_freq_1, samp_rate)
        self.freq_xlating_fir_filter_xxx_0_0_0_0_0_0 = filter.freq_xlating_fir_filter_ccc(int(samp_rate / 48000), (firdes_tap), channel_7 - center_freq_1, samp_rate)
        self.freq_xlating_fir_filter_xxx_0_0 = filter.freq_xlating_fir_filter_ccc(int(samp_rate / 48000), (firdes_tap), channel_1 - center_freq_0, samp_rate)
        self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(int(samp_rate / 48000), (firdes_tap), channel_0 - center_freq_0, samp_rate)
        self._channel_9_tool_bar = Qt.QToolBar(self)
        self._channel_9_tool_bar.addWidget(Qt.QLabel("channel_9"+": "))
        self._channel_9_line_edit = Qt.QLineEdit(str(self.channel_9))
        self._channel_9_tool_bar.addWidget(self._channel_9_line_edit)
        self._channel_9_line_edit.returnPressed.connect(
        	lambda: self.set_channel_9(eng_notation.str_to_num(str(self._channel_9_line_edit.text().toAscii()))))
        self.top_layout.addWidget(self._channel_9_tool_bar)
        self._channel_8_tool_bar = Qt.QToolBar(self)
        self._channel_8_tool_bar.addWidget(Qt.QLabel("channel_8"+": "))
        self._channel_8_line_edit = Qt.QLineEdit(str(self.channel_8))
        self._channel_8_tool_bar.addWidget(self._channel_8_line_edit)
        self._channel_8_line_edit.returnPressed.connect(
        	lambda: self.set_channel_8(eng_notation.str_to_num(str(self._channel_8_line_edit.text().toAscii()))))
        self.top_layout.addWidget(self._channel_8_tool_bar)
        self._channel_5_tool_bar = Qt.QToolBar(self)
        self._channel_5_tool_bar.addWidget(Qt.QLabel("channel_5"+": "))
        self._channel_5_line_edit = Qt.QLineEdit(str(self.channel_5))
        self._channel_5_tool_bar.addWidget(self._channel_5_line_edit)
        self._channel_5_line_edit.returnPressed.connect(
        	lambda: self.set_channel_5(eng_notation.str_to_num(str(self._channel_5_line_edit.text().toAscii()))))
        self.top_layout.addWidget(self._channel_5_tool_bar)
        self._channel_4_tool_bar = Qt.QToolBar(self)
        self._channel_4_tool_bar.addWidget(Qt.QLabel("channel_4"+": "))
        self._channel_4_line_edit = Qt.QLineEdit(str(self.channel_4))
        self._channel_4_tool_bar.addWidget(self._channel_4_line_edit)
        self._channel_4_line_edit.returnPressed.connect(
        	lambda: self.set_channel_4(eng_notation.str_to_num(str(self._channel_4_line_edit.text().toAscii()))))
        self.top_layout.addWidget(self._channel_4_tool_bar)
        self._channel_3_tool_bar = Qt.QToolBar(self)
        self._channel_3_tool_bar.addWidget(Qt.QLabel("channel_3"+": "))
        self._channel_3_line_edit = Qt.QLineEdit(str(self.channel_3))
        self._channel_3_tool_bar.addWidget(self._channel_3_line_edit)
        self._channel_3_line_edit.returnPressed.connect(
        	lambda: self.set_channel_3(eng_notation.str_to_num(str(self._channel_3_line_edit.text().toAscii()))))
        self.top_layout.addWidget(self._channel_3_tool_bar)
        self._channel_2_tool_bar = Qt.QToolBar(self)
        self._channel_2_tool_bar.addWidget(Qt.QLabel("channel_2"+": "))
        self._channel_2_line_edit = Qt.QLineEdit(str(self.channel_2))
        self._channel_2_tool_bar.addWidget(self._channel_2_line_edit)
        self._channel_2_line_edit.returnPressed.connect(
        	lambda: self.set_channel_2(eng_notation.str_to_num(str(self._channel_2_line_edit.text().toAscii()))))
        self.top_layout.addWidget(self._channel_2_tool_bar)
        self._channel_13_tool_bar = Qt.QToolBar(self)
        self._channel_13_tool_bar.addWidget(Qt.QLabel("channel_13"+": "))
        self._channel_13_line_edit = Qt.QLineEdit(str(self.channel_13))
        self._channel_13_tool_bar.addWidget(self._channel_13_line_edit)
        self._channel_13_line_edit.returnPressed.connect(
        	lambda: self.set_channel_13(eng_notation.str_to_num(str(self._channel_13_line_edit.text().toAscii()))))
        self.top_layout.addWidget(self._channel_13_tool_bar)
        self._channel_12_tool_bar = Qt.QToolBar(self)
        self._channel_12_tool_bar.addWidget(Qt.QLabel("channel_12"+": "))
        self._channel_12_line_edit = Qt.QLineEdit(str(self.channel_12))
        self._channel_12_tool_bar.addWidget(self._channel_12_line_edit)
        self._channel_12_line_edit.returnPressed.connect(
        	lambda: self.set_channel_12(eng_notation.str_to_num(str(self._channel_12_line_edit.text().toAscii()))))
        self.top_layout.addWidget(self._channel_12_tool_bar)
        self._channel_11_tool_bar = Qt.QToolBar(self)
        self._channel_11_tool_bar.addWidget(Qt.QLabel("channel_11"+": "))
        self._channel_11_line_edit = Qt.QLineEdit(str(self.channel_11))
        self._channel_11_tool_bar.addWidget(self._channel_11_line_edit)
        self._channel_11_line_edit.returnPressed.connect(
        	lambda: self.set_channel_11(eng_notation.str_to_num(str(self._channel_11_line_edit.text().toAscii()))))
        self.top_layout.addWidget(self._channel_11_tool_bar)
        self._channel_10_tool_bar = Qt.QToolBar(self)
        self._channel_10_tool_bar.addWidget(Qt.QLabel("channel_10"+": "))
        self._channel_10_line_edit = Qt.QLineEdit(str(self.channel_10))
        self._channel_10_tool_bar.addWidget(self._channel_10_line_edit)
        self._channel_10_line_edit.returnPressed.connect(
        	lambda: self.set_channel_10(eng_notation.str_to_num(str(self._channel_10_line_edit.text().toAscii()))))
        self.top_layout.addWidget(self._channel_10_tool_bar)
        self.blocks_udp_sink_3_0_1 = blocks.udp_sink(gr.sizeof_short*1, '127.0.0.1', 7306, 1472, True)
        self.blocks_udp_sink_3_0_0_0 = blocks.udp_sink(gr.sizeof_short*1, '127.0.0.1', 7307, 1472, True)
        self.blocks_udp_sink_1 = blocks.udp_sink(gr.sizeof_short*1, '127.0.0.1', 7301, 1472, True)
        self.blocks_udp_sink_0 = blocks.udp_sink(gr.sizeof_short*1, '127.0.0.1', 7300, 1472, True)
        self.blocks_multiply_xx_0_1 = blocks.multiply_vcc(1)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_multiply_const_vxx_0_2 = blocks.multiply_const_vff((0.1, ))
        self.blocks_multiply_const_vxx_0_0_1 = blocks.multiply_const_vff((0.1, ))
        self.blocks_multiply_const_vxx_0_0_0_0_0_1 = blocks.multiply_const_vff((0.1, ))
        self.blocks_multiply_const_vxx_0_0_0_0_0_0_0 = blocks.multiply_const_vff((0.1, ))
        self.blocks_float_to_short_0_1_0_0_1 = blocks.float_to_short(1, 32767)
        self.blocks_float_to_short_0_1_0_0_0_0 = blocks.float_to_short(1, 32767)
        self.blocks_float_to_short_0_1 = blocks.float_to_short(1, 32767)
        self.blocks_float_to_short_0_0 = blocks.float_to_short(1, 32767)
        self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, -100000, 1, 0)
        self.analog_pwr_squelch_xx_0_2 = analog.pwr_squelch_cc(sqlch, 1, 1, True)
        self.analog_pwr_squelch_xx_0_0_1 = analog.pwr_squelch_cc(sqlch, 1, 1, True)
        self.analog_pwr_squelch_xx_0_0_0_0_0_1 = analog.pwr_squelch_cc(sqlch, 1, 1, True)
        self.analog_pwr_squelch_xx_0_0_0_0_0_0_0 = analog.pwr_squelch_cc(sqlch, 1, 1, True)
        self.analog_nbfm_rx_0_0_0_0_1 = analog.nbfm_rx(
        	audio_rate=48000,
        	quad_rate=48000,
        	tau=75e-6,
        	max_dev=5000,
          )
        self.analog_nbfm_rx_0_0_0_0_0_0 = analog.nbfm_rx(
        	audio_rate=48000,
        	quad_rate=48000,
        	tau=75e-6,
        	max_dev=5000,
          )
        self.analog_nbfm_rx_0_0 = analog.nbfm_rx(
        	audio_rate=48000,
        	quad_rate=48000,
        	tau=75e-6,
        	max_dev=5000,
          )
        self.analog_nbfm_rx_0 = analog.nbfm_rx(
        	audio_rate=48000,
        	quad_rate=48000,
        	tau=75e-6,
        	max_dev=5000,
          )

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_nbfm_rx_0, 0), (self.blocks_multiply_const_vxx_0_2, 0))
        self.connect((self.analog_nbfm_rx_0_0, 0), (self.blocks_multiply_const_vxx_0_0_1, 0))
        self.connect((self.analog_nbfm_rx_0_0_0_0_0_0, 0), (self.blocks_multiply_const_vxx_0_0_0_0_0_0_0, 0))
        self.connect((self.analog_nbfm_rx_0_0_0_0_1, 0), (self.blocks_multiply_const_vxx_0_0_0_0_0_1, 0))
        self.connect((self.analog_pwr_squelch_xx_0_0_0_0_0_0_0, 0), (self.low_pass_filter_0_0_0_0_0_0, 0))
        self.connect((self.analog_pwr_squelch_xx_0_0_0_0_0_1, 0), (self.low_pass_filter_0_0_0_0_1, 0))
        self.connect((self.analog_pwr_squelch_xx_0_0_1, 0), (self.low_pass_filter_0_0, 0))
        self.connect((self.analog_pwr_squelch_xx_0_2, 0), (self.low_pass_filter_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), (self.blocks_multiply_xx_0_1, 1))
        self.connect((self.blocks_float_to_short_0_0, 0), (self.blocks_udp_sink_0, 0))
        self.connect((self.blocks_float_to_short_0_1, 0), (self.blocks_udp_sink_1, 0))
        self.connect((self.blocks_float_to_short_0_1_0_0_0_0, 0), (self.blocks_udp_sink_3_0_0_0, 0))
        self.connect((self.blocks_float_to_short_0_1_0_0_1, 0), (self.blocks_udp_sink_3_0_1, 0))
        self.connect((self.blocks_multiply_const_vxx_0_0_0_0_0_0_0, 0), (self.blocks_float_to_short_0_1_0_0_0_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0_0_0_0_0_1, 0), (self.blocks_float_to_short_0_1_0_0_1, 0))
        self.connect((self.blocks_multiply_const_vxx_0_0_1, 0), (self.blocks_float_to_short_0_1, 0))
        self.connect((self.blocks_multiply_const_vxx_0_2, 0), (self.blocks_float_to_short_0_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0), (self.freq_xlating_fir_filter_xxx_0_0, 0))
        self.connect((self.blocks_multiply_xx_0_1, 0), (self.freq_xlating_fir_filter_xxx_0_0_0_0_0_0, 0))
        self.connect((self.blocks_multiply_xx_0_1, 0), (self.freq_xlating_fir_filter_xxx_0_0_0_0_1, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.analog_pwr_squelch_xx_0_2, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0_0, 0), (self.analog_pwr_squelch_xx_0_0_1, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0_0_0_0_0_0, 0), (self.analog_pwr_squelch_xx_0_0_0_0_0_0_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0_0_0_0_1, 0), (self.analog_pwr_squelch_xx_0_0_0_0_0_1, 0))
        self.connect((self.low_pass_filter_0, 0), (self.analog_nbfm_rx_0, 0))
        self.connect((self.low_pass_filter_0_0, 0), (self.analog_nbfm_rx_0_0, 0))
        self.connect((self.low_pass_filter_0_0_0_0_0_0, 0), (self.analog_nbfm_rx_0_0_0_0_0_0, 0))
        self.connect((self.low_pass_filter_0_0_0_0_1, 0), (self.analog_nbfm_rx_0_0_0_0_1, 0))
        self.connect((self.osmosdr_source_0, 0), (self.blocks_multiply_xx_0, 0))
        self.connect((self.osmosdr_source_0_0, 0), (self.blocks_multiply_xx_0_1, 0))
Example #46
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="CP v0.1a")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Variables
        ##################################################
        self.freq = freq = 92.9e6
        self.samp_rate = samp_rate = 2.4e6
        self.ch2_volume = ch2_volume = 1
        self.ch2_squelch = ch2_squelch = -30
        self.ch2_mute = ch2_mute = 1
        self.ch2_modulation = ch2_modulation = 0
        self.ch2_invert = ch2_invert = 1
        self.ch2_freq = ch2_freq = freq
        self.ch1_volume = ch1_volume = 1
        self.ch1_squelch = ch1_squelch = -30
        self.ch1_mute = ch1_mute = 1
        self.ch1_modulation = ch1_modulation = 0
        self.ch1_invert = ch1_invert = 1
        self.ch1_freq = ch1_freq = freq

        ##################################################
        # Blocks
        ##################################################
        self.tab = self.tab = wx.Notebook(self.GetWin(), style=wx.NB_TOP)
        self.tab.AddPage(grc_wxgui.Panel(self.tab), "Ch 1")
        self.tab.AddPage(grc_wxgui.Panel(self.tab), "Ch 2")
        self.GridAdd(self.tab, 3, 0, 1, 7)
        self._freq_text_box = forms.text_box(
        	parent=self.GetWin(),
        	value=self.freq,
        	callback=self.set_freq,
        	label="Radio Center Freq",
        	converter=forms.float_converter(),
        )
        self.GridAdd(self._freq_text_box, 19, 0, 1, 10)
        _ch2_volume_sizer = wx.BoxSizer(wx.VERTICAL)
        self._ch2_volume_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_ch2_volume_sizer,
        	value=self.ch2_volume,
        	callback=self.set_ch2_volume,
        	label="Volume",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._ch2_volume_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_ch2_volume_sizer,
        	value=self.ch2_volume,
        	callback=self.set_ch2_volume,
        	minimum=0,
        	maximum=10,
        	num_steps=20,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_ch2_volume_sizer, 2, 2, 1, 1)
        _ch2_squelch_sizer = wx.BoxSizer(wx.VERTICAL)
        self._ch2_squelch_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_ch2_squelch_sizer,
        	value=self.ch2_squelch,
        	callback=self.set_ch2_squelch,
        	label="Squelch",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._ch2_squelch_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_ch2_squelch_sizer,
        	value=self.ch2_squelch,
        	callback=self.set_ch2_squelch,
        	minimum=-70,
        	maximum=0,
        	num_steps=14,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_ch2_squelch_sizer, 2, 3, 1, 1)
        self._ch2_mute_check_box = forms.check_box(
        	parent=self.GetWin(),
        	value=self.ch2_mute,
        	callback=self.set_ch2_mute,
        	label="Mute",
        	true=0,
        	false=1,
        )
        self.GridAdd(self._ch2_mute_check_box, 2, 5, 1, 1)
        self._ch2_modulation_chooser = forms.button(
        	parent=self.GetWin(),
        	value=self.ch2_modulation,
        	callback=self.set_ch2_modulation,
        	label="Modulation",
        	choices=[0, 1],
        	labels=["DMR","NBFM"],
        )
        self.GridAdd(self._ch2_modulation_chooser, 2, 1, 1, 1)
        self._ch2_invert_check_box = forms.check_box(
        	parent=self.GetWin(),
        	value=self.ch2_invert,
        	callback=self.set_ch2_invert,
        	label="Invert",
        	true=-1,
        	false=1,
        )
        self.GridAdd(self._ch2_invert_check_box, 2, 4, 1, 1)
        self._ch2_freq_text_box = forms.text_box(
        	parent=self.GetWin(),
        	value=self.ch2_freq,
        	callback=self.set_ch2_freq,
        	label="Ch2 Freq",
        	converter=forms.float_converter(),
        )
        self.GridAdd(self._ch2_freq_text_box, 2, 0, 1, 1)
        _ch1_volume_sizer = wx.BoxSizer(wx.VERTICAL)
        self._ch1_volume_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_ch1_volume_sizer,
        	value=self.ch1_volume,
        	callback=self.set_ch1_volume,
        	label="Volume",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._ch1_volume_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_ch1_volume_sizer,
        	value=self.ch1_volume,
        	callback=self.set_ch1_volume,
        	minimum=0,
        	maximum=10,
        	num_steps=40,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_ch1_volume_sizer, 0, 2, 1, 1)
        _ch1_squelch_sizer = wx.BoxSizer(wx.VERTICAL)
        self._ch1_squelch_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_ch1_squelch_sizer,
        	value=self.ch1_squelch,
        	callback=self.set_ch1_squelch,
        	label="Squelch",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._ch1_squelch_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_ch1_squelch_sizer,
        	value=self.ch1_squelch,
        	callback=self.set_ch1_squelch,
        	minimum=-70,
        	maximum=0,
        	num_steps=14,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_ch1_squelch_sizer, 0, 3, 1, 1)
        self._ch1_mute_check_box = forms.check_box(
        	parent=self.GetWin(),
        	value=self.ch1_mute,
        	callback=self.set_ch1_mute,
        	label="Mute",
        	true=0,
        	false=1,
        )
        self.GridAdd(self._ch1_mute_check_box, 0, 5, 1, 1)
        self._ch1_modulation_chooser = forms.button(
        	parent=self.GetWin(),
        	value=self.ch1_modulation,
        	callback=self.set_ch1_modulation,
        	label="Modulation",
        	choices=[0, 1],
        	labels=["DMR","NBFM"],
        )
        self.GridAdd(self._ch1_modulation_chooser, 0, 1, 1, 1)
        self._ch1_invert_check_box = forms.check_box(
        	parent=self.GetWin(),
        	value=self.ch1_invert,
        	callback=self.set_ch1_invert,
        	label="Invert",
        	true=-1,
        	false=1,
        )
        self.GridAdd(self._ch1_invert_check_box, 0, 4, 1, 1)
        self._ch1_freq_text_box = forms.text_box(
        	parent=self.GetWin(),
        	value=self.ch1_freq,
        	callback=self.set_ch1_freq,
        	label="Ch1 Freq",
        	converter=forms.float_converter(),
        )
        self.GridAdd(self._ch1_freq_text_box, 0, 0, 1, 1)
        self.wxgui_waterfallsink2_1 = waterfallsink2.waterfall_sink_c(
        	self.GetWin(),
        	baseband_freq=0,
        	dynamic_range=100,
        	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.GridAdd(self.wxgui_waterfallsink2_1.win, 4, 0, 15, 10)
        self.wxgui_fftsink2_0_0 = fftsink2.fft_sink_c(
        	self.tab.GetPage(1).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=15,
        	average=True,
        	avg_alpha=0.1333,
        	title="Channel 2",
        	peak_hold=False,
        )
        self.tab.GetPage(1).GridAdd(self.wxgui_fftsink2_0_0.win, 0, 0, 12, 7)
        self.wxgui_fftsink2_0 = fftsink2.fft_sink_c(
        	self.tab.GetPage(0).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=15,
        	average=True,
        	avg_alpha=0.1333,
        	title="Channel 1",
        	peak_hold=False,
        )
        self.tab.GetPage(0).GridAdd(self.wxgui_fftsink2_0.win, 0, 0, 12, 7)
        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(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(10, 0)
        self.rtlsdr_source_0.set_if_gain(20, 0)
        self.rtlsdr_source_0.set_bb_gain(20, 0)
        self.rtlsdr_source_0.set_antenna("", 0)
        self.rtlsdr_source_0.set_bandwidth(0, 0)
          
        self.rational_resampler_xxx_3_0 = filter.rational_resampler_fff(
                interpolation=48000,
                decimation=8000,
                taps=None,
                fractional_bw=None,
        )
        self.rational_resampler_xxx_3 = filter.rational_resampler_fff(
                interpolation=48000,
                decimation=8000,
                taps=None,
                fractional_bw=None,
        )
        self.rational_resampler_xxx_2_0 = filter.rational_resampler_ccc(
                interpolation=48000,
                decimation=2400000,
                taps=None,
                fractional_bw=None,
        )
        self.rational_resampler_xxx_2 = filter.rational_resampler_ccc(
                interpolation=48000,
                decimation=2400000,
                taps=None,
                fractional_bw=None,
        )
        self.rational_resampler_xxx_0_0 = filter.rational_resampler_ccc(
                interpolation=192000,
                decimation=int(samp_rate),
                taps=None,
                fractional_bw=None,
        )
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
                interpolation=192000,
                decimation=int(samp_rate),
                taps=None,
                fractional_bw=None,
        )
        self.low_pass_filter_1_0 = filter.fir_filter_ccf(1, firdes.low_pass(
        	1, 192000, 5e3, 5e3, firdes.WIN_HAMMING, 6.76))
        self.low_pass_filter_1 = filter.fir_filter_ccf(1, firdes.low_pass(
        	1, 192000, 5e3, 5e3, firdes.WIN_HAMMING, 6.76))
        self.freq_xlating_fft_filter_ccc_0_0 = filter.freq_xlating_fft_filter_ccc(1, (firdes.low_pass(1,samp_rate,200000,10000)), ch2_freq - freq, samp_rate)
        self.freq_xlating_fft_filter_ccc_0_0.set_nthreads(1)
        self.freq_xlating_fft_filter_ccc_0_0.declare_sample_delay(0)
        self.freq_xlating_fft_filter_ccc_0 = filter.freq_xlating_fft_filter_ccc(1, (firdes.low_pass(1,samp_rate,200000,10000)), ch1_freq - freq, samp_rate)
        self.freq_xlating_fft_filter_ccc_0.set_nthreads(1)
        self.freq_xlating_fft_filter_ccc_0.declare_sample_delay(0)
        self.dsd_block_ff_0_0 = dsd.block_ff(dsd.dsd_FRAME_DMR_MOTOTRBO,dsd.dsd_MOD_GFSK,3,True,3)
        self.dsd_block_ff_0 = dsd.block_ff(dsd.dsd_FRAME_DMR_MOTOTRBO,dsd.dsd_MOD_GFSK,3,True,3)
        self.blocks_multiply_const_vxx_2 = blocks.multiply_const_vff((ch2_invert * ch2_mute, ))
        self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vff((ch1_invert * ch1_mute, ))
        self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vff((ch2_volume, ))
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((ch1_volume, ))
        self.blks2_selector_0_1 = grc_blks2.selector(
        	item_size=gr.sizeof_gr_complex*1,
        	num_inputs=1,
        	num_outputs=2,
        	input_index=0,
        	output_index=ch2_modulation,
        )
        self.blks2_selector_0_0_0 = grc_blks2.selector(
        	item_size=gr.sizeof_float*1,
        	num_inputs=2,
        	num_outputs=1,
        	input_index=ch2_modulation,
        	output_index=0,
        )
        self.blks2_selector_0_0 = grc_blks2.selector(
        	item_size=gr.sizeof_float*1,
        	num_inputs=2,
        	num_outputs=1,
        	input_index=ch1_modulation,
        	output_index=0,
        )
        self.blks2_selector_0 = grc_blks2.selector(
        	item_size=gr.sizeof_gr_complex*1,
        	num_inputs=1,
        	num_outputs=2,
        	input_index=0,
        	output_index=ch1_modulation,
        )
        self.audio_sink_0_0 = audio.sink(48000, "", True)
        self.audio_sink_0 = audio.sink(48000, "", True)
        self.analog_quadrature_demod_cf_1_0 = analog.quadrature_demod_cf(1.6)
        self.analog_quadrature_demod_cf_1 = analog.quadrature_demod_cf(1.6)
        self.analog_pwr_squelch_xx_0_0_0 = analog.pwr_squelch_cc(ch2_squelch, 1e-4, 0, True)
        self.analog_pwr_squelch_xx_0_0 = analog.pwr_squelch_cc(ch1_squelch, 1e-4, 0, True)
        self.analog_nbfm_rx_0_0 = analog.nbfm_rx(
        	audio_rate=48000,
        	quad_rate=192000,
        	tau=75e-6,
        	max_dev=2.5e3,
        )
        self.analog_nbfm_rx_0 = analog.nbfm_rx(
        	audio_rate=48000,
        	quad_rate=192000,
        	tau=75e-6,
        	max_dev=2.5e3,
        )

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_nbfm_rx_0, 0), (self.blks2_selector_0_0, 1))    
        self.connect((self.analog_nbfm_rx_0_0, 0), (self.blks2_selector_0_0_0, 1))    
        self.connect((self.analog_pwr_squelch_xx_0_0, 0), (self.blks2_selector_0, 0))    
        self.connect((self.analog_pwr_squelch_xx_0_0_0, 0), (self.blks2_selector_0_1, 0))    
        self.connect((self.analog_quadrature_demod_cf_1, 0), (self.dsd_block_ff_0, 0))    
        self.connect((self.analog_quadrature_demod_cf_1_0, 0), (self.dsd_block_ff_0_0, 0))    
        self.connect((self.blks2_selector_0, 1), (self.rational_resampler_xxx_0, 0))    
        self.connect((self.blks2_selector_0, 0), (self.rational_resampler_xxx_2, 0))    
        self.connect((self.blks2_selector_0_0, 0), (self.blocks_multiply_const_vxx_0, 0))    
        self.connect((self.blks2_selector_0_0_0, 0), (self.blocks_multiply_const_vxx_0_0, 0))    
        self.connect((self.blks2_selector_0_1, 1), (self.rational_resampler_xxx_0_0, 0))    
        self.connect((self.blks2_selector_0_1, 0), (self.rational_resampler_xxx_2_0, 0))    
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_multiply_const_vxx_1, 0))    
        self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.blocks_multiply_const_vxx_2, 0))    
        self.connect((self.blocks_multiply_const_vxx_1, 0), (self.audio_sink_0, 0))    
        self.connect((self.blocks_multiply_const_vxx_2, 0), (self.audio_sink_0_0, 0))    
        self.connect((self.dsd_block_ff_0, 0), (self.rational_resampler_xxx_3, 0))    
        self.connect((self.dsd_block_ff_0_0, 0), (self.rational_resampler_xxx_3_0, 0))    
        self.connect((self.freq_xlating_fft_filter_ccc_0, 0), (self.analog_pwr_squelch_xx_0_0, 0))    
        self.connect((self.freq_xlating_fft_filter_ccc_0, 0), (self.wxgui_fftsink2_0, 0))    
        self.connect((self.freq_xlating_fft_filter_ccc_0_0, 0), (self.analog_pwr_squelch_xx_0_0_0, 0))    
        self.connect((self.freq_xlating_fft_filter_ccc_0_0, 0), (self.wxgui_fftsink2_0_0, 0))    
        self.connect((self.low_pass_filter_1, 0), (self.analog_nbfm_rx_0, 0))    
        self.connect((self.low_pass_filter_1_0, 0), (self.analog_nbfm_rx_0_0, 0))    
        self.connect((self.rational_resampler_xxx_0, 0), (self.low_pass_filter_1, 0))    
        self.connect((self.rational_resampler_xxx_0_0, 0), (self.low_pass_filter_1_0, 0))    
        self.connect((self.rational_resampler_xxx_2, 0), (self.analog_quadrature_demod_cf_1, 0))    
        self.connect((self.rational_resampler_xxx_2_0, 0), (self.analog_quadrature_demod_cf_1_0, 0))    
        self.connect((self.rational_resampler_xxx_3, 0), (self.blks2_selector_0_0, 0))    
        self.connect((self.rational_resampler_xxx_3_0, 0), (self.blks2_selector_0_0_0, 0))    
        self.connect((self.rtlsdr_source_0, 0), (self.freq_xlating_fft_filter_ccc_0, 0))    
        self.connect((self.rtlsdr_source_0, 0), (self.freq_xlating_fft_filter_ccc_0_0, 0))    
        self.connect((self.rtlsdr_source_0, 0), (self.wxgui_waterfallsink2_1, 0))    
Example #47
0
    def __init__(self):
        gr.top_block.__init__(self, "Merapi Vco")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Merapi Vco")
        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", "merapi_vco")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 2.4e6
        self.filt_len = filt_len = 1e6
        self.ch_bw = ch_bw = 30e3
        self.bb_rate = bb_rate = 192e3
        self.audio_rate = audio_rate = 48e3

        ##################################################
        # Blocks
        ##################################################
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
            interpolation=int(bb_rate),
            decimation=int(samp_rate),
            taps=None,
            fractional_bw=None,
        )
        self.qtgui_time_sink_x_2 = qtgui.time_sink_f(
            8192 * 8,  #size
            audio_rate,  #samp_rate
            "",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_2.set_update_time(0.10)
        self.qtgui_time_sink_x_2.set_y_axis(-10, 10)

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

        self.qtgui_time_sink_x_2.enable_tags(-1, True)
        self.qtgui_time_sink_x_2.set_trigger_mode(qtgui.TRIG_MODE_NORM,
                                                  qtgui.TRIG_SLOPE_POS, 8, 0,
                                                  0, "")
        self.qtgui_time_sink_x_2.enable_autoscale(False)
        self.qtgui_time_sink_x_2.enable_grid(False)
        self.qtgui_time_sink_x_2.enable_axis_labels(True)
        self.qtgui_time_sink_x_2.enable_control_panel(False)

        if not True:
            self.qtgui_time_sink_x_2.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_2.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_2.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_2.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_2.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_2.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_2.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_2.set_line_alpha(i, alphas[i])

        self._qtgui_time_sink_x_2_win = sip.wrapinstance(
            self.qtgui_time_sink_x_2.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_time_sink_x_2_win)
        self.qtgui_time_sink_x_1 = qtgui.time_sink_f(
            8192 * 8,  #size
            audio_rate,  #samp_rate
            "",  #name
            2  #number of inputs
        )
        self.qtgui_time_sink_x_1.set_update_time(0.10)
        self.qtgui_time_sink_x_1.set_y_axis(-1, 1)

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

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

        if not True:
            self.qtgui_time_sink_x_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(2):
            if len(labels[i]) == 0:
                self.qtgui_time_sink_x_1.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_1.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_1.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_1.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_1.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_1.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_1.set_line_alpha(i, alphas[i])

        self._qtgui_time_sink_x_1_win = sip.wrapinstance(
            self.qtgui_time_sink_x_1.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_time_sink_x_1_win)
        self.qtgui_time_sink_x_0 = qtgui.time_sink_c(
            1024,  #size
            audio_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(2 * 1):
            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)
        self.qtgui_freq_sink_x_1 = qtgui.freq_sink_c(
            8192,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            bb_rate,  #bw
            "",  #name
            1  #number of inputs
        )
        self.qtgui_freq_sink_x_1.set_update_time(0.10)
        self.qtgui_freq_sink_x_1.set_y_axis(-100, -20)
        self.qtgui_freq_sink_x_1.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0,
                                                  "")
        self.qtgui_freq_sink_x_1.enable_autoscale(False)
        self.qtgui_freq_sink_x_1.enable_grid(False)
        self.qtgui_freq_sink_x_1.set_fft_average(0.2)
        self.qtgui_freq_sink_x_1.enable_axis_labels(True)
        self.qtgui_freq_sink_x_1.enable_control_panel(False)

        if not True:
            self.qtgui_freq_sink_x_1.disable_legend()

        if "complex" == "float" or "complex" == "msg_float":
            self.qtgui_freq_sink_x_1.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_1.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_freq_sink_x_1.set_line_label(i, labels[i])
            self.qtgui_freq_sink_x_1.set_line_width(i, widths[i])
            self.qtgui_freq_sink_x_1.set_line_color(i, colors[i])
            self.qtgui_freq_sink_x_1.set_line_alpha(i, alphas[i])

        self._qtgui_freq_sink_x_1_win = sip.wrapinstance(
            self.qtgui_freq_sink_x_1.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_freq_sink_x_1_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(166.3e6, 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(49, 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.fft_filter_xxx_3 = filter.fft_filter_fff(
            1, (firdes.low_pass(1, audio_rate, 100, 100, firdes.WIN_BLACKMAN)),
            1)
        self.fft_filter_xxx_3.declare_sample_delay(0)
        self.fft_filter_xxx_2 = filter.fft_filter_ccc(
            1, (firdes.complex_band_pass(1, audio_rate, 360, 2360, 1e3,
                                         firdes.WIN_BLACKMAN)), 1)
        self.fft_filter_xxx_2.declare_sample_delay(0)
        self.fft_filter_xxx_1 = filter.fft_filter_ccc(1, (firdes.low_pass(
            1, bb_rate, ch_bw / 2, ch_bw / 10, firdes.WIN_BLACKMAN)), 1)
        self.fft_filter_xxx_1.declare_sample_delay(0)
        self.fft_filter_xxx_0 = filter.fft_filter_ccc(1, (firdes.low_pass(
            1, samp_rate, bb_rate / 2, bb_rate / 10, firdes.WIN_BLACKMAN)), 1)
        self.fft_filter_xxx_0.declare_sample_delay(0)
        self.blocks_sub_xx_0 = blocks.sub_ff(1)
        self.blocks_rotator_cc_0 = blocks.rotator_cc(502e3 / samp_rate * 2 *
                                                     math.pi)
        self.blocks_moving_average_xx_0 = blocks.moving_average_ff(
            int(filt_len), 1 / filt_len, 4000)
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(
            audio_rate / (2 * math.pi * 1e3 / 8.0))
        self.analog_nbfm_rx_0 = analog.nbfm_rx(
            audio_rate=int(audio_rate),
            quad_rate=int(bb_rate),
            tau=75e-6,
            max_dev=5e3,
        )

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_nbfm_rx_0, 0),
                     (self.blocks_float_to_complex_0, 0))
        self.connect((self.analog_quadrature_demod_cf_0, 0),
                     (self.blocks_moving_average_xx_0, 0))
        self.connect((self.analog_quadrature_demod_cf_0, 0),
                     (self.blocks_sub_xx_0, 0))
        self.connect((self.blocks_float_to_complex_0, 0),
                     (self.fft_filter_xxx_2, 0))
        self.connect((self.blocks_float_to_complex_0, 0),
                     (self.qtgui_time_sink_x_0, 0))
        self.connect((self.blocks_moving_average_xx_0, 0),
                     (self.blocks_sub_xx_0, 1))
        self.connect((self.blocks_rotator_cc_0, 0), (self.fft_filter_xxx_0, 0))
        self.connect((self.blocks_sub_xx_0, 0), (self.fft_filter_xxx_3, 0))
        self.connect((self.blocks_sub_xx_0, 0), (self.qtgui_time_sink_x_1, 0))
        self.connect((self.fft_filter_xxx_0, 0),
                     (self.rational_resampler_xxx_0, 0))
        self.connect((self.fft_filter_xxx_1, 0), (self.analog_nbfm_rx_0, 0))
        self.connect((self.fft_filter_xxx_2, 0),
                     (self.analog_quadrature_demod_cf_0, 0))
        self.connect((self.fft_filter_xxx_3, 0), (self.qtgui_time_sink_x_1, 1))
        self.connect((self.fft_filter_xxx_3, 0), (self.qtgui_time_sink_x_2, 0))
        self.connect((self.osmosdr_source_0, 0), (self.blocks_rotator_cc_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.fft_filter_xxx_1, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.qtgui_freq_sink_x_1, 0))
Example #48
0
    def __init__(self):
        gr.top_block.__init__(self, "Fm Fdb A")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Fm Fdb A")
        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_A")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.volume = volume = 0.5
        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, 0.5, 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(2.45e9, 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(5e9, 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(
            (volume, ))
        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))
Example #49
0
    def __init__(self):
        gr.top_block.__init__(self, "TJ Groundstation No Gui with Control and IQ streaming")

        ##################################################
        # Variables
        ##################################################
        self.interp = interp = 4
        self.audio_rate = audio_rate = 48000
        self.tx_gain = tx_gain = 10
        self.rx_downsamp_bw = rx_downsamp_bw = 10000
        self.rf_tx_rate = rf_tx_rate = audio_rate*interp
        self.rf_rx_rate = rf_rx_rate = 192000
        self.preamble_len = preamble_len = 300
        self.groundstation_zmq_port_4 = groundstation_zmq_port_4 = "5504"
        self.groundstation_zmq_port_3 = groundstation_zmq_port_3 = "5503"
        self.groundstation_zmq_port_2 = groundstation_zmq_port_2 = "5502"
        self.groundstation_zmq_port_1 = groundstation_zmq_port_1 = "5501"
        self.groundstation_port_2 = groundstation_port_2 = "5557"
        self.groundstation_port_1 = groundstation_port_1 = "5555"
        self.groundstation_ip_addr = groundstation_ip_addr = "192.168.1.10"
        self.groundstation_controller_ip = groundstation_controller_ip = "192.268.1.3"
        self.gain = gain = 40
        self.freq = freq = 144.39e6
        self.baud_rate = baud_rate = 1200
        self.audio_line_driver = audio_line_driver = .8
        self.Decay = Decay = 0.8
        self.Attack = Attack = 0.8

        ##################################################
        # Blocks
        ##################################################
        self.zeromq_push_sink_0_0_0_0 = zeromq.push_sink(gr.sizeof_float, 1, "tcp://"+groundstation_ip_addr+":"+groundstation_zmq_port_4, 100, False, -1)
        self.zeromq_push_sink_0_0_0 = zeromq.push_sink(gr.sizeof_float, 1, "tcp://"+groundstation_ip_addr+":"+groundstation_zmq_port_3, 100, False, -1)
        self.zeromq_push_sink_0_0 = zeromq.push_sink(gr.sizeof_gr_complex, 1, "tcp://"+groundstation_ip_addr+":"+groundstation_zmq_port_2, 100, False, -1)
        self.zeromq_push_sink_0 = zeromq.push_sink(gr.sizeof_gr_complex, 1, "tcp://"+groundstation_ip_addr+":"+groundstation_zmq_port_1, 100, False, -1)
        self.uhd_usrp_source_0_1 = uhd.usrp_source(
        	",".join(("", "")),
        	uhd.stream_args(
        		cpu_format="fc32",
        		channels=range(1),
        	),
        )
        self.uhd_usrp_source_0_1.set_samp_rate(rf_rx_rate)
        self.uhd_usrp_source_0_1.set_center_freq(freq, 0)
        self.uhd_usrp_source_0_1.set_gain(gain, 0)
        self.uhd_usrp_source_0_1.set_antenna('RX2', 0)
        self.uhd_usrp_source_0_1.set_bandwidth(rf_rx_rate, 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(rf_tx_rate)
        self.uhd_usrp_sink_0.set_center_freq(freq, 0)
        self.uhd_usrp_sink_0.set_gain(tx_gain, 0)
        self.uhd_usrp_sink_0.set_antenna('TX/RX', 0)
        self.uhd_usrp_sink_0.set_bandwidth(rf_tx_rate, 0)
        self.rational_resampler_xxx_0_0 = filter.rational_resampler_ccc(
                interpolation=4,
                decimation=1,
                taps=None,
                fractional_bw=None,
        )
        self.low_pass_filter_0_0 = filter.fir_filter_ccf(4, firdes.low_pass(
        	1, rf_rx_rate, rx_downsamp_bw/2, 1000, firdes.WIN_HAMMING, 6.76))
        self.detectMarkSpace_1_0_0 = detectMarkSpace(
            Frequency=2200,
            attack=Attack,
            decay=Decay,
            samp_rate=audio_rate,
        )
        self.detectMarkSpace_0_0_0 = detectMarkSpace(
            Frequency=1200,
            attack=Attack,
            decay=Decay,
            samp_rate=audio_rate,
        )
        self.bruninga_str_to_aprs_0 = bruninga.str_to_aprs('KN4DTQ', 'KN4DTQ', [])
        self.bruninga_ax25_fsk_mod_0 = bruninga.ax25_fsk_mod(audio_rate, preamble_len, 5, 2200, 1200, baud_rate)
        self.blocks_udp_sink_0_0 = blocks.udp_sink(gr.sizeof_char*1, groundstation_controller_ip, int(groundstation_port_2), 1472, True)
        self.blocks_sub_xx_0_0_0_0 = blocks.sub_ff(1)
        self.blocks_socket_pdu_0_0 = blocks.socket_pdu("UDP_SERVER", groundstation_ip_addr, groundstation_port_1, 10000, False)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((0.8, ))
        self.analog_nbfm_tx_0 = analog.nbfm_tx(
        	audio_rate=audio_rate,
        	quad_rate=audio_rate,
        	tau=75e-6,
        	max_dev=5e3,
        	fh=-1.0,
                )
        self.analog_nbfm_rx_0_0 = analog.nbfm_rx(
        	audio_rate=audio_rate,
        	quad_rate=audio_rate,
        	tau=75e-6,
        	max_dev=5e3,
          )
        self.afsk_ax25decode_1_0 = afsk.ax25decode(audio_rate, 1)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_socket_pdu_0_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.afsk_ax25decode_1_0, 0), (self.blocks_udp_sink_0_0, 0))
        self.connect((self.analog_nbfm_rx_0_0, 0), (self.detectMarkSpace_0_0_0, 0))
        self.connect((self.analog_nbfm_rx_0_0, 0), (self.detectMarkSpace_1_0_0, 0))
        self.connect((self.analog_nbfm_rx_0_0, 0), (self.zeromq_push_sink_0_0_0_0, 0))
        self.connect((self.analog_nbfm_tx_0, 0), (self.rational_resampler_xxx_0_0, 0))
        self.connect((self.analog_nbfm_tx_0, 0), (self.zeromq_push_sink_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.analog_nbfm_tx_0, 0))
        self.connect((self.blocks_sub_xx_0_0_0_0, 0), (self.afsk_ax25decode_1_0, 0))
        self.connect((self.bruninga_ax25_fsk_mod_0, 0), (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.bruninga_ax25_fsk_mod_0, 0), (self.zeromq_push_sink_0_0_0, 0))
        self.connect((self.detectMarkSpace_0_0_0, 0), (self.blocks_sub_xx_0_0_0_0, 0))
        self.connect((self.detectMarkSpace_1_0_0, 0), (self.blocks_sub_xx_0_0_0_0, 1))
        self.connect((self.low_pass_filter_0_0, 0), (self.analog_nbfm_rx_0_0, 0))
        self.connect((self.low_pass_filter_0_0, 0), (self.zeromq_push_sink_0_0, 0))
        self.connect((self.rational_resampler_xxx_0_0, 0), (self.uhd_usrp_sink_0, 0))
        self.connect((self.uhd_usrp_source_0_1, 0), (self.low_pass_filter_0_0, 0))
    def __init__(self):
        gr.top_block.__init__(self, "FM radio FFT example")

        ##################################################
        # Variables
        ##################################################
        self.variable_sample_rate_0 = variable_sample_rate_0 = 1e6
        self.samp_rate = samp_rate = 44100
        self.xlatecenter_8 = xlatecenter_8 = 0
        self.xlatecenter_7 = xlatecenter_7 = 0
        self.xlatecenter_6 = xlatecenter_6 = 0
        self.xlatecenter_5 = xlatecenter_5 = 0
        self.xlatecenter_4 = xlatecenter_4 = 0
        self.xlatecenter_3 = xlatecenter_3 = 0
        self.xlatecenter_2 = xlatecenter_2 = 0
        self.xlatecenter = xlatecenter = 0
        self.xlate_filter2 = xlate_filter2 = firdes.low_pass(1, samp_rate, 4000, 1000, firdes.WIN_HAMMING, 6.76)
        self.xlate_filter = xlate_filter = firdes.low_pass(1, variable_sample_rate_0, 125000, 25000, firdes.WIN_HAMMING, 6.76)
        self.variable_1 = variable_1 = 0
        self.transition = transition = 1e6
        self.rri = rri = 441
        self.rrd = rrd = 500
        self.quadrature = quadrature = 500000
        self.pscfshift = pscfshift = 0
        self.pscf8 = pscf8 = 0
        self.pscf7 = pscf7 = 0
        self.pscf6 = pscf6 = 0
        self.pscf5 = pscf5 = 0
        self.pscf4 = pscf4 = 0
        self.pscf3 = pscf3 = 0
        self.pscf2 = pscf2 = 0
        self.pscf1 = pscf1 = 0
        self.globaltune = globaltune = 0
        self.cutoff = cutoff = 1e5
        self.bptrans = bptrans = 100
        self.bpsr = bpsr = 200000
        self.bplow_4 = bplow_4 = 100
        self.bplow_3 = bplow_3 = 100
        self.bplow_2 = bplow_2 = 100
        self.bplow_1 = bplow_1 = 100
        self.bphi_4 = bphi_4 = 2.8e3
        self.bphi_3 = bphi_3 = 2.8e3
        self.bphi_2 = bphi_2 = 2.8e3
        self.bphi_1 = bphi_1 = 2.8e3
        self.audio_interp = audio_interp = 4
        self.amp_8 = amp_8 = 0
        self.amp_7 = amp_7 = 0
        self.amp_6 = amp_6 = 0
        self.amp_5 = amp_5 = 0
        self.amp_4 = amp_4 = 0
        self.amp_3 = amp_3 = 0
        self.amp_2 = amp_2 = 0
        self.amp_1 = amp_1 = 0
        self.RF_Gain = RF_Gain = 35
        self.CF = CF = 125.6e6

        ##################################################
        # Blocks
        ##################################################
        self.rational_resampler_xxx_1_0_1_0_0_2 = filter.rational_resampler_fff(
                interpolation=rri,
                decimation=rrd,
                taps=None,
                fractional_bw=None,
        )
        self.rational_resampler_xxx_1_0_1_0_0_1 = filter.rational_resampler_fff(
                interpolation=rri,
                decimation=rrd,
                taps=None,
                fractional_bw=None,
        )
        self.rational_resampler_xxx_1_0_1_0_0_0 = filter.rational_resampler_fff(
                interpolation=rri,
                decimation=rrd,
                taps=None,
                fractional_bw=None,
        )
        self.rational_resampler_xxx_1_0_1_0_0 = filter.rational_resampler_fff(
                interpolation=rri,
                decimation=rrd,
                taps=None,
                fractional_bw=None,
        )
        self.rational_resampler_xxx_1_0_1_0 = filter.rational_resampler_fff(
                interpolation=rri,
                decimation=rrd,
                taps=None,
                fractional_bw=None,
        )
        self.rational_resampler_xxx_1_0_1 = filter.rational_resampler_fff(
                interpolation=rri,
                decimation=rrd,
                taps=None,
                fractional_bw=None,
        )
        self.rational_resampler_xxx_1_0_0_1 = filter.rational_resampler_ccc(
                interpolation=rri,
                decimation=rrd,
                taps=None,
                fractional_bw=None,
        )
        self.rational_resampler_xxx_1_0_0_0_0_0_2 = filter.rational_resampler_ccc(
                interpolation=rri,
                decimation=rrd,
                taps=None,
                fractional_bw=None,
        )
        self.rational_resampler_xxx_1_0_0_0_0_0_1 = filter.rational_resampler_ccc(
                interpolation=rri,
                decimation=rrd,
                taps=None,
                fractional_bw=None,
        )
        self.rational_resampler_xxx_1_0_0_0_0_0_0 = filter.rational_resampler_ccc(
                interpolation=rri,
                decimation=rrd,
                taps=None,
                fractional_bw=None,
        )
        self.rational_resampler_xxx_1_0_0_0_0_0 = filter.rational_resampler_ccc(
                interpolation=rri,
                decimation=rrd,
                taps=None,
                fractional_bw=None,
        )
        self.rational_resampler_xxx_1_0_0_0_0 = filter.rational_resampler_ccc(
                interpolation=rri,
                decimation=rrd,
                taps=None,
                fractional_bw=None,
        )
        self.rational_resampler_xxx_1_0_0_0 = filter.rational_resampler_ccc(
                interpolation=rri,
                decimation=rrd,
                taps=None,
                fractional_bw=None,
        )
        self.rational_resampler_xxx_1_0_0 = filter.rational_resampler_ccc(
                interpolation=rri,
                decimation=rrd,
                taps=None,
                fractional_bw=None,
        )
        self.rational_resampler_xxx_1_0 = filter.rational_resampler_fff(
                interpolation=rri,
                decimation=rrd,
                taps=None,
                fractional_bw=None,
        )
        self.rational_resampler_xxx_0 = filter.rational_resampler_fff(
                interpolation=rri,
                decimation=rrd,
                taps=None,
                fractional_bw=None,
        )
        self.freq_xlating_fir_filter_xxx_1_1_0_0_0_2 = filter.freq_xlating_fir_filter_ccc(1, (1, ), pscf8+pscfshift, samp_rate)
        self.freq_xlating_fir_filter_xxx_1_1_0_0_0_1 = filter.freq_xlating_fir_filter_ccc(1, (1, ), pscf7+pscfshift, samp_rate)
        self.freq_xlating_fir_filter_xxx_1_1_0_0_0_0 = filter.freq_xlating_fir_filter_ccc(1, (1, ), pscf6+pscfshift, samp_rate)
        self.freq_xlating_fir_filter_xxx_1_1_0_0_0 = filter.freq_xlating_fir_filter_ccc(1, (1, ), pscf5+pscfshift, samp_rate)
        self.freq_xlating_fir_filter_xxx_1_1_0_0 = filter.freq_xlating_fir_filter_ccc(1, (1, ), pscf4+pscfshift, samp_rate)
        self.freq_xlating_fir_filter_xxx_1_1_0 = filter.freq_xlating_fir_filter_ccc(1, (1, ), pscf3+pscfshift, samp_rate)
        self.freq_xlating_fir_filter_xxx_1_1 = filter.freq_xlating_fir_filter_ccc(1, (1, ), pscf2+pscfshift, samp_rate)
        self.freq_xlating_fir_filter_xxx_1_0_0_0_0_0_2 = filter.freq_xlating_fir_filter_fcc(1, (1, ), pscf8+pscfshift, samp_rate)
        self.freq_xlating_fir_filter_xxx_1_0_0_0_0_0_1 = filter.freq_xlating_fir_filter_fcc(1, (1, ), pscf7+pscfshift, samp_rate)
        self.freq_xlating_fir_filter_xxx_1_0_0_0_0_0_0 = filter.freq_xlating_fir_filter_fcc(1, (1, ), pscf6+pscfshift, samp_rate)
        self.freq_xlating_fir_filter_xxx_1_0_0_0_0_0 = filter.freq_xlating_fir_filter_fcc(1, (1, ), pscf5+pscfshift, samp_rate)
        self.freq_xlating_fir_filter_xxx_1_0_0_0_0 = filter.freq_xlating_fir_filter_fcc(1, (1, ), pscf4+pscfshift, samp_rate)
        self.freq_xlating_fir_filter_xxx_1_0_0_0 = filter.freq_xlating_fir_filter_fcc(1, (1, ), pscf3+pscfshift, samp_rate)
        self.freq_xlating_fir_filter_xxx_1_0_0 = filter.freq_xlating_fir_filter_fcc(1, (1, ), pscf2+pscfshift, samp_rate)
        self.freq_xlating_fir_filter_xxx_1_0 = filter.freq_xlating_fir_filter_fcc(1, (1, ), pscf1+pscfshift, samp_rate)
        self.freq_xlating_fir_filter_xxx_1 = filter.freq_xlating_fir_filter_ccc(1, (1, ), pscf1+pscfshift, samp_rate)
        self.freq_xlating_fir_filter_xxx_0_1 = filter.freq_xlating_fir_filter_ccc(5, (xlate_filter), xlatecenter_3+globaltune, variable_sample_rate_0)
        self.freq_xlating_fir_filter_xxx_0_0_0_0_2 = filter.freq_xlating_fir_filter_ccc(5, (xlate_filter), xlatecenter_8+globaltune, variable_sample_rate_0)
        self.freq_xlating_fir_filter_xxx_0_0_0_0_1 = filter.freq_xlating_fir_filter_ccc(5, (xlate_filter), xlatecenter_7+globaltune, variable_sample_rate_0)
        self.freq_xlating_fir_filter_xxx_0_0_0_0_0 = filter.freq_xlating_fir_filter_ccc(5, (xlate_filter), xlatecenter_6+globaltune, variable_sample_rate_0)
        self.freq_xlating_fir_filter_xxx_0_0_0_0 = filter.freq_xlating_fir_filter_ccc(5, (xlate_filter), xlatecenter_5+globaltune, variable_sample_rate_0)
        self.freq_xlating_fir_filter_xxx_0_0_0 = filter.freq_xlating_fir_filter_ccc(5, (xlate_filter), xlatecenter_4+globaltune, variable_sample_rate_0)
        self.freq_xlating_fir_filter_xxx_0_0 = filter.freq_xlating_fir_filter_ccc(5, (xlate_filter), xlatecenter_2+globaltune, variable_sample_rate_0)
        self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(5, (xlate_filter), xlatecenter+globaltune, variable_sample_rate_0)
        self.blocks_multiply_const_vxx_0_1 = blocks.multiply_const_vff((amp_1, ))
        self.blocks_multiply_const_vxx_0_0_2 = blocks.multiply_const_vff((amp_2, ))
        self.blocks_multiply_const_vxx_0_0_1_1_2 = blocks.multiply_const_vff((amp_8, ))
        self.blocks_multiply_const_vxx_0_0_1_1_1 = blocks.multiply_const_vff((amp_7, ))
        self.blocks_multiply_const_vxx_0_0_1_1_0 = blocks.multiply_const_vff((amp_6, ))
        self.blocks_multiply_const_vxx_0_0_1_1 = blocks.multiply_const_vff((amp_5, ))
        self.blocks_multiply_const_vxx_0_0_1_0_0_2 = blocks.multiply_const_vff((amp_8, ))
        self.blocks_multiply_const_vxx_0_0_1_0_0_1 = blocks.multiply_const_vff((amp_7, ))
        self.blocks_multiply_const_vxx_0_0_1_0_0_0 = blocks.multiply_const_vff((amp_6, ))
        self.blocks_multiply_const_vxx_0_0_1_0_0 = blocks.multiply_const_vff((amp_5, ))
        self.blocks_multiply_const_vxx_0_0_1_0 = blocks.multiply_const_vff((amp_4, ))
        self.blocks_multiply_const_vxx_0_0_1 = blocks.multiply_const_vff((amp_4, ))
        self.blocks_multiply_const_vxx_0_0_0_0 = blocks.multiply_const_vff((amp_3, ))
        self.blocks_multiply_const_vxx_0_0_0 = blocks.multiply_const_vff((amp_3, ))
        self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vff((amp_2, ))
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((amp_1, ))
        self.blocks_complex_to_float_7 = blocks.complex_to_float(1)
        self.blocks_complex_to_float_6_0_2 = blocks.complex_to_float(1)
        self.blocks_complex_to_float_6_0_1 = blocks.complex_to_float(1)
        self.blocks_complex_to_float_6_0_0 = blocks.complex_to_float(1)
        self.blocks_complex_to_float_6_0 = blocks.complex_to_float(1)
        self.blocks_complex_to_float_6 = blocks.complex_to_float(1)
        self.blocks_complex_to_float_5_0_2 = blocks.complex_to_float(1)
        self.blocks_complex_to_float_5_0_1 = blocks.complex_to_float(1)
        self.blocks_complex_to_float_5_0_0 = blocks.complex_to_float(1)
        self.blocks_complex_to_float_5_0 = blocks.complex_to_float(1)
        self.blocks_complex_to_float_5 = blocks.complex_to_float(1)
        self.blocks_complex_to_float_4 = blocks.complex_to_float(1)
        self.blocks_complex_to_float_3 = blocks.complex_to_float(1)
        self.blocks_complex_to_float_2 = blocks.complex_to_float(1)
        self.blocks_complex_to_float_1 = blocks.complex_to_float(1)
        self.blocks_complex_to_float_0 = blocks.complex_to_float(1)
        self.blocks_add_xx_1_1_0_0_0 = blocks.add_vff(1)
        self.blocks_add_xx_1_1_0_0 = blocks.add_vff(1)
        self.blocks_add_xx_1_1_0 = blocks.add_vff(1)
        self.blocks_add_xx_1_1 = blocks.add_vff(1)
        self.blocks_add_xx_1_0 = blocks.add_vff(1)
        self.blocks_add_xx_1 = blocks.add_vff(1)
        self.band_pass_filter_0_0_0_0_1 = filter.fir_filter_ccf(4, firdes.band_pass(
        	1, bpsr, bplow_3, bphi_3, bptrans, firdes.WIN_HAMMING, 6.76))
        self.band_pass_filter_0_0_0_0_0_0_0_2 = filter.fir_filter_ccf(4, firdes.band_pass(
        	1, bpsr, bplow_4, bphi_4, bptrans, firdes.WIN_HAMMING, 6.76))
        self.band_pass_filter_0_0_0_0_0_0_0_1 = filter.fir_filter_ccf(4, firdes.band_pass(
        	1, bpsr, bplow_4, bphi_4, bptrans, firdes.WIN_HAMMING, 6.76))
        self.band_pass_filter_0_0_0_0_0_0_0_0 = filter.fir_filter_ccf(4, firdes.band_pass(
        	1, bpsr, bplow_4, bphi_4, bptrans, firdes.WIN_HAMMING, 6.76))
        self.band_pass_filter_0_0_0_0_0_0_0 = filter.fir_filter_ccf(4, firdes.band_pass(
        	1, bpsr, bplow_4, bphi_4, bptrans, firdes.WIN_HAMMING, 6.76))
        self.band_pass_filter_0_0_0_0_0_0 = filter.fir_filter_ccf(4, firdes.band_pass(
        	1, bpsr, bplow_4, bphi_4, bptrans, firdes.WIN_HAMMING, 6.76))
        self.band_pass_filter_0_0_0_0_0 = filter.fir_filter_ccf(4, firdes.band_pass(
        	1, bpsr, bplow_2, bphi_2, bptrans, firdes.WIN_HAMMING, 6.76))
        self.band_pass_filter_0_0_0_0 = filter.fir_filter_ccf(4, firdes.band_pass(
        	1, bpsr, bplow_1, bphi_1, bptrans, firdes.WIN_HAMMING, 6.76))
        self.audio_sink_4 = audio.sink(44100, "Radio:AM2", True)
        self.audio_sink_3 = audio.sink(44100, "Radio:NFM2", True)
        self.audio_sink_2 = audio.sink(44100, "Radio:AM1", True)
        self.audio_sink_1 = audio.sink(44100, "Radio:NFM1", True)
        self.analog_nbfm_rx_0_0_1 = analog.nbfm_rx(
        	audio_rate=50000,
        	quad_rate=int(variable_sample_rate_0/5),
        	tau=75e-6,
        	max_dev=12500,
        )
        self.analog_nbfm_rx_0_0_0_0_0_2 = analog.nbfm_rx(
        	audio_rate=50000,
        	quad_rate=int(variable_sample_rate_0/5),
        	tau=75e-6,
        	max_dev=12500,
        )
        self.analog_nbfm_rx_0_0_0_0_0_1 = analog.nbfm_rx(
        	audio_rate=50000,
        	quad_rate=int(variable_sample_rate_0/5),
        	tau=75e-6,
        	max_dev=12500,
        )
        self.analog_nbfm_rx_0_0_0_0_0_0 = analog.nbfm_rx(
        	audio_rate=50000,
        	quad_rate=int(variable_sample_rate_0/5),
        	tau=75e-6,
        	max_dev=12500,
        )
        self.analog_nbfm_rx_0_0_0_0_0 = analog.nbfm_rx(
        	audio_rate=50000,
        	quad_rate=int(variable_sample_rate_0/5),
        	tau=75e-6,
        	max_dev=12500,
        )
        self.analog_nbfm_rx_0_0_0_0 = analog.nbfm_rx(
        	audio_rate=50000,
        	quad_rate=int(variable_sample_rate_0/5),
        	tau=75e-6,
        	max_dev=12500,
        )
        self.analog_nbfm_rx_0_0_0 = analog.nbfm_rx(
        	audio_rate=50000,
        	quad_rate=int(variable_sample_rate_0/5),
        	tau=75e-6,
        	max_dev=12500,
        )
        self.analog_nbfm_rx_0_0 = analog.nbfm_rx(
        	audio_rate=50000,
        	quad_rate=int(variable_sample_rate_0/5),
        	tau=75e-6,
        	max_dev=12500,
        )
        self.RTL820T = osmosdr.source( args="numchan=" + str(1) + " " + "" )
        self.RTL820T.set_sample_rate(variable_sample_rate_0)
        self.RTL820T.set_center_freq(CF, 0)
        self.RTL820T.set_freq_corr(0, 0)
        self.RTL820T.set_dc_offset_mode(2, 0)
        self.RTL820T.set_iq_balance_mode(0, 0)
        self.RTL820T.set_gain_mode(False, 0)
        self.RTL820T.set_gain(RF_Gain, 0)
        self.RTL820T.set_if_gain(20, 0)
        self.RTL820T.set_bb_gain(20, 0)
        self.RTL820T.set_antenna("", 0)
        self.RTL820T.set_bandwidth(1e6, 0)
          

        ##################################################
        # Connections
        ##################################################
        self.connect((self.RTL820T, 0), (self.freq_xlating_fir_filter_xxx_0, 0))    
        self.connect((self.RTL820T, 0), (self.freq_xlating_fir_filter_xxx_0_0, 0))    
        self.connect((self.RTL820T, 0), (self.freq_xlating_fir_filter_xxx_0_0_0, 0))    
        self.connect((self.RTL820T, 0), (self.freq_xlating_fir_filter_xxx_0_0_0_0, 0))    
        self.connect((self.RTL820T, 0), (self.freq_xlating_fir_filter_xxx_0_0_0_0_0, 0))    
        self.connect((self.RTL820T, 0), (self.freq_xlating_fir_filter_xxx_0_0_0_0_1, 0))    
        self.connect((self.RTL820T, 0), (self.freq_xlating_fir_filter_xxx_0_0_0_0_2, 0))    
        self.connect((self.RTL820T, 0), (self.freq_xlating_fir_filter_xxx_0_1, 0))    
        self.connect((self.analog_nbfm_rx_0_0, 0), (self.rational_resampler_xxx_1_0, 0))    
        self.connect((self.analog_nbfm_rx_0_0_0, 0), (self.rational_resampler_xxx_1_0_1, 0))    
        self.connect((self.analog_nbfm_rx_0_0_0_0, 0), (self.rational_resampler_xxx_1_0_1_0, 0))    
        self.connect((self.analog_nbfm_rx_0_0_0_0_0, 0), (self.rational_resampler_xxx_1_0_1_0_0, 0))    
        self.connect((self.analog_nbfm_rx_0_0_0_0_0_0, 0), (self.rational_resampler_xxx_1_0_1_0_0_0, 0))    
        self.connect((self.analog_nbfm_rx_0_0_0_0_0_1, 0), (self.rational_resampler_xxx_1_0_1_0_0_1, 0))    
        self.connect((self.analog_nbfm_rx_0_0_0_0_0_2, 0), (self.rational_resampler_xxx_1_0_1_0_0_2, 0))    
        self.connect((self.analog_nbfm_rx_0_0_1, 0), (self.rational_resampler_xxx_0, 0))    
        self.connect((self.band_pass_filter_0_0_0_0, 0), (self.rational_resampler_xxx_1_0_0, 0))    
        self.connect((self.band_pass_filter_0_0_0_0_0, 0), (self.rational_resampler_xxx_1_0_0_0, 0))    
        self.connect((self.band_pass_filter_0_0_0_0_0_0, 0), (self.rational_resampler_xxx_1_0_0_0_0, 0))    
        self.connect((self.band_pass_filter_0_0_0_0_0_0_0, 0), (self.rational_resampler_xxx_1_0_0_0_0_0, 0))    
        self.connect((self.band_pass_filter_0_0_0_0_0_0_0_0, 0), (self.rational_resampler_xxx_1_0_0_0_0_0_0, 0))    
        self.connect((self.band_pass_filter_0_0_0_0_0_0_0_1, 0), (self.rational_resampler_xxx_1_0_0_0_0_0_1, 0))    
        self.connect((self.band_pass_filter_0_0_0_0_0_0_0_2, 0), (self.rational_resampler_xxx_1_0_0_0_0_0_2, 0))    
        self.connect((self.band_pass_filter_0_0_0_0_1, 0), (self.rational_resampler_xxx_1_0_0_1, 0))    
        self.connect((self.blocks_add_xx_1, 0), (self.audio_sink_1, 0))    
        self.connect((self.blocks_add_xx_1_0, 0), (self.audio_sink_2, 0))    
        self.connect((self.blocks_add_xx_1_1, 0), (self.audio_sink_3, 0))    
        self.connect((self.blocks_add_xx_1_1_0, 0), (self.audio_sink_4, 0))    
        self.connect((self.blocks_add_xx_1_1_0_0, 0), (self.blocks_add_xx_1_1, 2))    
        self.connect((self.blocks_add_xx_1_1_0_0_0, 0), (self.blocks_add_xx_1_1_0, 2))    
        self.connect((self.blocks_complex_to_float_0, 0), (self.blocks_multiply_const_vxx_0, 0))    
        self.connect((self.blocks_complex_to_float_1, 0), (self.blocks_multiply_const_vxx_0_1, 0))    
        self.connect((self.blocks_complex_to_float_2, 0), (self.blocks_multiply_const_vxx_0_0, 0))    
        self.connect((self.blocks_complex_to_float_3, 0), (self.blocks_multiply_const_vxx_0_0_2, 0))    
        self.connect((self.blocks_complex_to_float_4, 0), (self.blocks_multiply_const_vxx_0_0_0_0, 0))    
        self.connect((self.blocks_complex_to_float_5, 0), (self.blocks_multiply_const_vxx_0_0_1_0, 0))    
        self.connect((self.blocks_complex_to_float_5_0, 0), (self.blocks_multiply_const_vxx_0_0_1_0_0, 0))    
        self.connect((self.blocks_complex_to_float_5_0_0, 0), (self.blocks_multiply_const_vxx_0_0_1_0_0_0, 0))    
        self.connect((self.blocks_complex_to_float_5_0_1, 0), (self.blocks_multiply_const_vxx_0_0_1_0_0_1, 0))    
        self.connect((self.blocks_complex_to_float_5_0_2, 0), (self.blocks_multiply_const_vxx_0_0_1_0_0_2, 0))    
        self.connect((self.blocks_complex_to_float_6, 0), (self.blocks_multiply_const_vxx_0_0_1, 0))    
        self.connect((self.blocks_complex_to_float_6_0, 0), (self.blocks_multiply_const_vxx_0_0_1_1, 0))    
        self.connect((self.blocks_complex_to_float_6_0_0, 0), (self.blocks_multiply_const_vxx_0_0_1_1_0, 0))    
        self.connect((self.blocks_complex_to_float_6_0_1, 0), (self.blocks_multiply_const_vxx_0_0_1_1_1, 0))    
        self.connect((self.blocks_complex_to_float_6_0_2, 0), (self.blocks_multiply_const_vxx_0_0_1_1_2, 0))    
        self.connect((self.blocks_complex_to_float_7, 0), (self.blocks_multiply_const_vxx_0_0_0, 0))    
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_add_xx_1, 0))    
        self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.blocks_add_xx_1, 1))    
        self.connect((self.blocks_multiply_const_vxx_0_0_0, 0), (self.blocks_add_xx_1_1, 0))    
        self.connect((self.blocks_multiply_const_vxx_0_0_0_0, 0), (self.blocks_add_xx_1_1_0, 0))    
        self.connect((self.blocks_multiply_const_vxx_0_0_1, 0), (self.blocks_add_xx_1_1, 1))    
        self.connect((self.blocks_multiply_const_vxx_0_0_1_0, 0), (self.blocks_add_xx_1_1_0, 1))    
        self.connect((self.blocks_multiply_const_vxx_0_0_1_0_0, 0), (self.blocks_add_xx_1_1_0_0_0, 0))    
        self.connect((self.blocks_multiply_const_vxx_0_0_1_0_0_0, 0), (self.blocks_add_xx_1_1_0_0_0, 1))    
        self.connect((self.blocks_multiply_const_vxx_0_0_1_0_0_1, 0), (self.blocks_add_xx_1_1_0_0_0, 2))    
        self.connect((self.blocks_multiply_const_vxx_0_0_1_0_0_2, 0), (self.blocks_add_xx_1_1_0_0_0, 3))    
        self.connect((self.blocks_multiply_const_vxx_0_0_1_1, 0), (self.blocks_add_xx_1_1_0_0, 0))    
        self.connect((self.blocks_multiply_const_vxx_0_0_1_1_0, 0), (self.blocks_add_xx_1_1_0_0, 1))    
        self.connect((self.blocks_multiply_const_vxx_0_0_1_1_1, 0), (self.blocks_add_xx_1_1_0_0, 2))    
        self.connect((self.blocks_multiply_const_vxx_0_0_1_1_2, 0), (self.blocks_add_xx_1_1_0_0, 3))    
        self.connect((self.blocks_multiply_const_vxx_0_0_2, 0), (self.blocks_add_xx_1_0, 1))    
        self.connect((self.blocks_multiply_const_vxx_0_1, 0), (self.blocks_add_xx_1_0, 0))    
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.analog_nbfm_rx_0_0, 0))    
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.band_pass_filter_0_0_0_0, 0))    
        self.connect((self.freq_xlating_fir_filter_xxx_0_0, 0), (self.analog_nbfm_rx_0_0_0, 0))    
        self.connect((self.freq_xlating_fir_filter_xxx_0_0, 0), (self.band_pass_filter_0_0_0_0_0, 0))    
        self.connect((self.freq_xlating_fir_filter_xxx_0_0_0, 0), (self.analog_nbfm_rx_0_0_0_0, 0))    
        self.connect((self.freq_xlating_fir_filter_xxx_0_0_0, 0), (self.band_pass_filter_0_0_0_0_0_0, 0))    
        self.connect((self.freq_xlating_fir_filter_xxx_0_0_0_0, 0), (self.analog_nbfm_rx_0_0_0_0_0, 0))    
        self.connect((self.freq_xlating_fir_filter_xxx_0_0_0_0, 0), (self.band_pass_filter_0_0_0_0_0_0_0, 0))    
        self.connect((self.freq_xlating_fir_filter_xxx_0_0_0_0_0, 0), (self.analog_nbfm_rx_0_0_0_0_0_0, 0))    
        self.connect((self.freq_xlating_fir_filter_xxx_0_0_0_0_0, 0), (self.band_pass_filter_0_0_0_0_0_0_0_0, 0))    
        self.connect((self.freq_xlating_fir_filter_xxx_0_0_0_0_1, 0), (self.analog_nbfm_rx_0_0_0_0_0_1, 0))    
        self.connect((self.freq_xlating_fir_filter_xxx_0_0_0_0_1, 0), (self.band_pass_filter_0_0_0_0_0_0_0_1, 0))    
        self.connect((self.freq_xlating_fir_filter_xxx_0_0_0_0_2, 0), (self.analog_nbfm_rx_0_0_0_0_0_2, 0))    
        self.connect((self.freq_xlating_fir_filter_xxx_0_0_0_0_2, 0), (self.band_pass_filter_0_0_0_0_0_0_0_2, 0))    
        self.connect((self.freq_xlating_fir_filter_xxx_0_1, 0), (self.analog_nbfm_rx_0_0_1, 0))    
        self.connect((self.freq_xlating_fir_filter_xxx_0_1, 0), (self.band_pass_filter_0_0_0_0_1, 0))    
        self.connect((self.freq_xlating_fir_filter_xxx_1, 0), (self.blocks_complex_to_float_1, 0))    
        self.connect((self.freq_xlating_fir_filter_xxx_1_0, 0), (self.blocks_complex_to_float_0, 0))    
        self.connect((self.freq_xlating_fir_filter_xxx_1_0_0, 0), (self.blocks_complex_to_float_2, 0))    
        self.connect((self.freq_xlating_fir_filter_xxx_1_0_0_0, 0), (self.blocks_complex_to_float_7, 0))    
        self.connect((self.freq_xlating_fir_filter_xxx_1_0_0_0_0, 0), (self.blocks_complex_to_float_6, 0))    
        self.connect((self.freq_xlating_fir_filter_xxx_1_0_0_0_0_0, 0), (self.blocks_complex_to_float_6_0, 0))    
        self.connect((self.freq_xlating_fir_filter_xxx_1_0_0_0_0_0_0, 0), (self.blocks_complex_to_float_6_0_0, 0))    
        self.connect((self.freq_xlating_fir_filter_xxx_1_0_0_0_0_0_1, 0), (self.blocks_complex_to_float_6_0_1, 0))    
        self.connect((self.freq_xlating_fir_filter_xxx_1_0_0_0_0_0_2, 0), (self.blocks_complex_to_float_6_0_2, 0))    
        self.connect((self.freq_xlating_fir_filter_xxx_1_1, 0), (self.blocks_complex_to_float_3, 0))    
        self.connect((self.freq_xlating_fir_filter_xxx_1_1_0, 0), (self.blocks_complex_to_float_4, 0))    
        self.connect((self.freq_xlating_fir_filter_xxx_1_1_0_0, 0), (self.blocks_complex_to_float_5, 0))    
        self.connect((self.freq_xlating_fir_filter_xxx_1_1_0_0_0, 0), (self.blocks_complex_to_float_5_0, 0))    
        self.connect((self.freq_xlating_fir_filter_xxx_1_1_0_0_0_0, 0), (self.blocks_complex_to_float_5_0_0, 0))    
        self.connect((self.freq_xlating_fir_filter_xxx_1_1_0_0_0_1, 0), (self.blocks_complex_to_float_5_0_1, 0))    
        self.connect((self.freq_xlating_fir_filter_xxx_1_1_0_0_0_2, 0), (self.blocks_complex_to_float_5_0_2, 0))    
        self.connect((self.rational_resampler_xxx_0, 0), (self.freq_xlating_fir_filter_xxx_1_0_0_0, 0))    
        self.connect((self.rational_resampler_xxx_1_0, 0), (self.freq_xlating_fir_filter_xxx_1_0, 0))    
        self.connect((self.rational_resampler_xxx_1_0_0, 0), (self.freq_xlating_fir_filter_xxx_1, 0))    
        self.connect((self.rational_resampler_xxx_1_0_0_0, 0), (self.freq_xlating_fir_filter_xxx_1_1, 0))    
        self.connect((self.rational_resampler_xxx_1_0_0_0_0, 0), (self.freq_xlating_fir_filter_xxx_1_1_0_0, 0))    
        self.connect((self.rational_resampler_xxx_1_0_0_0_0_0, 0), (self.freq_xlating_fir_filter_xxx_1_1_0_0_0, 0))    
        self.connect((self.rational_resampler_xxx_1_0_0_0_0_0_0, 0), (self.freq_xlating_fir_filter_xxx_1_1_0_0_0_0, 0))    
        self.connect((self.rational_resampler_xxx_1_0_0_0_0_0_1, 0), (self.freq_xlating_fir_filter_xxx_1_1_0_0_0_1, 0))    
        self.connect((self.rational_resampler_xxx_1_0_0_0_0_0_2, 0), (self.freq_xlating_fir_filter_xxx_1_1_0_0_0_2, 0))    
        self.connect((self.rational_resampler_xxx_1_0_0_1, 0), (self.freq_xlating_fir_filter_xxx_1_1_0, 0))    
        self.connect((self.rational_resampler_xxx_1_0_1, 0), (self.freq_xlating_fir_filter_xxx_1_0_0, 0))    
        self.connect((self.rational_resampler_xxx_1_0_1_0, 0), (self.freq_xlating_fir_filter_xxx_1_0_0_0_0, 0))    
        self.connect((self.rational_resampler_xxx_1_0_1_0_0, 0), (self.freq_xlating_fir_filter_xxx_1_0_0_0_0_0, 0))    
        self.connect((self.rational_resampler_xxx_1_0_1_0_0_0, 0), (self.freq_xlating_fir_filter_xxx_1_0_0_0_0_0_0, 0))    
        self.connect((self.rational_resampler_xxx_1_0_1_0_0_1, 0), (self.freq_xlating_fir_filter_xxx_1_0_0_0_0_0_1, 0))    
        self.connect((self.rational_resampler_xxx_1_0_1_0_0_2, 0), (self.freq_xlating_fir_filter_xxx_1_0_0_0_0_0_2, 0))    
Example #51
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Nbfm")

        ##################################################
        # Variables
        ##################################################
        self.decim = decim = 2
        self.adc_rate = adc_rate = 2000000
        self.xlate_offset_fine = xlate_offset_fine = 4000
        self.xlate_offset = xlate_offset = 0
        self.xlate_decim = xlate_decim = 4
        self.xlate_bandwidth = xlate_bandwidth = 12500
        self.volume = volume = 1
        self.squelch = squelch = 50
        self.samp_rate = samp_rate = adc_rate/decim
        self.main_freq = main_freq = 167.99e6
        self.audio_rate = audio_rate = 48000
        self.audio_interp = audio_interp = 4

        ##################################################
        # Blocks
        ##################################################
        self.main_notebook = self.main_notebook = wx.Notebook(self.GetWin(), style=wx.NB_TOP)
        self.main_notebook.AddPage(grc_wxgui.Panel(self.main_notebook), "Baseband")
        self.main_notebook.AddPage(grc_wxgui.Panel(self.main_notebook), "Scope")
        self.main_notebook.AddPage(grc_wxgui.Panel(self.main_notebook), "Waterfall")
        self.main_notebook.AddPage(grc_wxgui.Panel(self.main_notebook), "Quad demod")
        self.Add(self.main_notebook)
        _xlate_offset_fine_sizer = wx.BoxSizer(wx.VERTICAL)
        self._xlate_offset_fine_text_box = forms.text_box(
        	parent=self.main_notebook.GetPage(0).GetWin(),
        	sizer=_xlate_offset_fine_sizer,
        	value=self.xlate_offset_fine,
        	callback=self.set_xlate_offset_fine,
        	label="Fine Offset",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._xlate_offset_fine_slider = forms.slider(
        	parent=self.main_notebook.GetPage(0).GetWin(),
        	sizer=_xlate_offset_fine_sizer,
        	value=self.xlate_offset_fine,
        	callback=self.set_xlate_offset_fine,
        	minimum=-10000,
        	maximum=10000,
        	num_steps=100,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.main_notebook.GetPage(0).Add(_xlate_offset_fine_sizer)
        self._xlate_offset_text_box = forms.text_box(
        	parent=self.main_notebook.GetPage(0).GetWin(),
        	value=self.xlate_offset,
        	callback=self.set_xlate_offset,
        	label="Xlate Offset",
        	converter=forms.float_converter(),
        )
        self.main_notebook.GetPage(0).Add(self._xlate_offset_text_box)
        _xlate_bandwidth_sizer = wx.BoxSizer(wx.VERTICAL)
        self._xlate_bandwidth_text_box = forms.text_box(
        	parent=self.main_notebook.GetPage(0).GetWin(),
        	sizer=_xlate_bandwidth_sizer,
        	value=self.xlate_bandwidth,
        	callback=self.set_xlate_bandwidth,
        	label="Xlate Bandwidth",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._xlate_bandwidth_slider = forms.slider(
        	parent=self.main_notebook.GetPage(0).GetWin(),
        	sizer=_xlate_bandwidth_sizer,
        	value=self.xlate_bandwidth,
        	callback=self.set_xlate_bandwidth,
        	minimum=2500,
        	maximum=250000,
        	num_steps=100,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.main_notebook.GetPage(0).Add(_xlate_bandwidth_sizer)
        _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=10,
        	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=0,
        	maximum=100,
        	num_steps=100,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.Add(_squelch_sizer)
        self._main_freq_text_box = forms.text_box(
        	parent=self.main_notebook.GetPage(0).GetWin(),
        	value=self.main_freq,
        	callback=self.set_main_freq,
        	label="Main Freq",
        	converter=forms.float_converter(),
        )
        self.main_notebook.GetPage(0).Add(self._main_freq_text_box)
        self.wxgui_waterfallsink2_0 = waterfallsink2.waterfall_sink_c(
        	self.main_notebook.GetPage(2).GetWin(),
        	baseband_freq=0,
        	dynamic_range=100,
        	ref_level=50,
        	ref_scale=2.0,
        	sample_rate=samp_rate/xlate_decim,
        	fft_size=512,
        	fft_rate=30,
        	average=False,
        	avg_alpha=None,
        	title="Waterfall Plot",
        )
        self.main_notebook.GetPage(2).Add(self.wxgui_waterfallsink2_0.win)
        self.wxgui_scopesink2_1 = scopesink2.scope_sink_f(
        	self.main_notebook.GetPage(3).GetWin(),
        	title="Scope Plot",
        	sample_rate=samp_rate/xlate_decim,
        	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.main_notebook.GetPage(3).Add(self.wxgui_scopesink2_1.win)
        self.wxgui_scopesink2_0 = scopesink2.scope_sink_c(
        	self.main_notebook.GetPage(1).GetWin(),
        	title="Scope Plot",
        	sample_rate=samp_rate/xlate_decim,
        	v_scale=10,
        	v_offset=0,
        	t_scale=10000,
        	ac_couple=False,
        	xy_mode=False,
        	num_inputs=1,
        	trig_mode=wxgui.TRIG_MODE_AUTO,
        	y_axis_label="Counts",
        )
        self.main_notebook.GetPage(1).Add(self.wxgui_scopesink2_0.win)
        self.wxgui_fftsink2_0 = fftsink2.fft_sink_c(
        	self.main_notebook.GetPage(0).GetWin(),
        	baseband_freq=0,
        	y_per_div=10,
        	y_divs=10,
        	ref_level=50,
        	ref_scale=2.0,
        	sample_rate=samp_rate/xlate_decim,
        	fft_size=1024,
        	fft_rate=30,
        	average=False,
        	avg_alpha=None,
        	title="FFT Plot",
        	peak_hold=False,
        )
        self.main_notebook.GetPage(0).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(main_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(2, 0)
        self.rtlsdr_source_0.set_gain_mode(True, 0)
        self.rtlsdr_source_0.set_gain(50, 0)
        self.rtlsdr_source_0.set_if_gain(20, 0)
        self.rtlsdr_source_0.set_bb_gain(20, 0)
        self.rtlsdr_source_0.set_antenna("", 0)
        self.rtlsdr_source_0.set_bandwidth(0, 0)
          
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
                interpolation=audio_rate*audio_interp,
                decimation=samp_rate/xlate_decim,
                taps=None,
                fractional_bw=None,
        )
        self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(xlate_decim, (firdes.low_pass(1, samp_rate, xlate_bandwidth/2, 1000)), xlate_offset + xlate_offset_fine, samp_rate)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((volume, ))
        self.audio_sink_0 = audio.sink(48000, "", True)
        self.analog_simple_squelch_cc_0 = analog.simple_squelch_cc(squelch*-1, 1)
        self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(1)
        self.analog_nbfm_rx_0 = analog.nbfm_rx(
        	audio_rate=audio_rate,
        	quad_rate=audio_rate*audio_interp,
        	tau=75e-6,
        	max_dev=5e3,
        )

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_nbfm_rx_0, 0), (self.blocks_multiply_const_vxx_0, 0))    
        self.connect((self.analog_quadrature_demod_cf_0, 0), (self.wxgui_scopesink2_1, 0))    
        self.connect((self.analog_simple_squelch_cc_0, 0), (self.analog_nbfm_rx_0, 0))    
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.audio_sink_0, 0))    
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.analog_quadrature_demod_cf_0, 0))    
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.rational_resampler_xxx_0, 0))    
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.wxgui_fftsink2_0, 0))    
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.wxgui_scopesink2_0, 0))    
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.wxgui_waterfallsink2_0, 0))    
        self.connect((self.rational_resampler_xxx_0, 0), (self.analog_simple_squelch_cc_0, 0))    
        self.connect((self.rtlsdr_source_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0))    
Example #52
0
    def __init__(self):
        gr.top_block.__init__(self, "Tlm Ana")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Tlm Ana")
        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", "tlm_ana")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.sps = sps = 40
        self.nfilt = nfilt = 40
        self.audio_rate = audio_rate = 48e3
        self.samp_rate = samp_rate = 300e3

        self.rrc_taps = rrc_taps = firdes.root_raised_cosine(
            nfilt * 1.0, audio_rate, 1200.0, 0.35, 16 * sps)

        self.ch_rate = ch_rate = 96e3

        ##################################################
        # Blocks
        ##################################################
        self.root_raised_cosine_filter_0 = filter.fir_filter_fff(
            1, firdes.root_raised_cosine(1.0, audio_rate, 1200.0, 0.35,
                                         16 * 40))
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
            interpolation=int(ch_rate),
            decimation=int(samp_rate),
            taps=None,
            fractional_bw=None,
        )
        self.qtgui_time_sink_x_0 = qtgui.time_sink_f(
            8192 * 8,  #size
            audio_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(-15, 15)

        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_TAG,
                                                  qtgui.TRIG_SLOPE_POS, 0.0,
                                                  50e-3, 0, 'start')
        self.qtgui_time_sink_x_0.enable_autoscale(False)
        self.qtgui_time_sink_x_0.enable_grid(True)
        self.qtgui_time_sink_x_0.enable_axis_labels(True)
        self.qtgui_time_sink_x_0.enable_control_panel(False)

        if not False:
            self.qtgui_time_sink_x_0.disable_legend()

        labels = ['', '', '', '', '', '', '', '', '', '']
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "red", "blue", "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_layout.addWidget(self._qtgui_time_sink_x_0_win)
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c(
            4096,  #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(-100, -20)
        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(0.2)
        self.qtgui_freq_sink_x_0.enable_axis_labels(True)
        self.qtgui_freq_sink_x_0.enable_control_panel(False)

        if not False:
            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.fft_filter_xxx_2 = filter.fft_filter_ccc(
            1, (firdes.low_pass(1, audio_rate, 1e3, 1e3, firdes.WIN_BLACKMAN)),
            1)
        self.fft_filter_xxx_2.declare_sample_delay(0)
        self.fft_filter_xxx_1 = filter.fft_filter_fff(1, (firdes.band_pass(
            1, audio_rate, 700, 2700, 500, firdes.WIN_BLACKMAN)), 1)
        self.fft_filter_xxx_1.declare_sample_delay(0)
        self.fft_filter_xxx_0 = filter.fft_filter_ccc(
            1, (firdes.low_pass(1, samp_rate, 5e3, 1e3, firdes.WIN_BLACKMAN)),
            1)
        self.fft_filter_xxx_0.declare_sample_delay(0)
        self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb()
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1,
                                                 samp_rate, True)
        self.blocks_threshold_ff_0 = blocks.threshold_ff(0.5, 0.7, 0)
        self.blocks_tagged_file_sink_0 = blocks.tagged_file_sink(
            gr.sizeof_char * 1, int(audio_rate))
        self.blocks_rotator_cc_1 = blocks.rotator_cc(
            (-1700 / audio_rate) * 2 * math.pi)
        self.blocks_rotator_cc_0 = blocks.rotator_cc(-(-16.2e3 / samp_rate) *
                                                     2 * math.pi)
        self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_float * 1)
        self.blocks_multiply_const_vxx_5 = blocks.multiply_const_vcc((2, ))
        self.blocks_multiply_const_vxx_4 = blocks.multiply_const_vff((1.0, ))
        self.blocks_multiply_const_vxx_3 = blocks.multiply_const_vff((1, ))
        self.blocks_multiply_const_vxx_2 = blocks.multiply_const_vff((7, ))
        self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vff((1e4, ))
        self.blocks_moving_average_xx_0 = blocks.moving_average_ff(
            400, 1.0 / 400, 4000)
        self.blocks_keep_one_in_n_2 = blocks.keep_one_in_n(
            gr.sizeof_float * 1, 5)
        self.blocks_keep_one_in_n_1 = blocks.keep_one_in_n(
            gr.sizeof_float * 1, 2)
        self.blocks_float_to_short_0 = blocks.float_to_short(1, 1)
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        self.blocks_float_to_char_0 = blocks.float_to_char(1, 1)
        self.blocks_file_source_0 = blocks.file_source(
            gr.sizeof_gr_complex * 1,
            '/home/handiko/gqrx_20180319_072938_433268400_300000_fc.raw', True)
        self.blocks_delay_3 = blocks.delay(gr.sizeof_float * 1, 0)
        self.blocks_delay_2 = blocks.delay(gr.sizeof_short * 1, 2400)
        self.blocks_delay_1 = blocks.delay(gr.sizeof_short * 1, 400)
        self.blocks_delay_0 = blocks.delay(gr.sizeof_float * 1, 400)
        self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1)
        self.blocks_char_to_float_0 = blocks.char_to_float(1, 1)
        self.blocks_burst_tagger_1 = blocks.burst_tagger(gr.sizeof_float)
        self.blocks_burst_tagger_1.set_true_tag('burst', True)
        self.blocks_burst_tagger_1.set_false_tag('burst', False)

        self.blocks_burst_tagger_0 = blocks.burst_tagger(gr.sizeof_float)
        self.blocks_burst_tagger_0.set_true_tag('start', True)
        self.blocks_burst_tagger_0.set_false_tag('stop', False)

        self.blocks_add_const_vxx_3 = blocks.add_const_vff((-5, ))
        self.blocks_add_const_vxx_2 = blocks.add_const_vff((5, ))
        self.blocks_add_const_vxx_1 = blocks.add_const_vff((48, ))
        self.blocks_add_const_vxx_0 = blocks.add_const_vff((0, ))
        self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(
            audio_rate / (2 * math.pi * 1e3 / 8.0))
        self.analog_nbfm_rx_0 = analog.nbfm_rx(
            audio_rate=int(audio_rate),
            quad_rate=int(ch_rate),
            tau=75e-6,
            max_dev=5e3,
        )

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_nbfm_rx_0, 0), (self.fft_filter_xxx_1, 0))
        self.connect((self.analog_quadrature_demod_cf_0, 0),
                     (self.root_raised_cosine_filter_0, 0))
        self.connect((self.blocks_add_const_vxx_0, 0),
                     (self.blocks_burst_tagger_1, 0))
        self.connect((self.blocks_add_const_vxx_1, 0),
                     (self.blocks_keep_one_in_n_2, 0))
        self.connect((self.blocks_add_const_vxx_2, 0),
                     (self.qtgui_time_sink_x_0, 0))
        self.connect((self.blocks_add_const_vxx_3, 0),
                     (self.qtgui_time_sink_x_0, 1))
        self.connect((self.blocks_burst_tagger_0, 0), (self.blocks_delay_0, 0))
        self.connect((self.blocks_burst_tagger_1, 0),
                     (self.blocks_add_const_vxx_1, 0))
        self.connect((self.blocks_burst_tagger_1, 0),
                     (self.blocks_null_sink_0, 0))
        self.connect((self.blocks_char_to_float_0, 0),
                     (self.blocks_add_const_vxx_0, 0))
        self.connect((self.blocks_complex_to_mag_squared_0, 0),
                     (self.blocks_multiply_const_vxx_1, 0))
        self.connect((self.blocks_delay_0, 0),
                     (self.blocks_multiply_const_vxx_2, 0))
        self.connect((self.blocks_delay_1, 0), (self.blocks_burst_tagger_0, 1))
        self.connect((self.blocks_delay_2, 0), (self.blocks_burst_tagger_1, 1))
        self.connect((self.blocks_delay_3, 0),
                     (self.blocks_multiply_const_vxx_3, 0))
        self.connect((self.blocks_file_source_0, 0),
                     (self.blocks_rotator_cc_0, 0))
        self.connect((self.blocks_float_to_char_0, 0),
                     (self.blocks_tagged_file_sink_0, 0))
        self.connect((self.blocks_float_to_complex_0, 0),
                     (self.blocks_rotator_cc_1, 0))
        self.connect((self.blocks_float_to_short_0, 0),
                     (self.blocks_delay_1, 0))
        self.connect((self.blocks_float_to_short_0, 0),
                     (self.blocks_delay_2, 0))
        self.connect((self.blocks_keep_one_in_n_1, 0),
                     (self.blocks_float_to_short_0, 0))
        self.connect((self.blocks_keep_one_in_n_2, 0),
                     (self.blocks_float_to_char_0, 0))
        self.connect((self.blocks_moving_average_xx_0, 0),
                     (self.blocks_threshold_ff_0, 0))
        self.connect((self.blocks_multiply_const_vxx_1, 0),
                     (self.blocks_moving_average_xx_0, 0))
        self.connect((self.blocks_multiply_const_vxx_2, 0),
                     (self.blocks_add_const_vxx_2, 0))
        self.connect((self.blocks_multiply_const_vxx_3, 0),
                     (self.blocks_add_const_vxx_3, 0))
        self.connect((self.blocks_multiply_const_vxx_4, 0),
                     (self.digital_binary_slicer_fb_0, 0))
        self.connect((self.blocks_multiply_const_vxx_5, 0),
                     (self.blocks_throttle_0, 0))
        self.connect((self.blocks_rotator_cc_0, 0),
                     (self.blocks_multiply_const_vxx_5, 0))
        self.connect((self.blocks_rotator_cc_1, 0), (self.fft_filter_xxx_2, 0))
        self.connect((self.blocks_threshold_ff_0, 0),
                     (self.blocks_keep_one_in_n_1, 0))
        self.connect((self.blocks_throttle_0, 0), (self.fft_filter_xxx_0, 0))
        self.connect((self.blocks_throttle_0, 0),
                     (self.qtgui_freq_sink_x_0, 0))
        self.connect((self.digital_binary_slicer_fb_0, 0),
                     (self.blocks_char_to_float_0, 0))
        self.connect((self.fft_filter_xxx_0, 0),
                     (self.rational_resampler_xxx_0, 0))
        self.connect((self.fft_filter_xxx_1, 0),
                     (self.blocks_burst_tagger_0, 0))
        self.connect((self.fft_filter_xxx_1, 0),
                     (self.blocks_float_to_complex_0, 0))
        self.connect((self.fft_filter_xxx_2, 0),
                     (self.analog_quadrature_demod_cf_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.analog_nbfm_rx_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.blocks_complex_to_mag_squared_0, 0))
        self.connect((self.root_raised_cosine_filter_0, 0),
                     (self.blocks_delay_3, 0))
        self.connect((self.root_raised_cosine_filter_0, 0),
                     (self.blocks_multiply_const_vxx_4, 0))
Example #53
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Nbfm")

        ##################################################
        # Variables
        ##################################################
        self.decim = decim = 2
        self.adc_rate = adc_rate = 2000000
        self.xlate_offset_fine = xlate_offset_fine = 4000
        self.xlate_offset = xlate_offset = 0
        self.xlate_decim = xlate_decim = 4
        self.xlate_bandwidth = xlate_bandwidth = 12500
        self.volume = volume = 1
        self.squelch = squelch = 50
        self.samp_rate = samp_rate = adc_rate / decim
        self.main_freq = main_freq = 167.99e6
        self.audio_rate = audio_rate = 48000
        self.audio_interp = audio_interp = 4

        ##################################################
        # Blocks
        ##################################################
        self.main_notebook = self.main_notebook = wx.Notebook(self.GetWin(),
                                                              style=wx.NB_TOP)
        self.main_notebook.AddPage(grc_wxgui.Panel(self.main_notebook),
                                   "Baseband")
        self.main_notebook.AddPage(grc_wxgui.Panel(self.main_notebook),
                                   "Scope")
        self.main_notebook.AddPage(grc_wxgui.Panel(self.main_notebook),
                                   "Waterfall")
        self.main_notebook.AddPage(grc_wxgui.Panel(self.main_notebook),
                                   "Quad demod")
        self.Add(self.main_notebook)
        _xlate_offset_fine_sizer = wx.BoxSizer(wx.VERTICAL)
        self._xlate_offset_fine_text_box = forms.text_box(
            parent=self.main_notebook.GetPage(0).GetWin(),
            sizer=_xlate_offset_fine_sizer,
            value=self.xlate_offset_fine,
            callback=self.set_xlate_offset_fine,
            label="Fine Offset",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._xlate_offset_fine_slider = forms.slider(
            parent=self.main_notebook.GetPage(0).GetWin(),
            sizer=_xlate_offset_fine_sizer,
            value=self.xlate_offset_fine,
            callback=self.set_xlate_offset_fine,
            minimum=-10000,
            maximum=10000,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.main_notebook.GetPage(0).Add(_xlate_offset_fine_sizer)
        self._xlate_offset_text_box = forms.text_box(
            parent=self.main_notebook.GetPage(0).GetWin(),
            value=self.xlate_offset,
            callback=self.set_xlate_offset,
            label="Xlate Offset",
            converter=forms.float_converter(),
        )
        self.main_notebook.GetPage(0).Add(self._xlate_offset_text_box)
        _xlate_bandwidth_sizer = wx.BoxSizer(wx.VERTICAL)
        self._xlate_bandwidth_text_box = forms.text_box(
            parent=self.main_notebook.GetPage(0).GetWin(),
            sizer=_xlate_bandwidth_sizer,
            value=self.xlate_bandwidth,
            callback=self.set_xlate_bandwidth,
            label="Xlate Bandwidth",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._xlate_bandwidth_slider = forms.slider(
            parent=self.main_notebook.GetPage(0).GetWin(),
            sizer=_xlate_bandwidth_sizer,
            value=self.xlate_bandwidth,
            callback=self.set_xlate_bandwidth,
            minimum=2500,
            maximum=250000,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.main_notebook.GetPage(0).Add(_xlate_bandwidth_sizer)
        _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=10,
            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=0,
            maximum=100,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.Add(_squelch_sizer)
        self._main_freq_text_box = forms.text_box(
            parent=self.main_notebook.GetPage(0).GetWin(),
            value=self.main_freq,
            callback=self.set_main_freq,
            label="Main Freq",
            converter=forms.float_converter(),
        )
        self.main_notebook.GetPage(0).Add(self._main_freq_text_box)
        self.wxgui_waterfallsink2_0 = waterfallsink2.waterfall_sink_c(
            self.main_notebook.GetPage(2).GetWin(),
            baseband_freq=0,
            dynamic_range=100,
            ref_level=50,
            ref_scale=2.0,
            sample_rate=samp_rate / xlate_decim,
            fft_size=512,
            fft_rate=30,
            average=False,
            avg_alpha=None,
            title="Waterfall Plot",
        )
        self.main_notebook.GetPage(2).Add(self.wxgui_waterfallsink2_0.win)
        self.wxgui_scopesink2_1 = scopesink2.scope_sink_f(
            self.main_notebook.GetPage(3).GetWin(),
            title="Scope Plot",
            sample_rate=samp_rate / xlate_decim,
            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.main_notebook.GetPage(3).Add(self.wxgui_scopesink2_1.win)
        self.wxgui_scopesink2_0 = scopesink2.scope_sink_c(
            self.main_notebook.GetPage(1).GetWin(),
            title="Scope Plot",
            sample_rate=samp_rate / xlate_decim,
            v_scale=10,
            v_offset=0,
            t_scale=10000,
            ac_couple=False,
            xy_mode=False,
            num_inputs=1,
            trig_mode=wxgui.TRIG_MODE_AUTO,
            y_axis_label="Counts",
        )
        self.main_notebook.GetPage(1).Add(self.wxgui_scopesink2_0.win)
        self.wxgui_fftsink2_0 = fftsink2.fft_sink_c(
            self.main_notebook.GetPage(0).GetWin(),
            baseband_freq=0,
            y_per_div=10,
            y_divs=10,
            ref_level=50,
            ref_scale=2.0,
            sample_rate=samp_rate / xlate_decim,
            fft_size=1024,
            fft_rate=30,
            average=False,
            avg_alpha=None,
            title="FFT Plot",
            peak_hold=False,
        )
        self.main_notebook.GetPage(0).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(main_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(2, 0)
        self.rtlsdr_source_0.set_gain_mode(True, 0)
        self.rtlsdr_source_0.set_gain(50, 0)
        self.rtlsdr_source_0.set_if_gain(20, 0)
        self.rtlsdr_source_0.set_bb_gain(20, 0)
        self.rtlsdr_source_0.set_antenna("", 0)
        self.rtlsdr_source_0.set_bandwidth(0, 0)

        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
            interpolation=audio_rate * audio_interp,
            decimation=samp_rate / xlate_decim,
            taps=None,
            fractional_bw=None,
        )
        self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(
            xlate_decim,
            (firdes.low_pass(1, samp_rate, xlate_bandwidth / 2, 1000)),
            xlate_offset + xlate_offset_fine, samp_rate)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff(
            (volume, ))
        self.audio_sink_0 = audio.sink(48000, "", True)
        self.analog_simple_squelch_cc_0 = analog.simple_squelch_cc(
            squelch * -1, 1)
        self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(1)
        self.analog_nbfm_rx_0 = analog.nbfm_rx(
            audio_rate=audio_rate,
            quad_rate=audio_rate * audio_interp,
            tau=75e-6,
            max_dev=5e3,
        )

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_nbfm_rx_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.analog_quadrature_demod_cf_0, 0),
                     (self.wxgui_scopesink2_1, 0))
        self.connect((self.analog_simple_squelch_cc_0, 0),
                     (self.analog_nbfm_rx_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.audio_sink_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0),
                     (self.analog_quadrature_demod_cf_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0),
                     (self.rational_resampler_xxx_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0),
                     (self.wxgui_fftsink2_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0),
                     (self.wxgui_scopesink2_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0),
                     (self.wxgui_waterfallsink2_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.analog_simple_squelch_cc_0, 0))
        self.connect((self.rtlsdr_source_0, 0),
                     (self.freq_xlating_fir_filter_xxx_0, 0))
    def __init__(self):
        gr.top_block.__init__(self, "FM radio FFT example")

        ##################################################
        # Variables
        ##################################################
        self.variable_sample_rate_0 = variable_sample_rate_0 = 1e6
        self.xlatecenter_4 = xlatecenter_4 = 0
        self.xlatecenter_3 = xlatecenter_3 = 0
        self.xlatecenter_2 = xlatecenter_2 = 0
        self.xlatecenter = xlatecenter = 0
        self.xlate_filter = xlate_filter = firdes.low_pass(1, variable_sample_rate_0, 125000, 25000, firdes.WIN_HAMMING, 6.76)
        self.variable_1 = variable_1 = 0
        self.transition = transition = 1e6
        self.samp_rate = samp_rate = 48000
        self.xlate_filter2 = xlate_filter2 = firdes.low_pass(1, samp_rate, 8000, 2000, firdes.WIN_HAMMING, 6.76)
        self.quadrature = quadrature = 500000
        self.cutoff = cutoff = 1e5
        self.bptrans = bptrans = 100
        self.bplow_4 = bplow_4 = 100
        self.bplow_3 = bplow_3 = 100
        self.bplow_2 = bplow_2 = 100
        self.bplow_1 = bplow_1 = 100
        self.bphi_4 = bphi_4 = 2.8e3
        self.bphi_3 = bphi_3 = 2.8e3
        self.bphi_2 = bphi_2 = 2.8e3
        self.bphi_1 = bphi_1 = 2.8e3
        self.audio_interp = audio_interp = 4
        self.amp_4 = amp_4 = 0
        self.amp_3 = amp_3 = 0
        self.amp_2 = amp_2 = 0
        self.amp_1 = amp_1 = 0
        self.RF_Gain = RF_Gain = 35
        self.CF = CF = 125.6e6
        self.shift_4 = shift_4 = 0
        self.shift_3 = shift_3 = 0
        self.shift_2 = shift_2 = 0
        self.shift_1 = shift_1 = 0

        ##################################################
        # Blocks
        ##################################################
        self.rational_resampler_xxx_1_0_2 = filter.rational_resampler_fff(
                interpolation=48,
                decimation=50,
                taps=None,
                fractional_bw=None,
        )
        self.rational_resampler_xxx_1_0_1_0 = filter.rational_resampler_fff(
                interpolation=48,
                decimation=50,
                taps=None,
                fractional_bw=None,
        )
        self.rational_resampler_xxx_1_0_1 = filter.rational_resampler_fff(
                interpolation=48,
                decimation=50,
                taps=None,
                fractional_bw=None,
        )
        self.rational_resampler_xxx_1_0_0_1 = filter.rational_resampler_ccc(
                interpolation=48,
                decimation=50,
                taps=None,
                fractional_bw=None,
        )
        self.rational_resampler_xxx_1_0_0_0_0 = filter.rational_resampler_ccc(
                interpolation=48,
                decimation=50,
                taps=None,
                fractional_bw=None,
        )
        self.rational_resampler_xxx_1_0_0_0 = filter.rational_resampler_ccc(
                interpolation=48,
                decimation=50,
                taps=None,
                fractional_bw=None,
        )
        self.rational_resampler_xxx_1_0_0 = filter.rational_resampler_ccc(
                interpolation=48,
                decimation=50,
                taps=None,
                fractional_bw=None,
        )
        self.rational_resampler_xxx_1_0 = filter.rational_resampler_fff(
                interpolation=48,
                decimation=50,
                taps=None,
                fractional_bw=None,
        )
        self.freq_xlating_fir_filter_xxx_0_1 = filter.freq_xlating_fir_filter_ccc(5, (xlate_filter), xlatecenter_3, variable_sample_rate_0)
        self.freq_xlating_fir_filter_xxx_0_0_0 = filter.freq_xlating_fir_filter_ccc(5, (xlate_filter), xlatecenter_4, variable_sample_rate_0)
        self.freq_xlating_fir_filter_xxx_0_0 = filter.freq_xlating_fir_filter_ccc(5, (xlate_filter), xlatecenter_2, variable_sample_rate_0)
        self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(5, (xlate_filter), xlatecenter, variable_sample_rate_0)

        self.freq_xlating_fir_filter_aaa = filter.freq_xlating_fir_filter_ccc(1, (xlate_filter2), shift_1, samp_rate)
        self.freq_xlating_fir_filter_bbb = filter.freq_xlating_fir_filter_ccc(1, (xlate_filter2), shift_2, samp_rate)
        self.freq_xlating_fir_filter_ccc = filter.freq_xlating_fir_filter_ccc(1, (xlate_filter2), shift_3, samp_rate)
        self.freq_xlating_fir_filter_ddd = filter.freq_xlating_fir_filter_ccc(1, (xlate_filter2), shift_4, samp_rate)

        self.blocks_multiply_const_vxx_0_1 = blocks.multiply_const_vff((amp_1, ))
        self.blocks_multiply_const_vxx_0_0_2 = blocks.multiply_const_vff((amp_2, ))
        self.blocks_multiply_const_vxx_0_0_1_0 = blocks.multiply_const_vff((amp_4, ))
        self.blocks_multiply_const_vxx_0_0_1 = blocks.multiply_const_vff((amp_4, ))
        self.blocks_multiply_const_vxx_0_0_0_0 = blocks.multiply_const_vff((amp_3, ))
        self.blocks_multiply_const_vxx_0_0_0 = blocks.multiply_const_vff((amp_3, ))
        self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vff((amp_2, ))
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((amp_1, ))
        self.blocks_complex_to_mag_0_1 = blocks.complex_to_mag(1)
        self.blocks_complex_to_mag_0_0_0 = blocks.complex_to_mag(1)
        self.blocks_complex_to_mag_0_0 = blocks.complex_to_mag(1)
        self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1)
        self.blocks_add_xx_1_1_0 = blocks.add_vff(1)
        self.blocks_add_xx_1_1 = blocks.add_vff(1)
        self.blocks_add_xx_1_0 = blocks.add_vff(1)
        self.blocks_add_xx_1 = blocks.add_vff(1)
        self.band_pass_filter_0_0_0_0_1 = filter.fir_filter_ccf(4, firdes.band_pass(
        	1, samp_rate, bplow_3, bphi_3, bptrans, firdes.WIN_HAMMING, 6.76))
        self.band_pass_filter_0_0_0_0_0_0 = filter.fir_filter_ccf(4, firdes.band_pass(
        	1, samp_rate, bplow_4, bphi_4, bptrans, firdes.WIN_HAMMING, 6.76))
        self.band_pass_filter_0_0_0_0_0 = filter.fir_filter_ccf(4, firdes.band_pass(
        	1, samp_rate, bplow_2, bphi_2, bptrans, firdes.WIN_HAMMING, 6.76))
        self.band_pass_filter_0_0_0_0 = filter.fir_filter_ccf(4, firdes.band_pass(
        	1, samp_rate, bplow_1, bphi_1, bptrans, firdes.WIN_HAMMING, 6.76))
        self.audio_sink_4 = audio.sink(48000, "Radio:AM2", True)
        self.audio_sink_3 = audio.sink(48000, "Radio:NFM2", True)
        self.audio_sink_2 = audio.sink(48000, "Radio:AM1", True)
        self.audio_sink_1 = audio.sink(48000, "Radio:NFM1", True)
        self.analog_nbfm_rx_0_0_1 = analog.nbfm_rx(
        	audio_rate=50000,
        	quad_rate=int(variable_sample_rate_0/5),
        	tau=75e-6,
        	max_dev=12500,
        )
        self.analog_nbfm_rx_0_0_0_0 = analog.nbfm_rx(
        	audio_rate=50000,
        	quad_rate=int(variable_sample_rate_0/5),
        	tau=75e-6,
        	max_dev=12500,
        )
        self.analog_nbfm_rx_0_0_0 = analog.nbfm_rx(
        	audio_rate=50000,
        	quad_rate=int(variable_sample_rate_0/5),
        	tau=75e-6,
        	max_dev=12500,
        )
        self.analog_nbfm_rx_0_0 = analog.nbfm_rx(
        	audio_rate=50000,
        	quad_rate=int(variable_sample_rate_0/5),
        	tau=75e-6,
        	max_dev=12500,
        )
        self.RTL820T = osmosdr.source( args="numchan=" + str(1) + " " + "" )
        self.RTL820T.set_sample_rate(variable_sample_rate_0)
        self.RTL820T.set_center_freq(CF, 0)
        self.RTL820T.set_freq_corr(0, 0)
        self.RTL820T.set_dc_offset_mode(2, 0)
        self.RTL820T.set_iq_balance_mode(0, 0)
        self.RTL820T.set_gain_mode(False, 0)
        self.RTL820T.set_gain(RF_Gain, 0)
        self.RTL820T.set_if_gain(20, 0)
        self.RTL820T.set_bb_gain(20, 0)
        self.RTL820T.set_antenna("", 0)
        self.RTL820T.set_bandwidth(1e6, 0)
          

        ##################################################
        # Connections
        ##################################################
        self.connect((self.RTL820T, 0), (self.freq_xlating_fir_filter_xxx_0, 0))    
        self.connect((self.RTL820T, 0), (self.freq_xlating_fir_filter_xxx_0_0, 0))    
        self.connect((self.RTL820T, 0), (self.freq_xlating_fir_filter_xxx_0_0_0, 0))    
        self.connect((self.RTL820T, 0), (self.freq_xlating_fir_filter_xxx_0_1, 0))    
        self.connect((self.analog_nbfm_rx_0_0, 0), (self.rational_resampler_xxx_1_0, 0))    
        self.connect((self.analog_nbfm_rx_0_0_0, 0), (self.rational_resampler_xxx_1_0_1, 0))    
        self.connect((self.analog_nbfm_rx_0_0_0_0, 0), (self.rational_resampler_xxx_1_0_1_0, 0))    
        self.connect((self.analog_nbfm_rx_0_0_1, 0), (self.rational_resampler_xxx_1_0_2, 0))    
        self.connect((self.band_pass_filter_0_0_0_0, 0), (self.rational_resampler_xxx_1_0_0, 0))    
        self.connect((self.band_pass_filter_0_0_0_0_0, 0), (self.rational_resampler_xxx_1_0_0_0, 0))    
        self.connect((self.band_pass_filter_0_0_0_0_0_0, 0), (self.rational_resampler_xxx_1_0_0_0_0, 0))    
        self.connect((self.band_pass_filter_0_0_0_0_1, 0), (self.rational_resampler_xxx_1_0_0_1, 0))    
        self.connect((self.blocks_add_xx_1, 0), (self.audio_sink_1, 0))    
        self.connect((self.blocks_add_xx_1_0, 0), (self.audio_sink_2, 0))    
        self.connect((self.blocks_add_xx_1_1, 0), (self.audio_sink_3, 0))    
        self.connect((self.blocks_add_xx_1_1_0, 0), (self.audio_sink_4, 0))    
        self.connect((self.blocks_complex_to_mag_0, 0), (self.blocks_multiply_const_vxx_0_1, 0))    
        self.connect((self.blocks_complex_to_mag_0_0, 0), (self.blocks_multiply_const_vxx_0_0_2, 0))    
        self.connect((self.blocks_complex_to_mag_0_0_0, 0), (self.blocks_multiply_const_vxx_0_0_1_0, 0))    
        self.connect((self.blocks_complex_to_mag_0_1, 0), (self.blocks_multiply_const_vxx_0_0_0_0, 0))    
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_add_xx_1, 0))    
        self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.blocks_add_xx_1, 1))    
        self.connect((self.blocks_multiply_const_vxx_0_0_0, 0), (self.blocks_add_xx_1_1, 0))    
        self.connect((self.blocks_multiply_const_vxx_0_0_0_0, 0), (self.blocks_add_xx_1_1_0, 0))    
        self.connect((self.blocks_multiply_const_vxx_0_0_1, 0), (self.blocks_add_xx_1_1, 1))    
        self.connect((self.blocks_multiply_const_vxx_0_0_1_0, 0), (self.blocks_add_xx_1_1_0, 1))    
        self.connect((self.blocks_multiply_const_vxx_0_0_2, 0), (self.blocks_add_xx_1_0, 1))    
        self.connect((self.blocks_multiply_const_vxx_0_1, 0), (self.blocks_add_xx_1_0, 0))    
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.analog_nbfm_rx_0_0, 0))    
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.band_pass_filter_0_0_0_0, 0))    
        self.connect((self.freq_xlating_fir_filter_xxx_0_0, 0), (self.analog_nbfm_rx_0_0_0, 0))    
        self.connect((self.freq_xlating_fir_filter_xxx_0_0, 0), (self.band_pass_filter_0_0_0_0_0, 0))    
        self.connect((self.freq_xlating_fir_filter_xxx_0_0_0, 0), (self.analog_nbfm_rx_0_0_0_0, 0))    
        self.connect((self.freq_xlating_fir_filter_xxx_0_0_0, 0), (self.band_pass_filter_0_0_0_0_0_0, 0))    
        self.connect((self.freq_xlating_fir_filter_xxx_0_1, 0), (self.analog_nbfm_rx_0_0_1, 0))    
        self.connect((self.freq_xlating_fir_filter_xxx_0_1, 0), (self.band_pass_filter_0_0_0_0_1, 0))    
        self.connect((self.rational_resampler_xxx_1_0, 0), (self.blocks_multiply_const_vxx_0, 0))    
        self.connect((self.rational_resampler_xxx_1_0_0, 0), (self.blocks_complex_to_mag_0, 0))    
        self.connect((self.rational_resampler_xxx_1_0_0_0, 0), (self.blocks_complex_to_mag_0_0, 0))    
        self.connect((self.rational_resampler_xxx_1_0_0_0_0, 0), (self.blocks_complex_to_mag_0_0_0, 0))    
        self.connect((self.rational_resampler_xxx_1_0_0_1, 0), (self.blocks_complex_to_mag_0_1, 0))    
        self.connect((self.rational_resampler_xxx_1_0_1, 0), (self.blocks_multiply_const_vxx_0_0, 0))    
        self.connect((self.rational_resampler_xxx_1_0_1_0, 0), (self.blocks_multiply_const_vxx_0_0_1, 0))    
        self.connect((self.rational_resampler_xxx_1_0_2, 0), (self.blocks_multiply_const_vxx_0_0_0, 0))