Ejemplo n.º 1
0
def make_resampler(in_rate, out_rate):
    fractional_cutoff = 0.4
    fractional_transition_width = 0.2

    # The rate relative to in_rate for which to design the anti-aliasing filter.
    in_relative_max_rate = min(out_rate, in_rate) / in_rate

    in_relative_cutoff = in_relative_max_rate * fractional_cutoff
    in_relative_transition_width = in_relative_max_rate * fractional_transition_width

    if _use_rational_resampler and in_rate % 1 == 0 and out_rate % 1 == 0:
        # Note: rational_resampler has this logic built in, but it does not correctly design the filter when decimating <http://gnuradio.org/redmine/issues/745>, so we do it ourselves; but this also allows sharing the calculation details for pfb_ and rational_.
        in_rate = int(in_rate)
        out_rate = int(out_rate)
        common = gcd(in_rate, out_rate)
        interpolation = out_rate // common
        decimation = in_rate // common
        return rational_resampler.rational_resampler_fff(
            interpolation=interpolation,
            decimation=decimation,
            taps=firdes.low_pass(
                interpolation,  # gain compensates for interpolation
                interpolation,  # rational resampler filter runs at the interpolated rate
                in_relative_cutoff,
                in_relative_transition_width))
    else:
        resample_ratio = out_rate / in_rate
        pfbsize = 32  # TODO: justify magic number (taken from gqrx)
        return pfb.arb_resampler_fff(
            resample_ratio,
            firdes.low_pass(pfbsize, pfbsize, in_relative_cutoff,
                            in_relative_transition_width), pfbsize)
Ejemplo n.º 2
0
def make_resampler(in_rate, out_rate):
	# magic numbers from gqrx
	resample_ratio = float(out_rate) / in_rate
	pfbsize = 32
	return pfb.arb_resampler_fff(
		resample_ratio,
		firdes.low_pass(pfbsize, pfbsize, 0.4 * resample_ratio, 0.2 * resample_ratio),
		pfbsize)
Ejemplo n.º 3
0
    def __init__(self):
        gr.top_block.__init__(self, "FM whole-band Channelizer to Measure Latency vs TP")

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 3.125e6
        self.gain = gain = 10
        self.pfb_transition_width = pfb_transition_width = 120e3
        self.pfb_samp_rate = pfb_samp_rate = samp_rate
        self.pfb_gain = pfb_gain = 1
        self.pfb_cutoff_freq = pfb_cutoff_freq = 80e3
        self.pfb_attenuation = pfb_attenuation = 60
        self.audio_transition_width = audio_transition_width = 3e3/10
        self.audio_samp_rate = audio_samp_rate = 44.1e3
        self.audio_gain = audio_gain = gain
        self.audio_cutoff_freq = audio_cutoff_freq = 18e3/10
        self.audio_attenuation = audio_attenuation = 80
        self.pfb_taps = pfb_taps = firdes.low_pass_2(pfb_gain, pfb_samp_rate, pfb_cutoff_freq, pfb_transition_width, pfb_attenuation)
        self.audio_taps = audio_taps = firdes.low_pass_2(audio_gain, audio_samp_rate, audio_cutoff_freq, audio_transition_width, audio_attenuation)
        self.pfb_ntaps = pfb_ntaps = pfb_taps.__len__()
        self.channel = channel = 0
        self.audio_rate = audio_rate = 44.1e3
        self.audio_ntaps = audio_ntaps = audio_taps.__len__()

        ##################################################
        # Blocks
        ##################################################
        self.west_timestamp_tagger_ff_0 = west.timestamp_tagger_ff(gr.sizeof_gr_complex, 100)
        self.west_timestamp_sink_f_0 = west.timestamp_sink_f("timestamp", "fm_latency_meas")
        self.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_fff(
        	   audio_rate / 50e3,
                  taps=(audio_taps),
        	  flt_size=10)
        self.pfb_arb_resampler_xxx_0.declare_sample_delay(0)
        	
        self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_float*1)
        self.blocks_file_source_0 = blocks.file_source(gr.sizeof_gr_complex*1, "/home/nathan/Downloads/WFM-97.9MHz-3.125Msps.dat", False)
        self.analog_wfm_rcv_0 = analog.wfm_rcv(
        	quad_rate=200e3,
        	audio_decimation=int(200e3 / audio_rate),
        )
        self.analog_fm_deemph_0 = analog.fm_deemph(fs=audio_rate, tau=75e-6)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_wfm_rcv_0, 0), (self.pfb_arb_resampler_xxx_0, 0))
        self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.analog_fm_deemph_0, 0))
        self.connect((self.analog_fm_deemph_0, 0), (self.west_timestamp_sink_f_0, 0))
        self.connect((self.west_timestamp_sink_f_0, 0), (self.blocks_null_sink_0, 0))
        self.connect((self.west_timestamp_tagger_ff_0, 0), (self.analog_wfm_rcv_0, 0))
        self.connect((self.blocks_file_source_0, 0), (self.west_timestamp_tagger_ff_0, 0))
Ejemplo n.º 4
0
 def __init__(self, rate, decim, gate=False):
     gr.hier_block2.__init__(self, "fm_demod",
                             gr.io_signature(1, 1, gr.sizeof_gr_complex),
                             gr.io_signature(1, 1, gr.sizeof_float))
     tau = 75.e-6
     deviation = 5.e3
     k = rate / (2 * pi * deviation)
     self.rate = rate
     self.quad = analog.quadrature_demod_cf(k)
     self.squelch = scanner.standard_squelch_ff(gate=gate)
     self.deemph = fm_deemph(rate, tau)
     self.nfilts = 32
     audio_taps = optfir.band_pass(self.nfilts, self.rate * self.nfilts,
                                   250, 300, 3000, 4000, 0.2, 40)
     self.resamp = pfb.arb_resampler_fff(1. / decim, audio_taps)
     self.connect(self, self.quad, self.squelch, self.deemph, self.resamp,
                  self)
Ejemplo n.º 5
0
 def __init__(self, rate, decim, gate=False):
     gr.hier_block2.__init__(self,
                             "fm_demod",
                             gr.io_signature(1,1,gr.sizeof_gr_complex),
                             gr.io_signature(1,1,gr.sizeof_float))
     tau=75.e-6
     deviation = 5.e3
     k=rate/(2*pi*deviation)
     self.rate = rate
     self.quad = analog.quadrature_demod_cf(k)
     self.squelch = scanner.standard_squelch_ff(gate=gate)
     self.deemph = fm_deemph(rate, tau)
     self.nfilts = 32
     audio_taps = optfir.band_pass(self.nfilts,
                                   self.rate*self.nfilts,
                                   250,
                                   300,
                                   3000,
                                   4000,
                                   0.2,
                                   40)
     self.resamp = pfb.arb_resampler_fff(1./decim, audio_taps)
     self.connect(self, self.quad, self.squelch, self.deemph, self.resamp, self)
Ejemplo n.º 6
0
def make_resampler(in_rate, out_rate):
    fractional_cutoff = 0.4
    fractional_transition_width = 0.2
    
    # The rate relative to in_rate for which to design the anti-aliasing filter.
    in_relative_max_rate = min(out_rate, in_rate) / in_rate
    
    in_relative_cutoff = in_relative_max_rate * fractional_cutoff
    in_relative_transition_width = in_relative_max_rate * fractional_transition_width
    
    if _use_rational_resampler and in_rate % 1 == 0 and out_rate % 1 == 0:
        # Note: rational_resampler has this logic built in, but it does not correctly design the filter when decimating <http://gnuradio.org/redmine/issues/745>, so we do it ourselves; but this also allows sharing the calculation details for pfb_ and rational_.
        in_rate = int(in_rate)
        out_rate = int(out_rate)
        common = gcd(in_rate, out_rate)
        interpolation = out_rate // common
        decimation = in_rate // common
        return rational_resampler.rational_resampler_fff(
            interpolation=interpolation,
            decimation=decimation,
            taps=firdes.low_pass(
                interpolation,  # gain compensates for interpolation
                interpolation,  # rational resampler filter runs at the interpolated rate
                in_relative_cutoff,
                in_relative_transition_width))
    else:
        resample_ratio = out_rate / in_rate
        pfbsize = 32  # TODO: justify magic number (taken from gqrx)
        return pfb.arb_resampler_fff(
            resample_ratio,
            firdes.low_pass(
                pfbsize,
                pfbsize,
                in_relative_cutoff,
                in_relative_transition_width),
            pfbsize)
Ejemplo n.º 7
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Keyfob Rx")

        ##################################################
        # Variables
        ##################################################
        self.sps = sps = 5
        self.samp_rate = samp_rate = 48000

        ##################################################
        # Blocks
        ##################################################
        self.wxgui_scopesink2_1 = scopesink2.scope_sink_f(
            self.GetWin(),
            title="Scope Plot",
            sample_rate=3400,
            v_scale=0,
            v_offset=0,
            t_scale=0,
            ac_couple=False,
            xy_mode=False,
            num_inputs=1,
            trig_mode=wxgui.TRIG_MODE_AUTO,
            y_axis_label="Counts",
        )
        self.Add(self.wxgui_scopesink2_1.win)
        self.wxgui_scopesink2_0 = scopesink2.scope_sink_f(
            self.GetWin(),
            title="Scope Plot",
            sample_rate=3400 * 5,
            v_scale=0,
            v_offset=0,
            t_scale=0,
            ac_couple=False,
            xy_mode=False,
            num_inputs=1,
            trig_mode=wxgui.TRIG_MODE_AUTO,
            y_axis_label="Counts",
        )
        self.Add(self.wxgui_scopesink2_0.win)
        self.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_fff(3393.75 * sps /
                                                             1000000.026491,
                                                             taps=None,
                                                             flt_size=32)
        self.pfb_arb_resampler_xxx_0.declare_sample_delay(0)

        self.osmosdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " +
                                               "")
        self.osmosdr_source_0.set_sample_rate(1000000)
        self.osmosdr_source_0.set_center_freq(434400000, 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(2, 0)
        self.osmosdr_source_0.set_if_gain(0, 0)
        self.osmosdr_source_0.set_bb_gain(0, 0)
        self.osmosdr_source_0.set_antenna("", 0)
        self.osmosdr_source_0.set_bandwidth(0, 0)

        self.keyfob_parse_packet_0 = keyfob.parse_packet()
        self.keyfob_manchester_decode_0 = keyfob.manchester_decode()
        self.digital_correlate_access_code_tag_bb_0 = digital.correlate_access_code_tag_bb(
            "10101000", 0, "packet_start")
        self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff(
            sps * (1 + 0.0), 0.25 * 0.175 * 0.175, 0.5, 0.175, 0.05)
        self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb()
        self.blocks_sub_xx_0 = blocks.sub_ff(1)
        self.blocks_moving_average_xx_1 = blocks.moving_average_ff(
            sps, 1.0 / sps, 4000)
        self.blocks_moving_average_xx_0 = blocks.moving_average_ff(
            10000, 1.0 / 10000, 4000)
        self.blocks_divide_xx_0 = blocks.divide_ff(1)
        self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_complex_to_mag_0, 0),
                     (self.blocks_moving_average_xx_0, 0))
        self.connect((self.blocks_complex_to_mag_0, 0),
                     (self.blocks_sub_xx_0, 0))
        self.connect((self.blocks_divide_xx_0, 0),
                     (self.pfb_arb_resampler_xxx_0, 0))
        self.connect((self.blocks_moving_average_xx_0, 0),
                     (self.blocks_divide_xx_0, 1))
        self.connect((self.blocks_moving_average_xx_0, 0),
                     (self.blocks_sub_xx_0, 1))
        self.connect((self.blocks_moving_average_xx_1, 0),
                     (self.digital_clock_recovery_mm_xx_0, 0))
        self.connect((self.blocks_moving_average_xx_1, 0),
                     (self.wxgui_scopesink2_0, 0))
        self.connect((self.blocks_sub_xx_0, 0), (self.blocks_divide_xx_0, 0))
        self.connect((self.digital_binary_slicer_fb_0, 0),
                     (self.keyfob_manchester_decode_0, 0))
        self.connect((self.digital_clock_recovery_mm_xx_0, 0),
                     (self.digital_binary_slicer_fb_0, 0))
        self.connect((self.digital_clock_recovery_mm_xx_0, 0),
                     (self.wxgui_scopesink2_1, 0))
        self.connect((self.digital_correlate_access_code_tag_bb_0, 0),
                     (self.keyfob_parse_packet_0, 0))
        self.connect((self.keyfob_manchester_decode_0, 0),
                     (self.digital_correlate_access_code_tag_bb_0, 0))
        self.connect((self.osmosdr_source_0, 0),
                     (self.blocks_complex_to_mag_0, 0))
        self.connect((self.pfb_arb_resampler_xxx_0, 0),
                     (self.blocks_moving_average_xx_1, 0))
Ejemplo n.º 8
0
    def __init__(self,
                 samp_rate=4E6,
                 audio_rate=8000,
                 record=True,
                 audio_bps=8):
        gr.hier_block2.__init__(self, "TunerDemodAM",
                                gr.io_signature(1, 1, gr.sizeof_gr_complex),
                                gr.io_signature(1, 1, gr.sizeof_float))

        # Default values
        self.center_freq = 0
        squelch_db = -60
        self.agc_ref = 0.1
        self.file_name = "/dev/null"
        self.record = record

        # Decimation values for four stages of decimation
        decims = (5, int(samp_rate / 1E6))

        # Low pass filter taps for decimation by 5
        low_pass_filter_taps_0 = \
            grfilter.firdes_low_pass(1, 1, 0.090, 0.010,
                                     grfilter.firdes.WIN_HAMMING)

        # Frequency translating FIR filter decimating by 5
        self.freq_xlating_fir_filter_ccc = \
            grfilter.freq_xlating_fir_filter_ccc(decims[0],
                                                 low_pass_filter_taps_0,
                                                 self.center_freq, samp_rate)

        # FIR filter decimating by 5
        fir_filter_ccc_0 = grfilter.fir_filter_ccc(decims[0],
                                                   low_pass_filter_taps_0)

        # Low pass filter taps for decimation from samp_rate/25 to 40-79.9 ksps
        # In other words, decimation by int(samp_rate/1E6)
        # 12.5 kHz cutoff for NBFM channel bandwidth
        low_pass_filter_taps_1 = grfilter.firdes_low_pass(
            1, samp_rate / decims[0]**2, 12.5E3, 1E3,
            grfilter.firdes.WIN_HAMMING)

        # FIR filter decimation by int(samp_rate/1E6)
        fir_filter_ccc_1 = grfilter.fir_filter_ccc(decims[1],
                                                   low_pass_filter_taps_1)

        # Non blocking power squelch
        # Squelch level needs to be lower than NBFM or else choppy AM demod
        self.analog_pwr_squelch_cc = analog.pwr_squelch_cc(
            squelch_db, 1e-1, 0, False)

        # AGC with reference set for nomninal 0 dB volume
        # Paramaters tweaked to prevent impulse during squelching
        self.agc3_cc = analog.agc3_cc(1.0, 1E-4, self.agc_ref, 10, 1)
        self.agc3_cc.set_max_gain(65536)

        # AM demod with complex_to_mag()
        # Can't use analog.am_demod_cf() since it won't work with N>2 demods
        am_demod_cf = blocks.complex_to_mag(1)

        # 3.5 kHz cutoff for audio bandwidth
        low_pass_filter_taps_2 = grfilter.firdes_low_pass(1,\
                        samp_rate/(decims[1] * decims[0]**2),\
                        3.5E3, 500, grfilter.firdes.WIN_HAMMING)

        # FIR filter decimating by 5 from 40-79.9 ksps to 8-15.98 ksps
        fir_filter_fff_0 = grfilter.fir_filter_fff(decims[0],
                                                   low_pass_filter_taps_2)

        # Polyphase resampler allows arbitary RF sample rates
        # Takes 8-15.98 ksps to a constant 8 ksps for audio
        pfb_resamp = audio_rate / float(samp_rate / (decims[1] * decims[0]**3))
        pfb_arb_resampler_fff = pfb.arb_resampler_fff(pfb_resamp,
                                                      taps=None,
                                                      flt_size=32)

        # Connect the blocks for the demod
        self.connect(self, self.freq_xlating_fir_filter_ccc)
        self.connect(self.freq_xlating_fir_filter_ccc, fir_filter_ccc_0)
        self.connect(fir_filter_ccc_0, fir_filter_ccc_1)
        self.connect(fir_filter_ccc_1, self.analog_pwr_squelch_cc)
        self.connect(self.analog_pwr_squelch_cc, self.agc3_cc)
        self.connect(self.agc3_cc, am_demod_cf)
        self.connect(am_demod_cf, fir_filter_fff_0)
        self.connect(fir_filter_fff_0, pfb_arb_resampler_fff)
        self.connect(pfb_arb_resampler_fff, self)

        # Need to set this to a very low value of -200 since it is after demod
        # Only want it to gate when the previous squelch has gone to zero
        analog_pwr_squelch_ff = analog.pwr_squelch_ff(-200, 1e-1, 0, True)

        # File sink with single channel and 8 bits/sample
        self.blocks_wavfile_sink = blocks.wavfile_sink(self.file_name, 1,
                                                       audio_rate, audio_bps)

        # Connect the blocks for recording
        self.connect(pfb_arb_resampler_fff, analog_pwr_squelch_ff)
        self.connect(analog_pwr_squelch_ff, self.blocks_wavfile_sink)
Ejemplo n.º 9
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Keyfob Decode Wav")

        ##################################################
        # Variables
        ##################################################
        self.sps = sps = 5
        self.samp_rate = samp_rate = 48000

        ##################################################
        # Blocks
        ##################################################
        self.wxgui_scopesink2_1 = scopesink2.scope_sink_f(
            self.GetWin(),
            title="Scope Plot",
            sample_rate=3400,
            v_scale=0,
            v_offset=0,
            t_scale=0,
            ac_couple=False,
            xy_mode=False,
            num_inputs=1,
            trig_mode=wxgui.TRIG_MODE_AUTO,
            y_axis_label="Counts",
        )
        self.Add(self.wxgui_scopesink2_1.win)
        self.wxgui_scopesink2_0 = scopesink2.scope_sink_f(
            self.GetWin(),
            title="Scope Plot",
            sample_rate=3400 * 5,
            v_scale=0,
            v_offset=0,
            t_scale=0,
            ac_couple=False,
            xy_mode=False,
            num_inputs=1,
            trig_mode=wxgui.TRIG_MODE_AUTO,
            y_axis_label="Counts",
        )
        self.Add(self.wxgui_scopesink2_0.win)
        self.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_fff(3400.0 * sps /
                                                             48000,
                                                             taps=None,
                                                             flt_size=32)
        self.pfb_arb_resampler_xxx_0.declare_sample_delay(0)

        self.keyfob_parse_packet_0 = keyfob.parse_packet()
        self.keyfob_manchester_decode_0 = keyfob.manchester_decode()
        self.digital_correlate_access_code_tag_bb_0 = digital.correlate_access_code_tag_bb(
            "10101000", 0, "packet_start")
        self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff(
            5 * (1 + 0.0), 0.25 * 0.175 * 0.175, 0.5, 0.175, 0.05)
        self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb()
        self.blocks_wavfile_source_0 = blocks.wavfile_source(
            "../gqrx_20150306_154200_434400000.wav", False)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_float * 1,
                                                 samp_rate * 3, True)
        self.blocks_moving_average_xx_1 = blocks.moving_average_ff(
            sps, 1, 4000)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_moving_average_xx_1, 0),
                     (self.digital_clock_recovery_mm_xx_0, 0))
        self.connect((self.blocks_moving_average_xx_1, 0),
                     (self.wxgui_scopesink2_0, 0))
        self.connect((self.blocks_throttle_0, 0),
                     (self.pfb_arb_resampler_xxx_0, 0))
        self.connect((self.blocks_wavfile_source_0, 0),
                     (self.blocks_throttle_0, 0))
        self.connect((self.digital_binary_slicer_fb_0, 0),
                     (self.keyfob_manchester_decode_0, 0))
        self.connect((self.digital_clock_recovery_mm_xx_0, 0),
                     (self.digital_binary_slicer_fb_0, 0))
        self.connect((self.digital_clock_recovery_mm_xx_0, 0),
                     (self.wxgui_scopesink2_1, 0))
        self.connect((self.digital_correlate_access_code_tag_bb_0, 0),
                     (self.keyfob_parse_packet_0, 0))
        self.connect((self.keyfob_manchester_decode_0, 0),
                     (self.digital_correlate_access_code_tag_bb_0, 0))
        self.connect((self.pfb_arb_resampler_xxx_0, 0),
                     (self.blocks_moving_average_xx_1, 0))
Ejemplo n.º 10
0
    def __init__(self,
                 antenna="RX",
                 bb_freq=0.0,
                 bw=0.0,
                 dc_removal="False",
                 decoded_data_file_path="/tmp/.satnogs/data/data",
                 dev_args="",
                 doppler_correction_per_sec=20,
                 enable_iq_dump=0,
                 file_path="test.wav",
                 flip_images=0,
                 gain=0.0,
                 gain_mode="Overall",
                 iq_file_path="/tmp/iq.dat",
                 lo_offset=100e3,
                 other_settings="",
                 ppm=0,
                 rigctl_port=4532,
                 rx_freq=100e6,
                 samp_rate_rx=2048000,
                 soapy_rx_device="driver=rtlsdr",
                 stream_args="",
                 sync=1,
                 tune_args="",
                 udp_IP="127.0.0.1",
                 udp_dump_host="",
                 udp_dump_port=57356,
                 udp_port=16887,
                 waterfall_file_path="/tmp/waterfall.dat"):
        gr.top_block.__init__(self, "NOAA APT Decoder")

        ##################################################
        # Parameters
        ##################################################
        self.antenna = antenna
        self.bb_freq = bb_freq
        self.bw = bw
        self.dc_removal = dc_removal
        self.decoded_data_file_path = decoded_data_file_path
        self.dev_args = dev_args
        self.doppler_correction_per_sec = doppler_correction_per_sec
        self.enable_iq_dump = enable_iq_dump
        self.file_path = file_path
        self.flip_images = flip_images
        self.gain = gain
        self.gain_mode = gain_mode
        self.iq_file_path = iq_file_path
        self.lo_offset = lo_offset
        self.other_settings = other_settings
        self.ppm = ppm
        self.rigctl_port = rigctl_port
        self.rx_freq = rx_freq
        self.samp_rate_rx = samp_rate_rx
        self.soapy_rx_device = soapy_rx_device
        self.stream_args = stream_args
        self.sync = sync
        self.tune_args = tune_args
        self.udp_IP = udp_IP
        self.udp_dump_host = udp_dump_host
        self.udp_dump_port = udp_dump_port
        self.udp_port = udp_port
        self.waterfall_file_path = waterfall_file_path

        ##################################################
        # Variables
        ##################################################
        self.audio_samp_rate = audio_samp_rate = 48000

        ##################################################
        # Blocks
        ##################################################
        self.soapy_source_0_0 = None
        # Make sure that the gain mode is valid
        if (gain_mode not in ['Overall', 'Specific', 'Settings Field']):
            raise ValueError(
                "Wrong gain mode on channel 0. Allowed gain modes: "
                "['Overall', 'Specific', 'Settings Field']")

        dev = soapy_rx_device

        # Stream arguments for every activated stream
        tune_args = [tune_args]
        settings = [other_settings]

        # Setup the device arguments
        dev_args = dev_args

        self.soapy_source_0_0 = soapy.source(1, dev, dev_args, stream_args,
                                             tune_args, settings, samp_rate_rx,
                                             "fc32")

        self.soapy_source_0_0.set_dc_removal(
            0, bool(distutils.util.strtobool(dc_removal)))

        # Set up DC offset. If set to (0, 0) internally the source block
        # will handle the case if no DC offset correction is supported
        self.soapy_source_0_0.set_dc_offset(0, 0)

        # Setup IQ Balance. If set to (0, 0) internally the source block
        # will handle the case if no IQ balance correction is supported
        self.soapy_source_0_0.set_iq_balance(0, 0)

        self.soapy_source_0_0.set_agc(0, False)

        # generic frequency setting should be specified first
        self.soapy_source_0_0.set_frequency(0, rx_freq - lo_offset)

        self.soapy_source_0_0.set_frequency(0, "BB", bb_freq)

        # Setup Frequency correction. If set to 0 internally the source block
        # will handle the case if no frequency correction is supported
        self.soapy_source_0_0.set_frequency_correction(0, ppm)

        self.soapy_source_0_0.set_antenna(0, antenna)

        self.soapy_source_0_0.set_bandwidth(0, bw)

        if (gain_mode != 'Settings Field'):
            # pass is needed, in case the template does not evaluare anything
            pass
            self.soapy_source_0_0.set_gain(0, gain)
        self.satnogs_waterfall_sink_0_0 = satnogs.waterfall_sink(
            4 * 4160 * 4, rx_freq, 10, 1024, waterfall_file_path, 1)
        self.satnogs_ogg_encoder_0 = satnogs.ogg_encoder(
            file_path, audio_samp_rate, 0.8)
        self.satnogs_noaa_apt_sink_1 = satnogs.noaa_apt_sink(
            decoded_data_file_path, 2080, 1800, True, False)
        self.satnogs_iq_sink_0_0 = satnogs.iq_sink(16768, iq_file_path, False,
                                                   enable_iq_dump)
        self.satnogs_doppler_compensation_0 = satnogs.doppler_compensation(
            samp_rate_rx, rx_freq, lo_offset, 4 * 4160 * 4, 1, 0)
        self.rational_resampler_xxx_0_0 = filter.rational_resampler_fff(
            interpolation=1, decimation=4, taps=None, fractional_bw=None)
        self.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_fff(audio_samp_rate /
                                                             (4 * 4160 * 4),
                                                             taps=None,
                                                             flt_size=32)
        self.pfb_arb_resampler_xxx_0.declare_sample_delay(0)
        self.low_pass_filter_0_0 = filter.fir_filter_ccf(
            1,
            firdes.low_pass(1, 4 * 4160 * 4, 4 * 4160 * 1.1, 1e3,
                            firdes.WIN_HAMMING, 6.76))
        self.hilbert_fc_0 = filter.hilbert_fc(65, firdes.WIN_HAMMING, 6.76)
        self.blocks_udp_sink_0_0 = blocks.udp_sink(gr.sizeof_gr_complex * 1,
                                                   udp_dump_host,
                                                   udp_dump_port, 1472, True)
        self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1)
        self.band_pass_filter_0 = filter.fir_filter_fff(
            4,
            firdes.band_pass(1, (4 * 4160 * 4), 500, 4.2e3, 200,
                             firdes.WIN_HAMMING, 6.76))
        self.analog_wfm_rcv_0 = analog.wfm_rcv(
            quad_rate=4 * 4160 * 4,
            audio_decimation=1,
        )

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_wfm_rcv_0, 0), (self.band_pass_filter_0, 0))
        self.connect((self.analog_wfm_rcv_0, 0),
                     (self.pfb_arb_resampler_xxx_0, 0))
        self.connect((self.band_pass_filter_0, 0), (self.hilbert_fc_0, 0))
        self.connect((self.blocks_complex_to_mag_0, 0),
                     (self.rational_resampler_xxx_0_0, 0))
        self.connect((self.hilbert_fc_0, 0), (self.blocks_complex_to_mag_0, 0))
        self.connect((self.low_pass_filter_0_0, 0), (self.analog_wfm_rcv_0, 0))
        self.connect((self.pfb_arb_resampler_xxx_0, 0),
                     (self.satnogs_ogg_encoder_0, 0))
        self.connect((self.rational_resampler_xxx_0_0, 0),
                     (self.satnogs_noaa_apt_sink_1, 0))
        self.connect((self.satnogs_doppler_compensation_0, 0),
                     (self.blocks_udp_sink_0_0, 0))
        self.connect((self.satnogs_doppler_compensation_0, 0),
                     (self.low_pass_filter_0_0, 0))
        self.connect((self.satnogs_doppler_compensation_0, 0),
                     (self.satnogs_iq_sink_0_0, 0))
        self.connect((self.satnogs_doppler_compensation_0, 0),
                     (self.satnogs_waterfall_sink_0_0, 0))
        self.connect((self.soapy_source_0_0, 0),
                     (self.satnogs_doppler_compensation_0, 0))
Ejemplo n.º 11
0
    def __init__(self):
        gr.top_block.__init__(self,
                              "Stereo FM receiver and RDS Decoder",
                              catch_exceptions=True)
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Stereo FM receiver and RDS Decoder")
        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", "rds_rx")

        try:
            if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"):
                self.restoreGeometry(
                    self.settings.value("geometry").toByteArray())
            else:
                self.restoreGeometry(self.settings.value("geometry"))
        except:
            pass

        ##################################################
        # Variables
        ##################################################
        self.freq_offset = freq_offset = 250000
        self.freq = freq = 88.5
        self.volume = volume = 0
        self.samp_rate = samp_rate = 2000000
        self.gain = gain = 25
        self.freq_tune = freq_tune = freq * 1e6 - freq_offset

        ##################################################
        # Blocks
        ##################################################
        self._volume_range = Range(-20, 10, 1, 0, 200)
        self._volume_win = RangeWidget(self._volume_range, self.set_volume,
                                       'Volume', "counter_slider", float,
                                       QtCore.Qt.Horizontal)
        self.top_grid_layout.addWidget(self._volume_win, 1, 0, 1, 1)
        for r in range(1, 2):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 1):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._gain_range = Range(0, 49.6, 1, 25, 200)
        self._gain_win = RangeWidget(self._gain_range, self.set_gain,
                                     'RF Gain', "counter_slider", float,
                                     QtCore.Qt.Horizontal)
        self.top_grid_layout.addWidget(self._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._freq_range = Range(77, 108, 0.1, 88.5, 200)
        self._freq_win = RangeWidget(self._freq_range, self.set_freq,
                                     'Frequency', "counter_slider", float,
                                     QtCore.Qt.Horizontal)
        self.top_grid_layout.addWidget(self._freq_win, 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.rtlsdr_source_0_0 = osmosdr.source(args="numchan=" + str(1) +
                                                " " + '')
        self.rtlsdr_source_0_0.set_time_unknown_pps(osmosdr.time_spec_t())
        self.rtlsdr_source_0_0.set_sample_rate(samp_rate)
        self.rtlsdr_source_0_0.set_center_freq(freq_tune, 0)
        self.rtlsdr_source_0_0.set_freq_corr(0, 0)
        self.rtlsdr_source_0_0.set_dc_offset_mode(0, 0)
        self.rtlsdr_source_0_0.set_iq_balance_mode(0, 0)
        self.rtlsdr_source_0_0.set_gain_mode(False, 0)
        self.rtlsdr_source_0_0.set_gain(14, 0)
        self.rtlsdr_source_0_0.set_if_gain(24, 0)
        self.rtlsdr_source_0_0.set_bb_gain(gain, 0)
        self.rtlsdr_source_0_0.set_antenna('', 0)
        self.rtlsdr_source_0_0.set_bandwidth(0, 0)
        self.root_raised_cosine_filter_0 = filter.fir_filter_ccf(
            2, firdes.root_raised_cosine(1, 19000, 2375, 1, 100))
        self.rds_parser_0 = rds.parser(False, False, 0)
        self.rds_panel_0 = rds.rdsPanel(freq)
        self._rds_panel_0_win = self.rds_panel_0
        self.top_layout.addWidget(self._rds_panel_0_win)
        self.rds_decoder_0 = rds.decoder(False, False)
        self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_f(
            1024,  #size
            window.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate,  #bw
            "",  #name
            1,  #number of inputs
            None  # parent
        )
        self.qtgui_waterfall_sink_x_0.set_update_time(0.10)
        self.qtgui_waterfall_sink_x_0.enable_grid(False)
        self.qtgui_waterfall_sink_x_0.enable_axis_labels(True)

        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 range(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
            window.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate,  #bw
            "",  #name
            1,
            None  # parent
        )
        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)
        self.qtgui_freq_sink_x_0.set_fft_window_normalized(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 range(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.pfb_arb_resampler_xxx_1 = pfb.arb_resampler_fff(240000.0 / 250000,
                                                             taps=None,
                                                             flt_size=32)
        self.pfb_arb_resampler_xxx_1.declare_sample_delay(0)
        self.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_ccf(19000 / 250e3,
                                                             taps=None,
                                                             flt_size=32)
        self.pfb_arb_resampler_xxx_0.declare_sample_delay(0)
        self.freq_xlating_fir_filter_xxx_2 = filter.freq_xlating_fir_filter_fcf(
            5, firdes.low_pass(1.0, 240000, 13e3, 3e3), 38000, 240000)
        self.freq_xlating_fir_filter_xxx_1_0 = filter.freq_xlating_fir_filter_fcc(
            1, firdes.low_pass(2500.0, 250000, 2.6e3, 2e3), 57e3, 250000)
        self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(
            1, firdes.low_pass(1, samp_rate, 80000, 20000), freq_offset,
            samp_rate)
        self.fir_filter_xxx_1 = filter.fir_filter_fff(
            5, firdes.low_pass(1.0, 240000, 13e3, 3e3))
        self.fir_filter_xxx_1.declare_sample_delay(0)
        self.digital_psk_demod_0 = digital.psk.psk_demod(
            constellation_points=2,
            differential=False,
            samples_per_symbol=4,
            excess_bw=0.35,
            phase_bw=6.28 / 100.0,
            timing_bw=6.28 / 100.0,
            mod_code="gray",
            verbose=False,
            log=False)
        self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(2)
        self.blocks_sub_xx_0 = blocks.sub_ff(1)
        self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_ff(
            10**(1. * (volume) / 10))
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_ff(
            10**(1. * (volume) / 10))
        self.blocks_keep_one_in_n_0 = blocks.keep_one_in_n(
            gr.sizeof_char * 1, 2)
        self.blocks_complex_to_real_0 = blocks.complex_to_real(1)
        self.blocks_add_xx_0 = blocks.add_vff(1)
        self.audio_sink_0 = audio.sink(48000, '', True)
        self.analog_wfm_rcv_0 = analog.wfm_rcv(
            quad_rate=samp_rate,
            audio_decimation=8,
        )
        self.analog_fm_deemph_0_0_0 = analog.fm_deemph(fs=48000, tau=75e-6)
        self.analog_fm_deemph_0_0 = analog.fm_deemph(fs=48000, tau=75e-6)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.rds_decoder_0, 'out'),
                         (self.rds_parser_0, 'in'))
        self.msg_connect((self.rds_parser_0, 'out'), (self.rds_panel_0, 'in'))
        self.connect((self.analog_fm_deemph_0_0, 0),
                     (self.blocks_multiply_const_vxx_0_0, 0))
        self.connect((self.analog_fm_deemph_0_0_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.analog_wfm_rcv_0, 0),
                     (self.freq_xlating_fir_filter_xxx_1_0, 0))
        self.connect((self.analog_wfm_rcv_0, 0),
                     (self.pfb_arb_resampler_xxx_1, 0))
        self.connect((self.analog_wfm_rcv_0, 0),
                     (self.qtgui_waterfall_sink_x_0, 0))
        self.connect((self.blocks_add_xx_0, 0),
                     (self.analog_fm_deemph_0_0_0, 0))
        self.connect((self.blocks_complex_to_real_0, 0),
                     (self.blocks_add_xx_0, 1))
        self.connect((self.blocks_complex_to_real_0, 0),
                     (self.blocks_sub_xx_0, 1))
        self.connect((self.blocks_keep_one_in_n_0, 0),
                     (self.digital_diff_decoder_bb_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, 0),
                     (self.audio_sink_0, 1))
        self.connect((self.blocks_sub_xx_0, 0), (self.analog_fm_deemph_0_0, 0))
        self.connect((self.digital_diff_decoder_bb_0, 0),
                     (self.rds_decoder_0, 0))
        self.connect((self.digital_psk_demod_0, 0),
                     (self.blocks_keep_one_in_n_0, 0))
        self.connect((self.fir_filter_xxx_1, 0), (self.blocks_add_xx_0, 0))
        self.connect((self.fir_filter_xxx_1, 0), (self.blocks_sub_xx_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0),
                     (self.analog_wfm_rcv_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0),
                     (self.qtgui_freq_sink_x_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_1_0, 0),
                     (self.pfb_arb_resampler_xxx_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_2, 0),
                     (self.blocks_complex_to_real_0, 0))
        self.connect((self.pfb_arb_resampler_xxx_0, 0),
                     (self.root_raised_cosine_filter_0, 0))
        self.connect((self.pfb_arb_resampler_xxx_1, 0),
                     (self.fir_filter_xxx_1, 0))
        self.connect((self.pfb_arb_resampler_xxx_1, 0),
                     (self.freq_xlating_fir_filter_xxx_2, 0))
        self.connect((self.root_raised_cosine_filter_0, 0),
                     (self.digital_psk_demod_0, 0))
        self.connect((self.rtlsdr_source_0_0, 0),
                     (self.freq_xlating_fir_filter_xxx_0, 0))
Ejemplo n.º 12
0
    def __init__(self, samp_rate=4E6, audio_rate=8000, record=True):
        gr.hier_block2.__init__(self, "TunerDemodAM",
                                gr.io_signature(1, 1, gr.sizeof_gr_complex),
                                gr.io_signature(1, 1, gr.sizeof_float))

        # Default values
        self.center_freq = 0
        squelch_db = -60
        self.agc_ref = 0.1
        self.file_name = "/dev/null"
        self.record = record

        # Decimation values for four stages of decimation
        decims = (5, int(samp_rate/1E6))

        # Low pass filter taps for decimation by 5
        low_pass_filter_taps_0 = \
            grfilter.firdes_low_pass(1, 1, 0.090, 0.010,
                                     grfilter.firdes.WIN_HAMMING)

        # Frequency translating FIR filter decimating by 5
        self.freq_xlating_fir_filter_ccc = \
            grfilter.freq_xlating_fir_filter_ccc(decims[0],
                                                 low_pass_filter_taps_0,
                                                 self.center_freq, samp_rate)

        # FIR filter decimating by 5
        fir_filter_ccc_0 = grfilter.fir_filter_ccc(decims[0],
                                                   low_pass_filter_taps_0)

        # Low pass filter taps for decimation from samp_rate/25 to 40-79.9 ksps
        # In other words, decimation by int(samp_rate/1E6)
        # 12.5 kHz cutoff for NBFM channel bandwidth
        low_pass_filter_taps_1 = grfilter.firdes_low_pass(
            1, samp_rate/decims[0]**2, 12.5E3, 1E3, grfilter.firdes.WIN_HAMMING)

        # FIR filter decimation by int(samp_rate/1E6)
        fir_filter_ccc_1 = grfilter.fir_filter_ccc(decims[1],
                                                   low_pass_filter_taps_1)

        # Non blocking power squelch
        # Squelch level needs to be lower than NBFM or else choppy AM demod
        self.analog_pwr_squelch_cc = analog.pwr_squelch_cc(squelch_db,
                                                           1e-1, 0, False)

        # AGC with reference set for nomninal 0 dB volume
        # Paramaters tweaked to prevent impulse during squelching
        self.agc3_cc = analog.agc3_cc(1.0, 1E-4, self.agc_ref, 10, 1)
        self.agc3_cc.set_max_gain(65536)

        # AM demod with complex_to_mag()
        # Can't use analog.am_demod_cf() since it won't work with N>2 demods
        am_demod_cf = blocks.complex_to_mag(1)

        # 3.5 kHz cutoff for audio bandwidth
        low_pass_filter_taps_2 = grfilter.firdes_low_pass(1,\
                        samp_rate/(decims[1] * decims[0]**2),\
                        3.5E3, 500, grfilter.firdes.WIN_HAMMING)

        # FIR filter decimating by 5 from 40-79.9 ksps to 8-15.98 ksps
        fir_filter_fff_0 = grfilter.fir_filter_fff(decims[0],
                                                   low_pass_filter_taps_2)

        # Polyphase resampler allows arbitary RF sample rates
        # Takes 8-15.98 ksps to a constant 8 ksps for audio
        pfb_resamp = audio_rate/float(samp_rate/(decims[1] * decims[0]**3))
        pfb_arb_resampler_fff = pfb.arb_resampler_fff(pfb_resamp, taps=None,
                                                      flt_size=32)

        # Connect the blocks for the demod
        self.connect(self, self.freq_xlating_fir_filter_ccc)
        self.connect(self.freq_xlating_fir_filter_ccc, fir_filter_ccc_0)
        self.connect(fir_filter_ccc_0, fir_filter_ccc_1)
        self.connect(fir_filter_ccc_1, self.analog_pwr_squelch_cc)
        self.connect(self.analog_pwr_squelch_cc, self.agc3_cc)
        self.connect(self.agc3_cc, am_demod_cf)
        self.connect(am_demod_cf, fir_filter_fff_0)
        self.connect(fir_filter_fff_0, pfb_arb_resampler_fff)
        self.connect(pfb_arb_resampler_fff, self)

        # Need to set this to a very low value of -200 since it is after demod
        # Only want it to gate when the previuos squelch has gone to zero
        analog_pwr_squelch_ff = analog.pwr_squelch_ff(-200, 1e-1, 0, True)

        # File sink with single channel and 8 bits/sample
        self.blocks_wavfile_sink = blocks.wavfile_sink(self.file_name, 1,
                                                       audio_rate, 8)

        # Connect the blocks for recording
        self.connect(pfb_arb_resampler_fff, analog_pwr_squelch_ff)
        self.connect(analog_pwr_squelch_ff, self.blocks_wavfile_sink)
Ejemplo n.º 13
0
    def __init__(self):
        gr.top_block.__init__(self, "Supacars")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Supacars")
        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", "SUPACARS")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.variable_qtgui_label_0_1 = variable_qtgui_label_0_1 = 'Parser Text Output'
        self.variable_qtgui_label_0_0 = variable_qtgui_label_0_0 = 'Raw Text Output'
        self.samp_rate = samp_rate = 48000
        self.rx_volume = rx_volume = 100
        self.rx_gain = rx_gain = 26
        self.lo_off = lo_off = 126e3
        self.init_sample_rate = init_sample_rate = 500e3
        self.corr_thres = corr_thres = 0.5
        self.center_freq = center_freq = 131.725e6

        ##################################################
        # Blocks
        ##################################################
        self._rx_volume_range = Range(1, 500, 1, 100, 200)
        self._rx_volume_win = RangeWidget(self._rx_volume_range,
                                          self.set_rx_volume, "rx_volume",
                                          "counter_slider", float)
        self.top_grid_layout.addWidget(self._rx_volume_win, 3, 0, 1, 2)
        self._rx_gain_range = Range(0, 40, 1, 26, 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, 1, 0, 1, 2)
        self._corr_thres_range = Range(0, 5, 0.01, 0.5, 200)
        self._corr_thres_win = RangeWidget(self._corr_thres_range,
                                           self.set_corr_thres, "corr_thres",
                                           "counter_slider", float)
        self.top_grid_layout.addWidget(self._corr_thres_win, 0, 0, 1, 2)
        self._variable_qtgui_label_0_1_tool_bar = Qt.QToolBar(self)

        if 0:
            self._variable_qtgui_label_0_1_formatter = 0
        else:
            self._variable_qtgui_label_0_1_formatter = lambda x: x

        self._variable_qtgui_label_0_1_tool_bar.addWidget(
            Qt.QLabel('Terminal 2 ' + ": "))
        self._variable_qtgui_label_0_1_label = Qt.QLabel(
            str(
                self._variable_qtgui_label_0_1_formatter(
                    self.variable_qtgui_label_0_1)))
        self._variable_qtgui_label_0_1_tool_bar.addWidget(
            self._variable_qtgui_label_0_1_label)
        self.top_grid_layout.addWidget(self._variable_qtgui_label_0_1_tool_bar,
                                       5, 1, 1, 1)

        self._variable_qtgui_label_0_0_tool_bar = Qt.QToolBar(self)

        if 0:
            self._variable_qtgui_label_0_0_formatter = 0
        else:
            self._variable_qtgui_label_0_0_formatter = lambda x: x

        self._variable_qtgui_label_0_0_tool_bar.addWidget(
            Qt.QLabel('Terminal 1 ' + ": "))
        self._variable_qtgui_label_0_0_label = Qt.QLabel(
            str(
                self._variable_qtgui_label_0_0_formatter(
                    self.variable_qtgui_label_0_0)))
        self._variable_qtgui_label_0_0_tool_bar.addWidget(
            self._variable_qtgui_label_0_0_label)
        self.top_grid_layout.addWidget(self._variable_qtgui_label_0_0_tool_bar,
                                       5, 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_samp_rate(init_sample_rate)
        self.uhd_usrp_source_0.set_center_freq(
            uhd.tune_request(center_freq, lo_off), 0)
        self.uhd_usrp_source_0.set_gain(rx_gain, 0)
        self.uhd_usrp_source_0.set_antenna('TX/RX', 0)
        self.supacars_acarsparser_0 = supacars.acarsparser(False, '')
        self.supacars_acars_0 = supacars.acars(samp_rate, corr_thres)
        self.qtgui_time_sink_x_0 = qtgui.time_sink_f(
            48000,  #size
            samp_rate,  #samp_rate
            "ACARS signal",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0.set_y_axis(-1, 1)

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

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

        if not True:
            self.qtgui_time_sink_x_0.disable_legend()

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

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

        self._qtgui_time_sink_x_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_win, 4, 0, 1,
                                       2)
        self.pyqt_text_output_0_0 = pyqt.text_output()
        self._pyqt_text_output_0_0_win = self.pyqt_text_output_0_0
        self.top_grid_layout.addWidget(self._pyqt_text_output_0_0_win, 6, 1, 1,
                                       1)
        self.pyqt_text_output_0 = pyqt.text_output()
        self._pyqt_text_output_0_win = self.pyqt_text_output_0
        self.top_grid_layout.addWidget(self._pyqt_text_output_0_win, 6, 0, 1,
                                       1)
        self.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_fff(samp_rate /
                                                             init_sample_rate,
                                                             taps=None,
                                                             flt_size=32)
        self.pfb_arb_resampler_xxx_0.declare_sample_delay(0)

        self.low_pass_filter_0 = filter.fir_filter_ccf(
            1,
            firdes.low_pass(rx_volume, init_sample_rate, 5e3, 500,
                            firdes.WIN_HAMMING, 6.76))
        self.dc_blocker_xx_0 = filter.dc_blocker_ff(32, True)
        self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1)
        self.audio_sink_0 = audio.sink(samp_rate, '', True)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.supacars_acars_0, 'raw_output'),
                         (self.pyqt_text_output_0, 'pdus'))
        self.msg_connect((self.supacars_acars_0, 'parser_output'),
                         (self.supacars_acarsparser_0, 'in'))
        self.msg_connect((self.supacars_acarsparser_0, 'parsed_out'),
                         (self.pyqt_text_output_0_0, 'pdus'))
        self.connect((self.blocks_complex_to_mag_0, 0),
                     (self.pfb_arb_resampler_xxx_0, 0))
        self.connect((self.dc_blocker_xx_0, 0), (self.audio_sink_0, 0))
        self.connect((self.dc_blocker_xx_0, 0), (self.qtgui_time_sink_x_0, 0))
        self.connect((self.dc_blocker_xx_0, 0), (self.supacars_acars_0, 0))
        self.connect((self.low_pass_filter_0, 0),
                     (self.blocks_complex_to_mag_0, 0))
        self.connect((self.pfb_arb_resampler_xxx_0, 0),
                     (self.dc_blocker_xx_0, 0))
        self.connect((self.uhd_usrp_source_0, 0), (self.low_pass_filter_0, 0))
Ejemplo n.º 14
0
    def __init__(self):
        gr.top_block.__init__(self, "FM whole-band Channelizer")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("FM whole-band Channelizer")
        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_channelize")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())


        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 3.125e6
        self.gain = gain = 25
        self.pfb_transition_width = pfb_transition_width = 120e3
        self.pfb_samp_rate = pfb_samp_rate = samp_rate
        self.pfb_gain = pfb_gain = 1
        self.pfb_cutoff_freq = pfb_cutoff_freq = 80e3
        self.pfb_attenuation = pfb_attenuation = 60
        self.audio_transition_width = audio_transition_width = 3e3/10
        self.audio_samp_rate = audio_samp_rate = 44.1e3
        self.audio_gain = audio_gain = gain
        self.audio_cutoff_freq = audio_cutoff_freq = 18e3/10
        self.audio_attenuation = audio_attenuation = 80
        self.pfb_taps = pfb_taps = firdes.low_pass_2(pfb_gain, pfb_samp_rate, pfb_cutoff_freq, pfb_transition_width, pfb_attenuation)
        self.audio_taps = audio_taps = firdes.low_pass_2(audio_gain, audio_samp_rate, audio_cutoff_freq, audio_transition_width, audio_attenuation)
        self.pfb_ntaps = pfb_ntaps = pfb_taps.__len__()
        self.channel = channel = 0
        self.audio_rate = audio_rate = 44.1e3
        self.audio_ntaps = audio_ntaps = audio_taps.__len__()

        ##################################################
        # Blocks
        ##################################################
        self._channel_layout = Qt.QVBoxLayout()
        self._channel_tool_bar = Qt.QToolBar(self)
        self._channel_layout.addWidget(self._channel_tool_bar)
        self._channel_tool_bar.addWidget(Qt.QLabel("fm channel"+": "))
        class qwt_counter_pyslot(Qwt.QwtCounter):
            def __init__(self, parent=None):
                Qwt.QwtCounter.__init__(self, parent)
            @pyqtSlot('double')
            def setValue(self, value):
                super(Qwt.QwtCounter, self).setValue(value)
        self._channel_counter = qwt_counter_pyslot()
        self._channel_counter.setRange(0, 125, 1)
        self._channel_counter.setNumButtons(2)
        self._channel_counter.setValue(self.channel)
        self._channel_tool_bar.addWidget(self._channel_counter)
        self._channel_counter.valueChanged.connect(self.set_channel)
        self._channel_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot)
        self._channel_slider.setRange(0, 125, 1)
        self._channel_slider.setValue(self.channel)
        self._channel_slider.setMinimumWidth(125)
        self._channel_slider.valueChanged.connect(self.set_channel)
        self._channel_layout.addWidget(self._channel_slider)
        self.top_layout.addLayout(self._channel_layout)
        self.pfb_decimator_ccf_0 = pfb.decimator_ccf(
        	  15,
        	  (pfb_taps),
        	  channel,
        	  100,
                  True,
                  True)
        self.pfb_decimator_ccf_0.declare_sample_delay(0)
        	
        self.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_fff(
        	   audio_rate / 50e3,
                  taps=(audio_taps),
        	  flt_size=10)
        self.pfb_arb_resampler_xxx_0.declare_sample_delay(0)
        	
        self._gain_layout = Qt.QVBoxLayout()
        self._gain_tool_bar = Qt.QToolBar(self)
        self._gain_layout.addWidget(self._gain_tool_bar)
        self._gain_tool_bar.addWidget(Qt.QLabel("Gain"+": "))
        class qwt_counter_pyslot(Qwt.QwtCounter):
            def __init__(self, parent=None):
                Qwt.QwtCounter.__init__(self, parent)
            @pyqtSlot('double')
            def setValue(self, value):
                super(Qwt.QwtCounter, self).setValue(value)
        self._gain_counter = qwt_counter_pyslot()
        self._gain_counter.setRange(0, 100, 1)
        self._gain_counter.setNumButtons(2)
        self._gain_counter.setValue(self.gain)
        self._gain_tool_bar.addWidget(self._gain_counter)
        self._gain_counter.valueChanged.connect(self.set_gain)
        self._gain_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot)
        self._gain_slider.setRange(0, 100, 1)
        self._gain_slider.setValue(self.gain)
        self._gain_slider.setMinimumWidth(200)
        self._gain_slider.valueChanged.connect(self.set_gain)
        self._gain_layout.addWidget(self._gain_slider)
        self.top_layout.addLayout(self._gain_layout)
        self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_float*1)
        self.blocks_file_source_0 = blocks.file_source(gr.sizeof_gr_complex*1, "/home/nathan/Downloads/WFM-97.9MHz-3.125Msps.dat", True)
        self.audio_sink_0 = audio.sink(int(audio_rate), "", True)
        self.analog_wfm_rcv_0 = analog.wfm_rcv(
        	quad_rate=200e3,
        	audio_decimation=int(200e3 / audio_rate),
        )
        self.analog_fm_deemph_0 = analog.fm_deemph(fs=audio_rate, tau=75e-6)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.pfb_decimator_ccf_0, 0), (self.analog_wfm_rcv_0, 0))
        self.connect((self.analog_wfm_rcv_0, 0), (self.pfb_arb_resampler_xxx_0, 0))
        self.connect((self.blocks_file_source_0, 0), (self.pfb_decimator_ccf_0, 0))
        self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.analog_fm_deemph_0, 0))
        self.connect((self.analog_fm_deemph_0, 0), (self.audio_sink_0, 0))
        self.connect((self.analog_fm_deemph_0, 0), (self.blocks_null_sink_0, 0))
Ejemplo n.º 15
0
    def __init__(self,
                 antenna="",
                 baudrate=9600.0,
                 bb_freq=0.0,
                 bw=0.0,
                 dc_removal="False",
                 decoded_data_file_path="/tmp/.satnogs/data/data",
                 dev_args="",
                 doppler_correction_per_sec=20,
                 enable_iq_dump=0,
                 file_path="test.wav",
                 framing="ax25",
                 gain=0.0,
                 gain_mode="Overall",
                 iq_file_path="/tmp/iq.dat",
                 lo_offset=100e3,
                 other_settings="",
                 ppm=0,
                 rigctl_port=4532,
                 rx_freq=100e6,
                 samp_rate_rx=0.0,
                 soapy_rx_device="driver=invalid",
                 stream_args="",
                 tune_args="",
                 udp_IP="127.0.0.1",
                 udp_dump_dest='127.0.0.1',
                 udp_dump_port=7355,
                 udp_port=16887,
                 waterfall_file_path="/tmp/waterfall.dat"):
        gr.top_block.__init__(self, "satnogs_fsk")

        ##################################################
        # Parameters
        ##################################################
        self.antenna = antenna
        self.baudrate = baudrate
        self.bb_freq = bb_freq
        self.bw = bw
        self.dc_removal = dc_removal
        self.decoded_data_file_path = decoded_data_file_path
        self.dev_args = dev_args
        self.doppler_correction_per_sec = doppler_correction_per_sec
        self.enable_iq_dump = enable_iq_dump
        self.file_path = file_path
        self.framing = framing
        self.gain = gain
        self.gain_mode = gain_mode
        self.iq_file_path = iq_file_path
        self.lo_offset = lo_offset
        self.other_settings = other_settings
        self.ppm = ppm
        self.rigctl_port = rigctl_port
        self.rx_freq = rx_freq
        self.samp_rate_rx = samp_rate_rx
        self.soapy_rx_device = soapy_rx_device
        self.stream_args = stream_args
        self.tune_args = tune_args
        self.udp_IP = udp_IP
        self.udp_dump_dest = udp_dump_dest
        self.udp_dump_port = udp_dump_port
        self.udp_port = udp_port
        self.waterfall_file_path = waterfall_file_path

        ##################################################
        # Variables
        ##################################################
        self.variable_ax25_decoder_0 = variable_ax25_decoder_0 = satnogs.ax25_decoder_make(
            'GND', 0, True, True, True, 1024)
        self.variable_ax100_mode6_decoder_0 = variable_ax100_mode6_decoder_0 = satnogs.ax100_decoder_mode6_make(
            satnogs.crc.CRC32_C, satnogs.whitening_make_ccsds(True), True)
        self.variable_ax100_mode5_decoder_0 = variable_ax100_mode5_decoder_0 = satnogs.ax100_decoder_mode5_make(
            [], 0, [0x93, 0x0B, 0x51, 0xDE], 3, satnogs.crc.CRC32_C,
            satnogs.whitening.make_ccsds(True), True)
        self.audio_samp_rate = audio_samp_rate = 48000
        self.decimation = decimation = max(
            4, satnogs.find_decimation(baudrate, 2, audio_samp_rate))
        self.available_framings = available_framings = {
            'ax25': variable_ax25_decoder_0,
            'ax100_mode5': variable_ax100_mode5_decoder_0,
            'ax100_mode6': variable_ax100_mode6_decoder_0
        }

        ##################################################
        # Blocks
        ##################################################
        self.soapy_source_0_0 = None
        # Make sure that the gain mode is valid
        if (gain_mode not in ['Overall', 'Specific', 'Settings Field']):
            raise ValueError(
                "Wrong gain mode on channel 0. Allowed gain modes: "
                "['Overall', 'Specific', 'Settings Field']")

        dev = soapy_rx_device

        # Stream arguments for every activated stream
        tune_args = [tune_args]
        settings = [other_settings]

        # Setup the device arguments
        dev_args = dev_args

        self.soapy_source_0_0 = soapy.source(1, dev, dev_args, stream_args,
                                             tune_args, settings, samp_rate_rx,
                                             "fc32")

        self.soapy_source_0_0.set_dc_removal(
            0, bool(distutils.util.strtobool(dc_removal)))

        # Set up DC offset. If set to (0, 0) internally the source block
        # will handle the case if no DC offset correction is supported
        self.soapy_source_0_0.set_dc_offset(0, 0)

        # Setup IQ Balance. If set to (0, 0) internally the source block
        # will handle the case if no IQ balance correction is supported
        self.soapy_source_0_0.set_iq_balance(0, 0)

        self.soapy_source_0_0.set_agc(0, False)

        # generic frequency setting should be specified first
        self.soapy_source_0_0.set_frequency(0, rx_freq - lo_offset)

        self.soapy_source_0_0.set_frequency(0, "BB", bb_freq)

        # Setup Frequency correction. If set to 0 internally the source block
        # will handle the case if no frequency correction is supported
        self.soapy_source_0_0.set_frequency_correction(0, ppm)

        self.soapy_source_0_0.set_antenna(0, antenna)

        self.soapy_source_0_0.set_bandwidth(0, bw)

        if (gain_mode != 'Settings Field'):
            # pass is needed, in case the template does not evaluare anything
            pass
            self.soapy_source_0_0.set_gain(0, gain)
        self.satnogs_waterfall_sink_0 = satnogs.waterfall_sink(
            baudrate * decimation, rx_freq, 10, 1024, waterfall_file_path, 1)
        self.satnogs_udp_msg_sink_0_0 = satnogs.udp_msg_sink(
            udp_IP, udp_port, 1500)
        self.satnogs_tcp_rigctl_msg_source_0 = satnogs.tcp_rigctl_msg_source(
            "127.0.0.1", rigctl_port, False,
            int(1000.0 / doppler_correction_per_sec) + 1, 1500)
        self.satnogs_ogg_encoder_0 = satnogs.ogg_encoder(
            file_path, audio_samp_rate, 1.0)
        self.satnogs_json_converter_0 = satnogs.json_converter()
        self.satnogs_iq_sink_0 = satnogs.iq_sink(16768, iq_file_path, False,
                                                 enable_iq_dump)
        self.satnogs_frame_file_sink_0_1_0 = satnogs.frame_file_sink(
            decoded_data_file_path, 0)
        self.satnogs_frame_decoder_0_0 = satnogs.frame_decoder(
            available_framings[framing], 1 * 1)
        self.satnogs_doppler_compensation_0 = satnogs.doppler_compensation(
            samp_rate_rx, rx_freq, lo_offset, baudrate * decimation, 1, 0)
        self.pfb_arb_resampler_xxx_1 = pfb.arb_resampler_fff(
            (audio_samp_rate) / (baudrate * 2), taps=None, flt_size=32)
        self.pfb_arb_resampler_xxx_1.declare_sample_delay(0)
        self.low_pass_filter_0_0 = filter.fir_filter_ccf(
            1,
            firdes.low_pass(1, baudrate * decimation, baudrate * 1.25,
                            baudrate / 2.0, firdes.WIN_HAMMING, 6.76))
        self.low_pass_filter_0 = filter.fir_filter_ccf(
            decimation // 2,
            firdes.low_pass(1, baudrate * decimation, 0.625 * baudrate,
                            baudrate / 8.0, firdes.WIN_HAMMING, 6.76))
        self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff(
            2, 2 * math.pi / 100, 0.5, 0.5 / 8.0, 0.01)
        self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb()
        self.dc_blocker_xx_0_0 = filter.dc_blocker_ff(1024, True)
        self.dc_blocker_xx_0 = filter.dc_blocker_ff(1024, True)
        self.blocks_vco_c_0 = blocks.vco_c(baudrate * decimation,
                                           -baudrate * decimation, 1.0)
        self.blocks_udp_sink_0_0 = blocks.udp_sink(gr.sizeof_gr_complex * 1,
                                                   udp_dump_dest,
                                                   udp_dump_port + 1, 1472,
                                                   True)
        self.blocks_udp_sink_0 = blocks.udp_sink(gr.sizeof_short * 1,
                                                 udp_dump_dest, udp_dump_port,
                                                 1472, True)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_moving_average_xx_0 = blocks.moving_average_ff(
            1024, 1.0 / 1024.0, 4096, 1)
        self.blocks_float_to_short_0 = blocks.float_to_short(1, 16383.0)
        self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex * 1, 1024 // 2)
        self.analog_quadrature_demod_cf_0_0_0_0 = analog.quadrature_demod_cf(
            1.0)
        self.analog_quadrature_demod_cf_0_0_0 = analog.quadrature_demod_cf(0.9)
        self.analog_quadrature_demod_cf_0_0 = analog.quadrature_demod_cf(1.2)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.satnogs_frame_decoder_0_0, 'out'),
                         (self.satnogs_json_converter_0, 'in'))
        self.msg_connect((self.satnogs_json_converter_0, 'out'),
                         (self.satnogs_frame_file_sink_0_1_0, 'frame'))
        self.msg_connect((self.satnogs_json_converter_0, 'out'),
                         (self.satnogs_udp_msg_sink_0_0, 'in'))
        self.msg_connect((self.satnogs_tcp_rigctl_msg_source_0, 'freq'),
                         (self.satnogs_doppler_compensation_0, 'doppler'))
        self.connect((self.analog_quadrature_demod_cf_0_0, 0),
                     (self.dc_blocker_xx_0, 0))
        self.connect((self.analog_quadrature_demod_cf_0_0_0, 0),
                     (self.pfb_arb_resampler_xxx_1, 0))
        self.connect((self.analog_quadrature_demod_cf_0_0_0_0, 0),
                     (self.blocks_moving_average_xx_0, 0))
        self.connect((self.blocks_delay_0, 0), (self.blocks_multiply_xx_0, 0))
        self.connect((self.blocks_float_to_short_0, 0),
                     (self.blocks_udp_sink_0, 0))
        self.connect((self.blocks_moving_average_xx_0, 0),
                     (self.blocks_vco_c_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0),
                     (self.low_pass_filter_0, 0))
        self.connect((self.blocks_vco_c_0, 0), (self.blocks_multiply_xx_0, 1))
        self.connect((self.dc_blocker_xx_0, 0),
                     (self.digital_clock_recovery_mm_xx_0, 0))
        self.connect((self.dc_blocker_xx_0_0, 0),
                     (self.blocks_float_to_short_0, 0))
        self.connect((self.dc_blocker_xx_0_0, 0),
                     (self.satnogs_ogg_encoder_0, 0))
        self.connect((self.digital_binary_slicer_fb_0, 0),
                     (self.satnogs_frame_decoder_0_0, 0))
        self.connect((self.digital_clock_recovery_mm_xx_0, 0),
                     (self.digital_binary_slicer_fb_0, 0))
        self.connect((self.low_pass_filter_0, 0),
                     (self.analog_quadrature_demod_cf_0_0, 0))
        self.connect((self.low_pass_filter_0, 0),
                     (self.analog_quadrature_demod_cf_0_0_0, 0))
        self.connect((self.low_pass_filter_0_0, 0),
                     (self.analog_quadrature_demod_cf_0_0_0_0, 0))
        self.connect((self.pfb_arb_resampler_xxx_1, 0),
                     (self.dc_blocker_xx_0_0, 0))
        self.connect((self.satnogs_doppler_compensation_0, 0),
                     (self.blocks_delay_0, 0))
        self.connect((self.satnogs_doppler_compensation_0, 0),
                     (self.blocks_udp_sink_0_0, 0))
        self.connect((self.satnogs_doppler_compensation_0, 0),
                     (self.low_pass_filter_0_0, 0))
        self.connect((self.satnogs_doppler_compensation_0, 0),
                     (self.satnogs_iq_sink_0, 0))
        self.connect((self.satnogs_doppler_compensation_0, 0),
                     (self.satnogs_waterfall_sink_0, 0))
        self.connect((self.soapy_source_0_0, 0),
                     (self.satnogs_doppler_compensation_0, 0))
Ejemplo n.º 16
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Keyfob Rx")

        ##################################################
        # Variables
        ##################################################
        self.sps = sps = 5
        self.samp_rate = samp_rate = 48000

        ##################################################
        # Blocks
        ##################################################
        self.wxgui_scopesink2_1 = scopesink2.scope_sink_f(
        	self.GetWin(),
        	title="Scope Plot",
        	sample_rate=3400,
        	v_scale=0,
        	v_offset=0,
        	t_scale=0,
        	ac_couple=False,
        	xy_mode=False,
        	num_inputs=1,
        	trig_mode=wxgui.TRIG_MODE_AUTO,
        	y_axis_label="Counts",
        )
        self.Add(self.wxgui_scopesink2_1.win)
        self.wxgui_scopesink2_0 = scopesink2.scope_sink_f(
        	self.GetWin(),
        	title="Scope Plot",
        	sample_rate=3400 * 5,
        	v_scale=0,
        	v_offset=0,
        	t_scale=0,
        	ac_couple=False,
        	xy_mode=False,
        	num_inputs=1,
        	trig_mode=wxgui.TRIG_MODE_AUTO,
        	y_axis_label="Counts",
        )
        self.Add(self.wxgui_scopesink2_0.win)
        self.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_fff(
        	  3393.75*sps/1000000.026491,
                  taps=None,
        	  flt_size=32)
        self.pfb_arb_resampler_xxx_0.declare_sample_delay(0)
        	
        self.osmosdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + "" )
        self.osmosdr_source_0.set_sample_rate(1000000)
        self.osmosdr_source_0.set_center_freq(434400000, 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(2, 0)
        self.osmosdr_source_0.set_if_gain(0, 0)
        self.osmosdr_source_0.set_bb_gain(0, 0)
        self.osmosdr_source_0.set_antenna("", 0)
        self.osmosdr_source_0.set_bandwidth(0, 0)
          
        self.keyfob_parse_packet_0 = keyfob.parse_packet()
        self.keyfob_manchester_decode_0 = keyfob.manchester_decode()
        self.digital_correlate_access_code_tag_bb_0 = digital.correlate_access_code_tag_bb("10101000", 0, "packet_start")
        self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff(sps*(1+0.0), 0.25*0.175*0.175, 0.5, 0.175, 0.05)
        self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb()
        self.blocks_sub_xx_0 = blocks.sub_ff(1)
        self.blocks_moving_average_xx_1 = blocks.moving_average_ff(sps, 1.0/sps, 4000)
        self.blocks_moving_average_xx_0 = blocks.moving_average_ff(10000, 1.0/10000, 4000)
        self.blocks_divide_xx_0 = blocks.divide_ff(1)
        self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_complex_to_mag_0, 0), (self.blocks_moving_average_xx_0, 0))    
        self.connect((self.blocks_complex_to_mag_0, 0), (self.blocks_sub_xx_0, 0))    
        self.connect((self.blocks_divide_xx_0, 0), (self.pfb_arb_resampler_xxx_0, 0))    
        self.connect((self.blocks_moving_average_xx_0, 0), (self.blocks_divide_xx_0, 1))    
        self.connect((self.blocks_moving_average_xx_0, 0), (self.blocks_sub_xx_0, 1))    
        self.connect((self.blocks_moving_average_xx_1, 0), (self.digital_clock_recovery_mm_xx_0, 0))    
        self.connect((self.blocks_moving_average_xx_1, 0), (self.wxgui_scopesink2_0, 0))    
        self.connect((self.blocks_sub_xx_0, 0), (self.blocks_divide_xx_0, 0))    
        self.connect((self.digital_binary_slicer_fb_0, 0), (self.keyfob_manchester_decode_0, 0))    
        self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.digital_binary_slicer_fb_0, 0))    
        self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.wxgui_scopesink2_1, 0))    
        self.connect((self.digital_correlate_access_code_tag_bb_0, 0), (self.keyfob_parse_packet_0, 0))    
        self.connect((self.keyfob_manchester_decode_0, 0), (self.digital_correlate_access_code_tag_bb_0, 0))    
        self.connect((self.osmosdr_source_0, 0), (self.blocks_complex_to_mag_0, 0))    
        self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.blocks_moving_average_xx_1, 0))    
Ejemplo n.º 17
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(
            self, title="Stereo FM receiver and RDS Decoder")

        ##################################################
        # Variables
        ##################################################
        self.freq_offset = freq_offset = 250000
        self.freq = freq = 97e6
        self.volume = volume = -3
        self.samp_rate = samp_rate = 2000000
        self.gain = gain = 20
        self.freq_tune = freq_tune = freq - freq_offset

        ##################################################
        # Blocks
        ##################################################
        _volume_sizer = wx.BoxSizer(wx.VERTICAL)
        self._volume_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_volume_sizer,
            value=self.volume,
            callback=self.set_volume,
            label='Volume',
            converter=forms.float_converter(),
            proportion=0,
        )
        self._volume_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_volume_sizer,
            value=self.volume,
            callback=self.set_volume,
            minimum=-20,
            maximum=10,
            num_steps=300,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_volume_sizer, 0, 1, 1, 1)
        self.nb = self.nb = wx.Notebook(self.GetWin(), style=wx.NB_TOP)
        self.nb.AddPage(grc_wxgui.Panel(self.nb), "BB")
        self.nb.AddPage(grc_wxgui.Panel(self.nb), "Demod")
        self.nb.AddPage(grc_wxgui.Panel(self.nb), "Waterfall")
        self.nb.AddPage(grc_wxgui.Panel(self.nb), "L+R")
        self.nb.AddPage(grc_wxgui.Panel(self.nb), "L-R")
        self.nb.AddPage(grc_wxgui.Panel(self.nb), "RDS")
        self.nb.AddPage(grc_wxgui.Panel(self.nb), "Const")
        self.GridAdd(self.nb, 2, 0, 1, 2)
        _gain_sizer = wx.BoxSizer(wx.VERTICAL)
        self._gain_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_gain_sizer,
            value=self.gain,
            callback=self.set_gain,
            label='RF Gain',
            converter=forms.float_converter(),
            proportion=0,
        )
        self._gain_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_gain_sizer,
            value=self.gain,
            callback=self.set_gain,
            minimum=0,
            maximum=49.6,
            num_steps=124,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_gain_sizer, 0, 0, 1, 1)
        _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=107.9e6,
            num_steps=200,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_freq_sizer, 1, 0, 1, 2)
        self.wxgui_waterfallsink2_0 = waterfallsink2.waterfall_sink_f(
            self.nb.GetPage(2).GetWin(),
            baseband_freq=0,
            dynamic_range=100,
            ref_level=0,
            ref_scale=2.0,
            sample_rate=250000,
            fft_size=512,
            fft_rate=15,
            average=False,
            avg_alpha=None,
            title='Waterfall Plot',
        )
        self.nb.GetPage(2).Add(self.wxgui_waterfallsink2_0.win)
        self.wxgui_scopesink2_1 = scopesink2.scope_sink_c(
            self.nb.GetPage(6).GetWin(),
            title='Scope Plot',
            sample_rate=2375 * 4,
            v_scale=0.4,
            v_offset=0,
            t_scale=0,
            ac_couple=False,
            xy_mode=True,
            num_inputs=1,
            trig_mode=wxgui.TRIG_MODE_AUTO,
            y_axis_label='Counts',
        )
        self.nb.GetPage(6).Add(self.wxgui_scopesink2_1.win)
        self.wxgui_fftsink2_0_0_0_1_0_1 = fftsink2.fft_sink_c(
            self.nb.GetPage(5).GetWin(),
            baseband_freq=0,
            y_per_div=10,
            y_divs=10,
            ref_level=0,
            ref_scale=2.0,
            sample_rate=19000,
            fft_size=1024,
            fft_rate=15,
            average=False,
            avg_alpha=None,
            title='RDS',
            peak_hold=False,
        )
        self.nb.GetPage(5).Add(self.wxgui_fftsink2_0_0_0_1_0_1.win)
        self.wxgui_fftsink2_0_0_0_1 = fftsink2.fft_sink_f(
            self.nb.GetPage(4).GetWin(),
            baseband_freq=0,
            y_per_div=10,
            y_divs=10,
            ref_level=0,
            ref_scale=2.0,
            sample_rate=48000,
            fft_size=1024,
            fft_rate=15,
            average=False,
            avg_alpha=None,
            title='L-R',
            peak_hold=False,
        )
        self.nb.GetPage(4).Add(self.wxgui_fftsink2_0_0_0_1.win)
        self.wxgui_fftsink2_0_0_0 = fftsink2.fft_sink_f(
            self.nb.GetPage(3).GetWin(),
            baseband_freq=0,
            y_per_div=10,
            y_divs=10,
            ref_level=0,
            ref_scale=2.0,
            sample_rate=48000,
            fft_size=1024,
            fft_rate=15,
            average=False,
            avg_alpha=None,
            title='L+R',
            peak_hold=False,
        )
        self.nb.GetPage(3).Add(self.wxgui_fftsink2_0_0_0.win)
        self.wxgui_fftsink2_0_0 = fftsink2.fft_sink_f(
            self.nb.GetPage(1).GetWin(),
            baseband_freq=0,
            y_per_div=10,
            y_divs=10,
            ref_level=0,
            ref_scale=2.0,
            sample_rate=250000,
            fft_size=1024,
            fft_rate=15,
            average=True,
            avg_alpha=0.8,
            title='FM Demod',
            peak_hold=False,
        )
        self.nb.GetPage(1).Add(self.wxgui_fftsink2_0_0.win)
        self.wxgui_fftsink2_0 = fftsink2.fft_sink_c(
            self.nb.GetPage(0).GetWin(),
            baseband_freq=0,
            y_per_div=10,
            y_divs=10,
            ref_level=-30,
            ref_scale=2.0,
            sample_rate=samp_rate,
            fft_size=1024,
            fft_rate=15,
            average=True,
            avg_alpha=0.8,
            title='Baseband',
            peak_hold=False,
        )
        self.nb.GetPage(0).Add(self.wxgui_fftsink2_0.win)
        self.rtlsdr_source_0_0 = osmosdr.source(args="numchan=" + str(1) +
                                                " " + '')
        self.rtlsdr_source_0_0.set_sample_rate(samp_rate)
        self.rtlsdr_source_0_0.set_center_freq(freq_tune, 0)
        self.rtlsdr_source_0_0.set_freq_corr(0, 0)
        self.rtlsdr_source_0_0.set_dc_offset_mode(0, 0)
        self.rtlsdr_source_0_0.set_iq_balance_mode(0, 0)
        self.rtlsdr_source_0_0.set_gain_mode(False, 0)
        self.rtlsdr_source_0_0.set_gain(14, 0)
        self.rtlsdr_source_0_0.set_if_gain(24, 0)
        self.rtlsdr_source_0_0.set_bb_gain(gain, 0)
        self.rtlsdr_source_0_0.set_antenna('', 0)
        self.rtlsdr_source_0_0.set_bandwidth(0, 0)

        self.root_raised_cosine_filter_0 = filter.fir_filter_ccf(
            2, firdes.root_raised_cosine(1, 19000, 2375, 1, 100))
        self.rftap_rftap_encap_0 = rftap.rftap_encap(3, -1, 'rds')
        self.pfb_arb_resampler_xxx_1 = pfb.arb_resampler_fff(240000.0 / 250000,
                                                             taps=None,
                                                             flt_size=32)
        self.pfb_arb_resampler_xxx_1.declare_sample_delay(0)

        self.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_ccf(19000 / 250e3,
                                                             taps=None,
                                                             flt_size=32)
        self.pfb_arb_resampler_xxx_0.declare_sample_delay(0)

        self.gr_rds_parser_0 = rds.parser(True, False, 0)
        self.gr_rds_panel_0 = rds.rdsPanel(freq, self.GetWin())
        self.Add(self.gr_rds_panel_0.panel)
        self.gr_rds_decoder_0 = rds.decoder(False, False)
        self.freq_xlating_fir_filter_xxx_2 = filter.freq_xlating_fir_filter_fcf(
            5, (firdes.low_pass(1.0, 240000, 13e3, 3e3, firdes.WIN_HAMMING)),
            38000, 240000)
        self.freq_xlating_fir_filter_xxx_1_0 = filter.freq_xlating_fir_filter_fcc(
            1,
            (firdes.low_pass(2500.0, 250000, 2.6e3, 2e3, firdes.WIN_HAMMING)),
            57e3, 250000)
        self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(
            1, (firdes.low_pass(1, samp_rate, 80000, 20000)), freq_offset,
            samp_rate)
        self.fir_filter_xxx_1 = filter.fir_filter_fff(
            5, (firdes.low_pass(1.0, 240000, 13e3, 3e3, firdes.WIN_HAMMING)))
        self.fir_filter_xxx_1.declare_sample_delay(0)
        self.digital_psk_demod_0 = digital.psk.psk_demod(
            constellation_points=2,
            differential=False,
            samples_per_symbol=4,
            excess_bw=0.35,
            phase_bw=6.28 / 100.0,
            timing_bw=6.28 / 100.0,
            mod_code="gray",
            verbose=False,
            log=False,
        )
        self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(2)
        self.blocks_sub_xx_0 = blocks.sub_ff(1)
        self.blocks_socket_pdu_0 = blocks.socket_pdu("UDP_CLIENT", '127.0.0.1',
                                                     '52001', 10000, False)
        self.blocks_pdu_set_0 = blocks.pdu_set(pmt.to_pmt("nomfreq"),
                                               pmt.to_pmt(freq))
        self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vff(
            (10**(1. * (volume) / 10), ))
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff(
            (10**(1. * (volume) / 10), ))
        self.blocks_keep_one_in_n_0 = blocks.keep_one_in_n(
            gr.sizeof_char * 1, 2)
        self.blocks_complex_to_real_0 = blocks.complex_to_real(1)
        self.blocks_add_xx_0 = blocks.add_vff(1)
        self.audio_sink_0 = audio.sink(48000, '', True)
        self.analog_wfm_rcv_0 = analog.wfm_rcv(
            quad_rate=samp_rate,
            audio_decimation=8,
        )
        self.analog_fm_deemph_0_0_0 = analog.fm_deemph(fs=48000, tau=75e-6)
        self.analog_fm_deemph_0_0 = analog.fm_deemph(fs=48000, tau=75e-6)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_pdu_set_0, 'pdus'),
                         (self.rftap_rftap_encap_0, 'in'))
        self.msg_connect((self.gr_rds_decoder_0, 'out'),
                         (self.blocks_pdu_set_0, 'pdus'))
        self.msg_connect((self.gr_rds_decoder_0, 'out'),
                         (self.gr_rds_parser_0, 'in'))
        self.msg_connect((self.gr_rds_parser_0, 'out'),
                         (self.gr_rds_panel_0, 'in'))
        self.msg_connect((self.rftap_rftap_encap_0, 'out'),
                         (self.blocks_socket_pdu_0, 'pdus'))
        self.connect((self.analog_fm_deemph_0_0, 0),
                     (self.blocks_multiply_const_vxx_0_0, 0))
        self.connect((self.analog_fm_deemph_0_0_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.analog_wfm_rcv_0, 0),
                     (self.freq_xlating_fir_filter_xxx_1_0, 0))
        self.connect((self.analog_wfm_rcv_0, 0),
                     (self.pfb_arb_resampler_xxx_1, 0))
        self.connect((self.analog_wfm_rcv_0, 0), (self.wxgui_fftsink2_0_0, 0))
        self.connect((self.analog_wfm_rcv_0, 0),
                     (self.wxgui_waterfallsink2_0, 0))
        self.connect((self.blocks_add_xx_0, 0),
                     (self.analog_fm_deemph_0_0_0, 0))
        self.connect((self.blocks_complex_to_real_0, 0),
                     (self.blocks_add_xx_0, 1))
        self.connect((self.blocks_complex_to_real_0, 0),
                     (self.blocks_sub_xx_0, 1))
        self.connect((self.blocks_complex_to_real_0, 0),
                     (self.wxgui_fftsink2_0_0_0_1, 0))
        self.connect((self.blocks_keep_one_in_n_0, 0),
                     (self.digital_diff_decoder_bb_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, 0),
                     (self.audio_sink_0, 1))
        self.connect((self.blocks_sub_xx_0, 0), (self.analog_fm_deemph_0_0, 0))
        self.connect((self.digital_diff_decoder_bb_0, 0),
                     (self.gr_rds_decoder_0, 0))
        self.connect((self.digital_psk_demod_0, 0),
                     (self.blocks_keep_one_in_n_0, 0))
        self.connect((self.fir_filter_xxx_1, 0), (self.blocks_add_xx_0, 0))
        self.connect((self.fir_filter_xxx_1, 0), (self.blocks_sub_xx_0, 0))
        self.connect((self.fir_filter_xxx_1, 0),
                     (self.wxgui_fftsink2_0_0_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0),
                     (self.analog_wfm_rcv_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_1_0, 0),
                     (self.pfb_arb_resampler_xxx_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_2, 0),
                     (self.blocks_complex_to_real_0, 0))
        self.connect((self.pfb_arb_resampler_xxx_0, 0),
                     (self.root_raised_cosine_filter_0, 0))
        self.connect((self.pfb_arb_resampler_xxx_0, 0),
                     (self.wxgui_fftsink2_0_0_0_1_0_1, 0))
        self.connect((self.pfb_arb_resampler_xxx_1, 0),
                     (self.fir_filter_xxx_1, 0))
        self.connect((self.pfb_arb_resampler_xxx_1, 0),
                     (self.freq_xlating_fir_filter_xxx_2, 0))
        self.connect((self.root_raised_cosine_filter_0, 0),
                     (self.digital_psk_demod_0, 0))
        self.connect((self.root_raised_cosine_filter_0, 0),
                     (self.wxgui_scopesink2_1, 0))
        self.connect((self.rtlsdr_source_0_0, 0),
                     (self.freq_xlating_fir_filter_xxx_0, 0))
Ejemplo n.º 18
0
    def __init__(self):
        gr.top_block.__init__(self, "Ham2Mon NBFM Receiver Flow Example")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Ham2Mon NBFM Receiver Flow 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", "nbfm_flow_example")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 1E6
        self.initial_decim = initial_decim = 5
        self.samp_ratio = samp_ratio = samp_rate/1E6
        self.final_rate = final_rate = samp_rate/initial_decim**2/int(samp_rate/1E6)
        
        self.variable_low_pass_filter_taps_2 = variable_low_pass_filter_taps_2 = firdes.low_pass(1.0, final_rate, 3500, 500, firdes.WIN_HAMMING, 6.76)
          
        
        self.variable_low_pass_filter_taps_1 = variable_low_pass_filter_taps_1 = firdes.low_pass(1.0, samp_rate/25, 12.5E3, 1E3, firdes.WIN_HAMMING, 6.76)
          
        
        self.variable_low_pass_filter_taps_0 = variable_low_pass_filter_taps_0 = firdes.low_pass(1.0, 1, 0.090, 0.010, firdes.WIN_HAMMING, 6.76)
          
        self.squelch_dB = squelch_dB = -70
        self.gain_db = gain_db = 30
        self.final_decim = final_decim = int(samp_rate/1E6)
        self.file_name = file_name = "test.wav"
        self.fft_length = fft_length = 256 * int(pow(2, np.ceil(np.log(samp_ratio)/np.log(2))))
        self.demod_bb_freq = demod_bb_freq = 390E3
        self.center_freq = center_freq = 144E6

        ##################################################
        # Blocks
        ##################################################
        self._squelch_dB_range = Range(-100, 0, 5, -70, 200)
        self._squelch_dB_win = RangeWidget(self._squelch_dB_range, self.set_squelch_dB, "Squelch (dB)", "counter_slider", float)
        self.top_grid_layout.addWidget(self._squelch_dB_win, 5,1,1,3)
        self._gain_db_range = Range(0, 70, 1, 30, 200)
        self._gain_db_win = RangeWidget(self._gain_db_range, self.set_gain_db, "HW Gain (dB)", "counter_slider", float)
        self.top_grid_layout.addWidget(self._gain_db_win, 4,1,1,3)
        self._demod_bb_freq_range = Range(-samp_rate/2, samp_rate/2, 5E3, 390E3, 200)
        self._demod_bb_freq_win = RangeWidget(self._demod_bb_freq_range, self.set_demod_bb_freq, "Demod BB Freq (Hz)", "counter_slider", float)
        self.top_grid_layout.addWidget(self._demod_bb_freq_win, 3,1,1,3)
        self.qtgui_time_sink_x_0 = qtgui.time_sink_f(
        	fft_length, #size
        	samp_rate, #samp_rate
        	"Averaged Spectrum", #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(-60, 40)
        
        self.qtgui_time_sink_x_0.set_y_label("Power", "")
        
        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_control_panel(False)
        
        if not True:
          self.qtgui_time_sink_x_0.disable_legend()
        
        labels = ["", "", "", "", "",
                  "", "", "", "", ""]
        widths = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        colors = ["blue", "red", "green", "black", "cyan",
                  "magenta", "yellow", "dark red", "dark green", "blue"]
        styles = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1,
                   -1, -1, -1, -1, -1]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]
        
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_time_sink_x_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_0.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_0.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i])
        
        self._qtgui_time_sink_x_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_win, 0,1,3,1)
        self.qtgui_freq_sink_x_0_0 = qtgui.freq_sink_c(
        	1024, #size
        	firdes.WIN_BLACKMAN_hARRIS, #wintype
        	0, #fc
        	final_rate, #bw
        	"Decimated Channel", #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(-200, -60)
        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_control_panel(False)
        
        if not True:
          self.qtgui_freq_sink_x_0_0.disable_legend()
        
        if complex == type(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.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_0_win, 3,0,3,1)
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c(
        	fft_length, #size
        	firdes.WIN_BLACKMAN_hARRIS, #wintype
        	144E6, #fc
        	samp_rate, #bw
        	"Spectrum", #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(-120, -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(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_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win, 0,0,3,1)
        self.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_fff(
        	  16E3/float(final_rate/5),
                  taps=None,
        	  flt_size=32)
        self.pfb_arb_resampler_xxx_0.declare_sample_delay(0)
        	
        self.osmosdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + "uhd" )
        self.osmosdr_source_0.set_sample_rate(samp_rate)
        self.osmosdr_source_0.set_center_freq(center_freq, 0)
        self.osmosdr_source_0.set_freq_corr(0, 0)
        self.osmosdr_source_0.set_dc_offset_mode(0, 0)
        self.osmosdr_source_0.set_iq_balance_mode(0, 0)
        self.osmosdr_source_0.set_gain_mode(False, 0)
        self.osmosdr_source_0.set_gain(gain_db, 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(samp_rate*0.8, 0)
          
        self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(initial_decim, (variable_low_pass_filter_taps_0), demod_bb_freq, samp_rate)
        self.fir_filter_xxx_0_1 = filter.fir_filter_fff(initial_decim, (variable_low_pass_filter_taps_0))
        self.fir_filter_xxx_0_1.declare_sample_delay(0)
        self.fir_filter_xxx_0_0 = filter.fir_filter_ccc(int(samp_rate/1E6), (variable_low_pass_filter_taps_0))
        self.fir_filter_xxx_0_0.declare_sample_delay(0)
        self.fir_filter_xxx_0 = filter.fir_filter_ccc(initial_decim, (variable_low_pass_filter_taps_0))
        self.fir_filter_xxx_0.declare_sample_delay(0)
        self.fft_vxx_0 = fft.fft_vcc(fft_length, True, (window.blackmanharris(fft_length)), True, 1)
        self.blocks_wavfile_sink_0 = blocks.wavfile_sink(file_name, 1, 16000, 8)
        self.blocks_vector_to_stream_0 = blocks.vector_to_stream(gr.sizeof_float*1, fft_length)
        self.blocks_stream_to_vector_0 = blocks.stream_to_vector(gr.sizeof_gr_complex*1, fft_length)
        self.blocks_probe_signal_vx_0 = blocks.probe_signal_vf(fft_length)
        self.blocks_nlog10_ff_0 = blocks.nlog10_ff(10, fft_length, 0)
        self.blocks_keep_one_in_n_0 = blocks.keep_one_in_n(gr.sizeof_gr_complex*fft_length, int(round(samp_rate/fft_length/1000)))
        self.blocks_integrate_xx_0 = blocks.integrate_ff(100, fft_length)
        self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(fft_length)
        self.audio_sink_0 = audio.sink(16000, "", True)
        self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(0.050)
        self.analog_pwr_squelch_xx_0_0 = analog.pwr_squelch_ff(-200, 0.1, 0, True)
        self.analog_pwr_squelch_xx_0 = analog.pwr_squelch_cc(squelch_dB, 0.1, 0, False)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_pwr_squelch_xx_0, 0), (self.analog_quadrature_demod_cf_0, 0))    
        self.connect((self.analog_pwr_squelch_xx_0_0, 0), (self.blocks_wavfile_sink_0, 0))    
        self.connect((self.analog_quadrature_demod_cf_0, 0), (self.fir_filter_xxx_0_1, 0))    
        self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.blocks_integrate_xx_0, 0))    
        self.connect((self.blocks_integrate_xx_0, 0), (self.blocks_nlog10_ff_0, 0))    
        self.connect((self.blocks_keep_one_in_n_0, 0), (self.fft_vxx_0, 0))    
        self.connect((self.blocks_nlog10_ff_0, 0), (self.blocks_probe_signal_vx_0, 0))    
        self.connect((self.blocks_nlog10_ff_0, 0), (self.blocks_vector_to_stream_0, 0))    
        self.connect((self.blocks_stream_to_vector_0, 0), (self.blocks_keep_one_in_n_0, 0))    
        self.connect((self.blocks_vector_to_stream_0, 0), (self.qtgui_time_sink_x_0, 0))    
        self.connect((self.fft_vxx_0, 0), (self.blocks_complex_to_mag_squared_0, 0))    
        self.connect((self.fir_filter_xxx_0, 0), (self.fir_filter_xxx_0_0, 0))    
        self.connect((self.fir_filter_xxx_0_0, 0), (self.analog_pwr_squelch_xx_0, 0))    
        self.connect((self.fir_filter_xxx_0_0, 0), (self.qtgui_freq_sink_x_0_0, 0))    
        self.connect((self.fir_filter_xxx_0_1, 0), (self.pfb_arb_resampler_xxx_0, 0))    
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.fir_filter_xxx_0, 0))    
        self.connect((self.osmosdr_source_0, 0), (self.blocks_stream_to_vector_0, 0))    
        self.connect((self.osmosdr_source_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0))    
        self.connect((self.osmosdr_source_0, 0), (self.qtgui_freq_sink_x_0, 0))    
        self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.analog_pwr_squelch_xx_0_0, 0))    
        self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.audio_sink_0, 0))    
Ejemplo n.º 19
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Keyfob Decode Wav")

        ##################################################
        # Variables
        ##################################################
        self.sps = sps = 5
        self.samp_rate = samp_rate = 48000

        ##################################################
        # Blocks
        ##################################################
        self.wxgui_scopesink2_1 = scopesink2.scope_sink_f(
        	self.GetWin(),
        	title="Scope Plot",
        	sample_rate=3400,
        	v_scale=0,
        	v_offset=0,
        	t_scale=0,
        	ac_couple=False,
        	xy_mode=False,
        	num_inputs=1,
        	trig_mode=wxgui.TRIG_MODE_AUTO,
        	y_axis_label="Counts",
        )
        self.Add(self.wxgui_scopesink2_1.win)
        self.wxgui_scopesink2_0 = scopesink2.scope_sink_f(
        	self.GetWin(),
        	title="Scope Plot",
        	sample_rate=3400 * 5,
        	v_scale=0,
        	v_offset=0,
        	t_scale=0,
        	ac_couple=False,
        	xy_mode=False,
        	num_inputs=1,
        	trig_mode=wxgui.TRIG_MODE_AUTO,
        	y_axis_label="Counts",
        )
        self.Add(self.wxgui_scopesink2_0.win)
        self.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_fff(
        	  3400.0*sps/48000,
                  taps=None,
        	  flt_size=32)
        self.pfb_arb_resampler_xxx_0.declare_sample_delay(0)
        	
        self.keyfob_parse_packet_0 = keyfob.parse_packet()
        self.keyfob_manchester_decode_0 = keyfob.manchester_decode()
        self.digital_correlate_access_code_tag_bb_0 = digital.correlate_access_code_tag_bb("10101000", 0, "packet_start")
        self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff(5*(1+0.0), 0.25*0.175*0.175, 0.5, 0.175, 0.05)
        self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb()
        self.blocks_wavfile_source_0 = blocks.wavfile_source("../gqrx_20150306_154200_434400000.wav", False)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_float*1, samp_rate*3,True)
        self.blocks_moving_average_xx_1 = blocks.moving_average_ff(sps, 1, 4000)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_moving_average_xx_1, 0), (self.digital_clock_recovery_mm_xx_0, 0))    
        self.connect((self.blocks_moving_average_xx_1, 0), (self.wxgui_scopesink2_0, 0))    
        self.connect((self.blocks_throttle_0, 0), (self.pfb_arb_resampler_xxx_0, 0))    
        self.connect((self.blocks_wavfile_source_0, 0), (self.blocks_throttle_0, 0))    
        self.connect((self.digital_binary_slicer_fb_0, 0), (self.keyfob_manchester_decode_0, 0))    
        self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.digital_binary_slicer_fb_0, 0))    
        self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.wxgui_scopesink2_1, 0))    
        self.connect((self.digital_correlate_access_code_tag_bb_0, 0), (self.keyfob_parse_packet_0, 0))    
        self.connect((self.keyfob_manchester_decode_0, 0), (self.digital_correlate_access_code_tag_bb_0, 0))    
        self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.blocks_moving_average_xx_1, 0))    
Ejemplo n.º 20
0
    def __init__(self):
        gr.top_block.__init__(self, "Ham2Mon Receiver Flow Example")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Ham2Mon Receiver Flow 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", "flow_example")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 1E6
        self.initial_decim = initial_decim = 5
        self.samp_ratio = samp_ratio = samp_rate / 1E6
        self.final_rate = final_rate = samp_rate / initial_decim**2 / int(
            samp_rate / 1E6)

        self.variable_low_pass_filter_taps_2 = variable_low_pass_filter_taps_2 = firdes.low_pass(
            1.0, final_rate, 3500, 500, firdes.WIN_HAMMING, 6.76)

        self.variable_low_pass_filter_taps_1 = variable_low_pass_filter_taps_1 = firdes.low_pass(
            1.0, samp_rate / 25, 12.5E3, 1E3, firdes.WIN_HAMMING, 6.76)

        self.variable_low_pass_filter_taps_0 = variable_low_pass_filter_taps_0 = firdes.low_pass(
            1.0, 1, 0.090, 0.010, firdes.WIN_HAMMING, 6.76)

        self.squelch_dB = squelch_dB = -70
        self.gain_db = gain_db = 30
        self.final_decim = final_decim = int(samp_rate / 1E6)
        self.file_name = file_name = "test.wav"
        self.fft_length = fft_length = 256 * int(
            pow(2, np.ceil(np.log(samp_ratio) / np.log(2))))
        self.demod_bb_freq = demod_bb_freq = 390E3
        self.center_freq = center_freq = 144E6

        ##################################################
        # Blocks
        ##################################################
        self._squelch_dB_range = Range(-100, 0, 5, -70, 200)
        self._squelch_dB_win = RangeWidget(self._squelch_dB_range,
                                           self.set_squelch_dB, "Squelch (dB)",
                                           "counter_slider", float)
        self.top_grid_layout.addWidget(self._squelch_dB_win, 5, 1, 1, 3)
        self._gain_db_range = Range(0, 70, 1, 30, 200)
        self._gain_db_win = RangeWidget(self._gain_db_range, self.set_gain_db,
                                        "HW Gain (dB)", "counter_slider",
                                        float)
        self.top_grid_layout.addWidget(self._gain_db_win, 4, 1, 1, 3)
        self._demod_bb_freq_range = Range(-samp_rate / 2, samp_rate / 2, 5E3,
                                          390E3, 200)
        self._demod_bb_freq_win = RangeWidget(self._demod_bb_freq_range,
                                              self.set_demod_bb_freq,
                                              "Demod BB Freq (Hz)",
                                              "counter_slider", float)
        self.top_grid_layout.addWidget(self._demod_bb_freq_win, 3, 1, 1, 3)
        self.qtgui_time_sink_x_0 = qtgui.time_sink_f(
            fft_length,  #size
            samp_rate,  #samp_rate
            "Averaged Spectrum",  #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(-60, 40)

        self.qtgui_time_sink_x_0.set_y_label("Power", "")

        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_control_panel(False)

        if not True:
            self.qtgui_time_sink_x_0.disable_legend()

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

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

        self._qtgui_time_sink_x_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_win, 0, 1, 3,
                                       1)
        self.qtgui_freq_sink_x_0_0 = qtgui.freq_sink_c(
            1024,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            final_rate,  #bw
            "Decimated Channel",  #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(-200, -60)
        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_control_panel(False)

        if not True:
            self.qtgui_freq_sink_x_0_0.disable_legend()

        if complex == type(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.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_0_win, 3, 0,
                                       3, 1)
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c(
            fft_length,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            144E6,  #fc
            samp_rate,  #bw
            "Spectrum",  #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(-120, -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(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_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win, 0, 0, 3,
                                       1)
        self.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_fff(
            16E3 / float(final_rate / 5), taps=None, flt_size=32)
        self.pfb_arb_resampler_xxx_0.declare_sample_delay(0)

        self.osmosdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " +
                                               "uhd")
        self.osmosdr_source_0.set_sample_rate(samp_rate)
        self.osmosdr_source_0.set_center_freq(center_freq, 0)
        self.osmosdr_source_0.set_freq_corr(0, 0)
        self.osmosdr_source_0.set_dc_offset_mode(0, 0)
        self.osmosdr_source_0.set_iq_balance_mode(0, 0)
        self.osmosdr_source_0.set_gain_mode(False, 0)
        self.osmosdr_source_0.set_gain(gain_db, 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(samp_rate * 0.8, 0)

        self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(
            initial_decim, (variable_low_pass_filter_taps_0), demod_bb_freq,
            samp_rate)
        self.fir_filter_xxx_0_1 = filter.fir_filter_fff(
            initial_decim, (variable_low_pass_filter_taps_0))
        self.fir_filter_xxx_0_1.declare_sample_delay(0)
        self.fir_filter_xxx_0_0 = filter.fir_filter_ccc(
            int(samp_rate / 1E6), (variable_low_pass_filter_taps_0))
        self.fir_filter_xxx_0_0.declare_sample_delay(0)
        self.fir_filter_xxx_0 = filter.fir_filter_ccc(
            initial_decim, (variable_low_pass_filter_taps_0))
        self.fir_filter_xxx_0.declare_sample_delay(0)
        self.fft_vxx_0 = fft.fft_vcc(fft_length, True,
                                     (window.blackmanharris(fft_length)), True,
                                     1)
        self.blocks_wavfile_sink_0 = blocks.wavfile_sink(
            file_name, 1, 16000, 8)
        self.blocks_vector_to_stream_0 = blocks.vector_to_stream(
            gr.sizeof_float * 1, fft_length)
        self.blocks_stream_to_vector_0 = blocks.stream_to_vector(
            gr.sizeof_gr_complex * 1, fft_length)
        self.blocks_probe_signal_vx_0 = blocks.probe_signal_vf(fft_length)
        self.blocks_nlog10_ff_0 = blocks.nlog10_ff(10, fft_length, 0)
        self.blocks_keep_one_in_n_0 = blocks.keep_one_in_n(
            gr.sizeof_gr_complex * fft_length,
            int(round(samp_rate / fft_length / 1000)))
        self.blocks_integrate_xx_0 = blocks.integrate_ff(100, fft_length)
        self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(
            fft_length)
        self.audio_sink_0 = audio.sink(16000, "", True)
        self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(0.050)
        self.analog_pwr_squelch_xx_0_0 = analog.pwr_squelch_ff(
            -200, 0.1, 0, True)
        self.analog_pwr_squelch_xx_0 = analog.pwr_squelch_cc(
            squelch_dB, 0.1, 0, False)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_pwr_squelch_xx_0, 0),
                     (self.analog_quadrature_demod_cf_0, 0))
        self.connect((self.analog_pwr_squelch_xx_0_0, 0),
                     (self.blocks_wavfile_sink_0, 0))
        self.connect((self.analog_quadrature_demod_cf_0, 0),
                     (self.fir_filter_xxx_0_1, 0))
        self.connect((self.blocks_complex_to_mag_squared_0, 0),
                     (self.blocks_integrate_xx_0, 0))
        self.connect((self.blocks_integrate_xx_0, 0),
                     (self.blocks_nlog10_ff_0, 0))
        self.connect((self.blocks_keep_one_in_n_0, 0), (self.fft_vxx_0, 0))
        self.connect((self.blocks_nlog10_ff_0, 0),
                     (self.blocks_probe_signal_vx_0, 0))
        self.connect((self.blocks_nlog10_ff_0, 0),
                     (self.blocks_vector_to_stream_0, 0))
        self.connect((self.blocks_stream_to_vector_0, 0),
                     (self.blocks_keep_one_in_n_0, 0))
        self.connect((self.blocks_vector_to_stream_0, 0),
                     (self.qtgui_time_sink_x_0, 0))
        self.connect((self.fft_vxx_0, 0),
                     (self.blocks_complex_to_mag_squared_0, 0))
        self.connect((self.fir_filter_xxx_0, 0), (self.fir_filter_xxx_0_0, 0))
        self.connect((self.fir_filter_xxx_0_0, 0),
                     (self.analog_pwr_squelch_xx_0, 0))
        self.connect((self.fir_filter_xxx_0_0, 0),
                     (self.qtgui_freq_sink_x_0_0, 0))
        self.connect((self.fir_filter_xxx_0_1, 0),
                     (self.pfb_arb_resampler_xxx_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0),
                     (self.fir_filter_xxx_0, 0))
        self.connect((self.osmosdr_source_0, 0),
                     (self.blocks_stream_to_vector_0, 0))
        self.connect((self.osmosdr_source_0, 0),
                     (self.freq_xlating_fir_filter_xxx_0, 0))
        self.connect((self.osmosdr_source_0, 0), (self.qtgui_freq_sink_x_0, 0))
        self.connect((self.pfb_arb_resampler_xxx_0, 0),
                     (self.analog_pwr_squelch_xx_0_0, 0))
        self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.audio_sink_0, 0))
    def __init__(self):
        gr.top_block.__init__(self, "Symbol Differential Filter", catch_exceptions=True)
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Symbol Differential Filter")
        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", "symbol_differential_filter")

        try:
            if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"):
                self.restoreGeometry(self.settings.value("geometry").toByteArray())
            else:
                self.restoreGeometry(self.settings.value("geometry"))
        except:
            pass

        ##################################################
        # Variables
        ##################################################
        self.sps = sps = 4
        self.ntaps = ntaps = 45
        self.eb = eb = 0.25
        self.samp_rate = samp_rate = 32000
        self.rrc_tx = rrc_tx = firdes.root_raised_cosine(sps, sps, 1, eb, sps*ntaps)
        self.rrc_rx = rrc_rx = firdes.root_raised_cosine(1.0, sps, 1, eb, ntaps)
        self.rate = rate = 1.2

        ##################################################
        # Blocks
        ##################################################
        self.qtgui_time_sink_x_0_0 = qtgui.time_sink_f(
            7*sps, #size
            samp_rate, #samp_rate
            'QT GUI Plot', #name
            2, #number of inputs
            None # parent
        )
        self.qtgui_time_sink_x_0_0.set_update_time(0.01)
        self.qtgui_time_sink_x_0_0.set_y_axis(-0.5, 1.25)

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

        self.qtgui_time_sink_x_0_0.enable_tags(True)
        self.qtgui_time_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_NORM, qtgui.TRIG_SLOPE_POS, 0.8, 0.00005*sps, 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)
        self.qtgui_time_sink_x_0_0.enable_stem_plot(False)


        labels = ['sym0', 'd(sym0)/dt', 'sym1', 'd(sym1)/dt', '',
            '', '', '', '', 'Signal 10']
        widths = [2, 2, 2, 2, 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]
        styles = [1, 1, 1, 1, 1,
            1, 1, 1, 1, 1]
        markers = [0, 0, 0, 0, -1,
            -1, -1, -1, -1, -1]


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

        self._qtgui_time_sink_x_0_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_0_win, 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.pfb_arb_resampler_xxx_0_0_1 = pfb.arb_resampler_fff(
            rate,
            taps=None,
            flt_size=32)
        self.pfb_arb_resampler_xxx_0_0_1.declare_sample_delay(0)
        self.interp_fir_filter_xxx_0 = filter.interp_fir_filter_fff(sps, rrc_tx)
        self.interp_fir_filter_xxx_0.declare_sample_delay(0)
        self.fir_filter_xxx_0_2 = filter.fir_filter_fff(1, [-1, 0, 1])
        self.fir_filter_xxx_0_2.declare_sample_delay(0)
        self.fir_filter_xxx_0 = filter.fir_filter_fff(1, rrc_rx)
        self.fir_filter_xxx_0.declare_sample_delay(0)
        self.blocks_vector_source_x_0 = blocks.vector_source_f(49*[0,] + [1,] + 50*[0,], True, 1, [])
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_float*1, samp_rate,True)
        self.blocks_delay_0_0 = blocks.delay(gr.sizeof_float*1, 1)



        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_delay_0_0, 0), (self.qtgui_time_sink_x_0_0, 0))
        self.connect((self.blocks_throttle_0, 0), (self.interp_fir_filter_xxx_0, 0))
        self.connect((self.blocks_vector_source_x_0, 0), (self.blocks_throttle_0, 0))
        self.connect((self.fir_filter_xxx_0, 0), (self.blocks_delay_0_0, 0))
        self.connect((self.fir_filter_xxx_0, 0), (self.fir_filter_xxx_0_2, 0))
        self.connect((self.fir_filter_xxx_0_2, 0), (self.qtgui_time_sink_x_0_0, 1))
        self.connect((self.interp_fir_filter_xxx_0, 0), (self.pfb_arb_resampler_xxx_0_0_1, 0))
        self.connect((self.pfb_arb_resampler_xxx_0_0_1, 0), (self.fir_filter_xxx_0, 0))
Ejemplo n.º 22
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(
            self, title="Stereo FM receiver and RDS Decoder")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Variables
        ##################################################
        self.freq_offset = freq_offset = 250000
        self.freq = freq = 95.8e6
        self.volume = volume = -3
        self.samp_rate = samp_rate = 1e6
        self.gain = gain = 20
        self.freq_tune = freq_tune = freq - freq_offset
        self.capture_base_freq = capture_base_freq = 88e6

        ##################################################
        # Blocks
        ##################################################
        _volume_sizer = wx.BoxSizer(wx.VERTICAL)
        self._volume_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_volume_sizer,
            value=self.volume,
            callback=self.set_volume,
            label='Volume',
            converter=forms.float_converter(),
            proportion=0,
        )
        self._volume_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_volume_sizer,
            value=self.volume,
            callback=self.set_volume,
            minimum=-20,
            maximum=10,
            num_steps=300,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_volume_sizer, 0, 1, 1, 1)
        self.nb = self.nb = wx.Notebook(self.GetWin(), style=wx.NB_TOP)
        self.nb.AddPage(grc_wxgui.Panel(self.nb), "BB")
        self.nb.AddPage(grc_wxgui.Panel(self.nb), "Demod")
        self.nb.AddPage(grc_wxgui.Panel(self.nb), "Waterfall")
        self.nb.AddPage(grc_wxgui.Panel(self.nb), "L+R")
        self.nb.AddPage(grc_wxgui.Panel(self.nb), "L-R")
        self.nb.AddPage(grc_wxgui.Panel(self.nb), "RDS")
        self.nb.AddPage(grc_wxgui.Panel(self.nb), "Const")
        self.nb.AddPage(grc_wxgui.Panel(self.nb), "x")
        self.nb.AddPage(grc_wxgui.Panel(self.nb), "y")
        self.GridAdd(self.nb, 2, 0, 1, 2)
        _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=800,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_freq_sizer, 1, 0, 1, 2)
        self.wxgui_waterfallsink2_1 = waterfallsink2.waterfall_sink_c(
            self.nb.GetPage(8).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.nb.GetPage(8).Add(self.wxgui_waterfallsink2_1.win)
        self.wxgui_waterfallsink2_0 = waterfallsink2.waterfall_sink_f(
            self.nb.GetPage(2).GetWin(),
            baseband_freq=0,
            dynamic_range=100,
            ref_level=0,
            ref_scale=2.0,
            sample_rate=250000,
            fft_size=512,
            fft_rate=15,
            average=False,
            avg_alpha=None,
            title='Waterfall Plot',
        )
        self.nb.GetPage(2).Add(self.wxgui_waterfallsink2_0.win)
        self.wxgui_scopesink2_1 = scopesink2.scope_sink_c(
            self.nb.GetPage(6).GetWin(),
            title='Scope Plot',
            sample_rate=2375 * 4,
            v_scale=0.4,
            v_offset=0,
            t_scale=0,
            ac_couple=False,
            xy_mode=True,
            num_inputs=1,
            trig_mode=wxgui.TRIG_MODE_AUTO,
            y_axis_label='Counts',
        )
        self.nb.GetPage(6).Add(self.wxgui_scopesink2_1.win)
        self.wxgui_fftsink2_1 = fftsink2.fft_sink_c(
            self.nb.GetPage(7).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='FFT Plot',
            peak_hold=False,
        )
        self.nb.GetPage(7).Add(self.wxgui_fftsink2_1.win)
        self.wxgui_fftsink2_0_0_0_1_0_1 = fftsink2.fft_sink_c(
            self.nb.GetPage(5).GetWin(),
            baseband_freq=0,
            y_per_div=10,
            y_divs=10,
            ref_level=0,
            ref_scale=2.0,
            sample_rate=19000,
            fft_size=1024,
            fft_rate=15,
            average=False,
            avg_alpha=None,
            title='RDS',
            peak_hold=False,
        )
        self.nb.GetPage(5).Add(self.wxgui_fftsink2_0_0_0_1_0_1.win)
        self.wxgui_fftsink2_0_0_0_1 = fftsink2.fft_sink_f(
            self.nb.GetPage(4).GetWin(),
            baseband_freq=0,
            y_per_div=10,
            y_divs=10,
            ref_level=0,
            ref_scale=2.0,
            sample_rate=48000,
            fft_size=1024,
            fft_rate=15,
            average=False,
            avg_alpha=None,
            title='L-R',
            peak_hold=False,
        )
        self.nb.GetPage(4).Add(self.wxgui_fftsink2_0_0_0_1.win)
        self.wxgui_fftsink2_0_0_0 = fftsink2.fft_sink_f(
            self.nb.GetPage(3).GetWin(),
            baseband_freq=0,
            y_per_div=10,
            y_divs=10,
            ref_level=0,
            ref_scale=2.0,
            sample_rate=48000,
            fft_size=1024,
            fft_rate=15,
            average=False,
            avg_alpha=None,
            title='L+R',
            peak_hold=False,
        )
        self.nb.GetPage(3).Add(self.wxgui_fftsink2_0_0_0.win)
        self.wxgui_fftsink2_0_0 = fftsink2.fft_sink_f(
            self.nb.GetPage(1).GetWin(),
            baseband_freq=0,
            y_per_div=10,
            y_divs=10,
            ref_level=0,
            ref_scale=2.0,
            sample_rate=250000,
            fft_size=1024,
            fft_rate=15,
            average=True,
            avg_alpha=0.8,
            title='FM Demod',
            peak_hold=False,
        )
        self.nb.GetPage(1).Add(self.wxgui_fftsink2_0_0.win)
        self.wxgui_fftsink2_0 = fftsink2.fft_sink_c(
            self.nb.GetPage(0).GetWin(),
            baseband_freq=0,
            y_per_div=10,
            y_divs=10,
            ref_level=-30,
            ref_scale=2.0,
            sample_rate=samp_rate,
            fft_size=1024,
            fft_rate=15,
            average=True,
            avg_alpha=0.8,
            title='Baseband',
            peak_hold=False,
        )
        self.nb.GetPage(0).Add(self.wxgui_fftsink2_0.win)
        self.root_raised_cosine_filter_0 = filter.fir_filter_ccf(
            2, firdes.root_raised_cosine(1, 19000, 2375, .35, 100))
        self.pfb_arb_resampler_xxx_1 = pfb.arb_resampler_fff(240000.0 / 250000,
                                                             taps=None,
                                                             flt_size=32)
        self.pfb_arb_resampler_xxx_1.declare_sample_delay(0)

        self.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_ccf(19000 / 250e3,
                                                             taps=None,
                                                             flt_size=32)
        self.pfb_arb_resampler_xxx_0.declare_sample_delay(0)

        self.gr_rds_parser_0 = rds.parser(True, False, 0)
        self.gr_rds_panel_0 = rds.rdsPanel(freq, self.GetWin())
        self.Add(self.gr_rds_panel_0.panel)
        self.gr_rds_decoder_0 = rds.decoder(False, False)
        _gain_sizer = wx.BoxSizer(wx.VERTICAL)
        self._gain_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_gain_sizer,
            value=self.gain,
            callback=self.set_gain,
            label='RF Gain',
            converter=forms.float_converter(),
            proportion=0,
        )
        self._gain_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_gain_sizer,
            value=self.gain,
            callback=self.set_gain,
            minimum=0,
            maximum=49.6,
            num_steps=124,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_gain_sizer, 0, 0, 1, 1)
        self.freq_xlating_fir_filter_xxx_2 = filter.freq_xlating_fir_filter_fcf(
            5, (firdes.low_pass(1.0, 240000, 13e3, 3e3, firdes.WIN_HAMMING)),
            38000, 240000)
        self.freq_xlating_fir_filter_xxx_1_0 = filter.freq_xlating_fir_filter_fcc(
            1,
            (firdes.low_pass(2500.0, 250000, 2.6e3, 2e3, firdes.WIN_HAMMING)),
            57e3, 250000)
        self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(
            1, (firdes.low_pass(1, samp_rate, 80000, 20000)), freq_offset,
            samp_rate)
        self.fir_filter_xxx_1 = filter.fir_filter_fff(
            5, (firdes.low_pass(1.0, 240000, 13e3, 3e3, firdes.WIN_HAMMING)))
        self.fir_filter_xxx_1.declare_sample_delay(0)
        self.digital_psk_demod_0 = digital.psk.psk_demod(
            constellation_points=2,
            differential=False,
            samples_per_symbol=4,
            excess_bw=0.35,
            phase_bw=6.28 / 100.0,
            timing_bw=6.28 / 100.0,
            mod_code="gray",
            verbose=False,
            log=False,
        )
        self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(2)
        self.blocks_sub_xx_0 = blocks.sub_ff(1)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vff(
            (10**(1. * (volume) / 10), ))
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff(
            (10**(1. * (volume) / 10), ))
        self.blocks_keep_one_in_n_0 = blocks.keep_one_in_n(
            gr.sizeof_char * 1, 2)
        self.blocks_file_source_0 = blocks.file_source(
            gr.sizeof_gr_complex * 1,
            '/home/deepstar/Projects/OverTheWire/advent2019/advent2019/steven/northpole-airwaves/northpole-airwaves.wav',
            True)
        self.blocks_complex_to_real_0 = blocks.complex_to_real(1)
        self.blocks_add_xx_0 = blocks.add_vff(1)
        self.audio_sink_0 = audio.sink(48000, '', True)
        self.analog_wfm_rcv_0 = analog.wfm_rcv(
            quad_rate=samp_rate,
            audio_decimation=int(samp_rate / (250e3)),
        )
        self.analog_sig_source_x_0 = analog.sig_source_c(
            samp_rate, analog.GR_COS_WAVE, freq - capture_base_freq, 1, 0)
        self.analog_fm_deemph_0_0_0 = analog.fm_deemph(fs=48000, tau=75e-6)
        self.analog_fm_deemph_0_0 = analog.fm_deemph(fs=48000, tau=75e-6)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.gr_rds_decoder_0, 'out'),
                         (self.gr_rds_parser_0, 'in'))
        self.msg_connect((self.gr_rds_parser_0, 'out'),
                         (self.gr_rds_panel_0, 'in'))
        self.connect((self.analog_fm_deemph_0_0, 0),
                     (self.blocks_multiply_const_vxx_0_0, 0))
        self.connect((self.analog_fm_deemph_0_0_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.analog_sig_source_x_0, 0),
                     (self.blocks_multiply_xx_0, 1))
        self.connect((self.analog_wfm_rcv_0, 0),
                     (self.freq_xlating_fir_filter_xxx_1_0, 0))
        self.connect((self.analog_wfm_rcv_0, 0),
                     (self.pfb_arb_resampler_xxx_1, 0))
        self.connect((self.analog_wfm_rcv_0, 0), (self.wxgui_fftsink2_0_0, 0))
        self.connect((self.analog_wfm_rcv_0, 0),
                     (self.wxgui_waterfallsink2_0, 0))
        self.connect((self.blocks_add_xx_0, 0),
                     (self.analog_fm_deemph_0_0_0, 0))
        self.connect((self.blocks_complex_to_real_0, 0),
                     (self.blocks_add_xx_0, 1))
        self.connect((self.blocks_complex_to_real_0, 0),
                     (self.blocks_sub_xx_0, 1))
        self.connect((self.blocks_complex_to_real_0, 0),
                     (self.wxgui_fftsink2_0_0_0_1, 0))
        self.connect((self.blocks_file_source_0, 0),
                     (self.blocks_multiply_xx_0, 0))
        self.connect((self.blocks_keep_one_in_n_0, 0),
                     (self.digital_diff_decoder_bb_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, 0),
                     (self.audio_sink_0, 1))
        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.wxgui_fftsink2_1, 0))
        self.connect((self.blocks_multiply_xx_0, 0),
                     (self.wxgui_waterfallsink2_1, 0))
        self.connect((self.blocks_sub_xx_0, 0), (self.analog_fm_deemph_0_0, 0))
        self.connect((self.digital_diff_decoder_bb_0, 0),
                     (self.gr_rds_decoder_0, 0))
        self.connect((self.digital_psk_demod_0, 0),
                     (self.blocks_keep_one_in_n_0, 0))
        self.connect((self.fir_filter_xxx_1, 0), (self.blocks_add_xx_0, 0))
        self.connect((self.fir_filter_xxx_1, 0), (self.blocks_sub_xx_0, 0))
        self.connect((self.fir_filter_xxx_1, 0),
                     (self.wxgui_fftsink2_0_0_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0),
                     (self.analog_wfm_rcv_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_1_0, 0),
                     (self.pfb_arb_resampler_xxx_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_2, 0),
                     (self.blocks_complex_to_real_0, 0))
        self.connect((self.pfb_arb_resampler_xxx_0, 0),
                     (self.root_raised_cosine_filter_0, 0))
        self.connect((self.pfb_arb_resampler_xxx_0, 0),
                     (self.wxgui_fftsink2_0_0_0_1_0_1, 0))
        self.connect((self.pfb_arb_resampler_xxx_1, 0),
                     (self.fir_filter_xxx_1, 0))
        self.connect((self.pfb_arb_resampler_xxx_1, 0),
                     (self.freq_xlating_fir_filter_xxx_2, 0))
        self.connect((self.root_raised_cosine_filter_0, 0),
                     (self.digital_psk_demod_0, 0))
        self.connect((self.root_raised_cosine_filter_0, 0),
                     (self.wxgui_scopesink2_1, 0))
Ejemplo n.º 23
0
    def __init__(self):
        gr.top_block.__init__(self, "Keyfob Decode Wav")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Keyfob Decode 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", "keyfob_decode_wav")

        try:
            if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"):
                self.restoreGeometry(
                    self.settings.value("geometry").toByteArray())
            else:
                self.restoreGeometry(self.settings.value("geometry"))
        except:
            pass

        ##################################################
        # Variables
        ##################################################
        self.sps = sps = 5
        self.samp_rate = samp_rate = 48000

        ##################################################
        # Blocks
        ##################################################
        self.qtgui_time_sink_x_1 = qtgui.time_sink_f(
            1024,  #size
            3400,  #samp_rate
            "",  #name
            1  #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(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)
        self.qtgui_time_sink_x_1.enable_stem_plot(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", "blue"
        ]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]

        for i in range(1):
            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_grid_layout.addWidget(self._qtgui_time_sink_x_1_win)
        self.qtgui_time_sink_x_0 = qtgui.time_sink_f(
            1024,  #size
            3400 * sps,  #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(True)
        self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE,
                                                  qtgui.TRIG_SLOPE_POS, 0.0, 0,
                                                  0, "")
        self.qtgui_time_sink_x_0.enable_autoscale(False)
        self.qtgui_time_sink_x_0.enable_grid(False)
        self.qtgui_time_sink_x_0.enable_axis_labels(True)
        self.qtgui_time_sink_x_0.enable_control_panel(False)
        self.qtgui_time_sink_x_0.enable_stem_plot(False)

        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"
        ]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]

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

        self._qtgui_time_sink_x_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_win)
        self.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_fff(3400.0 * sps /
                                                             48000,
                                                             taps=None,
                                                             flt_size=32)
        self.pfb_arb_resampler_xxx_0.declare_sample_delay(0)
        self.keyfob_parse_packet_0 = keyfob.parse_packet()
        self.keyfob_manchester_decode_0 = keyfob.manchester_decode()
        self.digital_correlate_access_code_tag_xx_0 = digital.correlate_access_code_tag_bb(
            "10101000", 0, 'packet_start')
        self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff(
            5 * (1 + 0.0), 0.25 * 0.175 * 0.175, 0.5, 0.175, 0.05)
        self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb()
        self.blocks_wavfile_source_0 = blocks.wavfile_source(
            '/home/basti/src/gr-keyfob/gqrx_20150306_154200_434400000.wav',
            False)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_float * 1,
                                                 samp_rate * 3, True)
        self.blocks_moving_average_xx_1 = blocks.moving_average_ff(
            sps, 1, 4000, 1)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_moving_average_xx_1, 0),
                     (self.digital_clock_recovery_mm_xx_0, 0))
        self.connect((self.blocks_moving_average_xx_1, 0),
                     (self.qtgui_time_sink_x_0, 0))
        self.connect((self.blocks_throttle_0, 0),
                     (self.pfb_arb_resampler_xxx_0, 0))
        self.connect((self.blocks_wavfile_source_0, 0),
                     (self.blocks_throttle_0, 0))
        self.connect((self.digital_binary_slicer_fb_0, 0),
                     (self.keyfob_manchester_decode_0, 0))
        self.connect((self.digital_clock_recovery_mm_xx_0, 0),
                     (self.digital_binary_slicer_fb_0, 0))
        self.connect((self.digital_clock_recovery_mm_xx_0, 0),
                     (self.qtgui_time_sink_x_1, 0))
        self.connect((self.digital_correlate_access_code_tag_xx_0, 0),
                     (self.keyfob_parse_packet_0, 0))
        self.connect((self.keyfob_manchester_decode_0, 0),
                     (self.digital_correlate_access_code_tag_xx_0, 0))
        self.connect((self.pfb_arb_resampler_xxx_0, 0),
                     (self.blocks_moving_average_xx_1, 0))
Ejemplo n.º 24
0
    def __init__(self, samp_rate=4E6, audio_rate=8000, record=True):
        gr.hier_block2.__init__(self, "TunerDemodNBFM",
                                gr.io_signature(1, 1, gr.sizeof_gr_complex),
                                gr.io_signature(1, 1, gr.sizeof_float))

        # Default values
        self.center_freq = 0
        squelch_db = -60
        self.quad_demod_gain = 0.050
        self.file_name = "/dev/null"
        self.record = record

        # Decimation values for four stages of decimation
        decims = (5, int(samp_rate/1E6))

        # Low pass filter taps for decimation by 5
        low_pass_filter_taps_0 = \
            grfilter.firdes_low_pass(1, 1, 0.090, 0.010,
                                     grfilter.firdes.WIN_HAMMING)

        # Frequency translating FIR filter decimating by 5
        self.freq_xlating_fir_filter_ccc = \
            grfilter.freq_xlating_fir_filter_ccc(decims[0],
                                                 low_pass_filter_taps_0,
                                                 self.center_freq, samp_rate)

        # FIR filter decimating by 5
        fir_filter_ccc_0 = grfilter.fir_filter_ccc(decims[0],
                                                   low_pass_filter_taps_0)

        # Low pass filter taps for decimation from samp_rate/25 to 40-79.9 ksps
        # In other words, decimation by int(samp_rate/1E6)
        # 12.5 kHz cutoff for NBFM channel bandwidth
        low_pass_filter_taps_1 = grfilter.firdes_low_pass(
            1, samp_rate/decims[0]**2, 12.5E3, 1E3, grfilter.firdes.WIN_HAMMING)

        # FIR filter decimation by int(samp_rate/1E6)
        fir_filter_ccc_1 = grfilter.fir_filter_ccc(decims[1],
                                                   low_pass_filter_taps_1)

        # Non blocking power squelch
        self.analog_pwr_squelch_cc = analog.pwr_squelch_cc(squelch_db,
                                                           1e-1, 0, False)

        # Quadrature demod with gain set for decent audio
        # The gain will be later multiplied by the 0 dB normalized volume
        self.analog_quadrature_demod_cf = \
            analog.quadrature_demod_cf(self.quad_demod_gain)

        # 3.5 kHz cutoff for audio bandwidth
        low_pass_filter_taps_2 = grfilter.firdes_low_pass(1,\
                        samp_rate/(decims[1] * decims[0]**2),\
                        3.5E3, 500, grfilter.firdes.WIN_HAMMING)

        # FIR filter decimating by 5 from 40-79.9 ksps to 8-15.98 ksps
        fir_filter_fff_0 = grfilter.fir_filter_fff(decims[0],
                                                   low_pass_filter_taps_2)

        # Polyphase resampler allows arbitary RF sample rates
        # Takes 8-15.98 ksps to a constant 8 ksps for audio
        pfb_resamp = audio_rate/float(samp_rate/(decims[1] * decims[0]**3))
        pfb_arb_resampler_fff = pfb.arb_resampler_fff(pfb_resamp, taps=None,
                                                      flt_size=32)

        # Connect the blocks for the demod
        self.connect(self, self.freq_xlating_fir_filter_ccc)
        self.connect(self.freq_xlating_fir_filter_ccc, fir_filter_ccc_0)
        self.connect(fir_filter_ccc_0, fir_filter_ccc_1)
        self.connect(fir_filter_ccc_1, self.analog_pwr_squelch_cc)
        self.connect(self.analog_pwr_squelch_cc,
                     self.analog_quadrature_demod_cf)
        self.connect(self.analog_quadrature_demod_cf, fir_filter_fff_0)
        self.connect(fir_filter_fff_0, pfb_arb_resampler_fff)
        self.connect(pfb_arb_resampler_fff, self)

        # Need to set this to a very low value of -200 since it is after demod
        # Only want it to gate when the previuos squelch has gone to zero
        analog_pwr_squelch_ff = analog.pwr_squelch_ff(-200, 1e-1, 0, True)

        # File sink with single channel and 8 bits/sample
        self.blocks_wavfile_sink = blocks.wavfile_sink(self.file_name, 1,
                                                       audio_rate, 8)

        # Connect the blocks for recording
        self.connect(pfb_arb_resampler_fff, analog_pwr_squelch_ff)
        self.connect(analog_pwr_squelch_ff, self.blocks_wavfile_sink)
Ejemplo n.º 25
0
    def __init__(self):
        gr.top_block.__init__(self, "Symbol Sampling Diff")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Symbol Sampling Diff")
        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", "symbol_sampling_diff")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.sps = sps = 4
        self.ntaps = ntaps = 45
        self.eb = eb = 0.25
        self.samp_rate = samp_rate = 32000
        self.rrc_tx = rrc_tx = firdes.root_raised_cosine(
            sps, sps, 1, eb, sps * ntaps)
        self.rrc_rx = rrc_rx = firdes.root_raised_cosine(1, sps, 1, eb, ntaps)
        self.rate = rate = 1.125

        ##################################################
        # Blocks
        ##################################################
        self.qtgui_time_sink_x_0_0 = qtgui.time_sink_f(
            27,  #size
            samp_rate,  #samp_rate
            'QT GUI Plot',  #name
            4  #number of inputs
        )
        self.qtgui_time_sink_x_0_0.set_update_time(0.01)
        self.qtgui_time_sink_x_0_0.set_y_axis(-0.5, 1.25)

        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_NORM,
                                                    qtgui.TRIG_SLOPE_POS, 0.9,
                                                    0.0002, 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)
        self.qtgui_time_sink_x_0_0.enable_stem_plot(False)

        if not True:
            self.qtgui_time_sink_x_0_0.disable_legend()

        labels = [
            'Rx Symbol 1', 'Rx Symbol 2', 'Rx Symbol 3', 'Rx Symbol 4', '', '',
            '', '', '', ''
        ]
        widths = [2, 2, 2, 2, 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 = [0, 0, 0, 0, -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(4):
            if len(labels[i]) == 0:
                self.qtgui_time_sink_x_0_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_0_0.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_0_0.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_0_0.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_0_0.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_0_0.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_0_0.set_line_alpha(i, alphas[i])

        self._qtgui_time_sink_x_0_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_0_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_0_win, 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.qtgui_time_sink_x_0 = qtgui.time_sink_f(
            27,  #size
            samp_rate,  #samp_rate
            'QT GUI Plot',  #name
            4  #number of inputs
        )
        self.qtgui_time_sink_x_0.set_update_time(0.01)
        self.qtgui_time_sink_x_0.set_y_axis(-0.5, 1.25)

        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_NORM,
                                                  qtgui.TRIG_SLOPE_POS, 0.99,
                                                  0.0002, 0, "")
        self.qtgui_time_sink_x_0.enable_autoscale(False)
        self.qtgui_time_sink_x_0.enable_grid(False)
        self.qtgui_time_sink_x_0.enable_axis_labels(True)
        self.qtgui_time_sink_x_0.enable_control_panel(False)
        self.qtgui_time_sink_x_0.enable_stem_plot(False)

        if not True:
            self.qtgui_time_sink_x_0.disable_legend()

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

        self._qtgui_time_sink_x_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_win, 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.pfb_arb_resampler_xxx_0_0_1 = pfb.arb_resampler_fff(rate,
                                                                 taps=None,
                                                                 flt_size=32)
        self.pfb_arb_resampler_xxx_0_0_1.declare_sample_delay(0)

        self.pfb_arb_resampler_xxx_0_0_0 = pfb.arb_resampler_fff(rate,
                                                                 taps=None,
                                                                 flt_size=32)
        self.pfb_arb_resampler_xxx_0_0_0.declare_sample_delay(0)

        self.pfb_arb_resampler_xxx_0_0 = pfb.arb_resampler_fff(rate,
                                                               taps=None,
                                                               flt_size=32)
        self.pfb_arb_resampler_xxx_0_0.declare_sample_delay(0)

        self.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_fff(rate,
                                                             taps=None,
                                                             flt_size=32)
        self.pfb_arb_resampler_xxx_0.declare_sample_delay(0)

        self.interp_fir_filter_xxx_0_1 = filter.interp_fir_filter_fff(
            sps, (rrc_tx))
        self.interp_fir_filter_xxx_0_1.declare_sample_delay(0)
        self.interp_fir_filter_xxx_0_0_0 = filter.interp_fir_filter_fff(
            sps, (rrc_tx))
        self.interp_fir_filter_xxx_0_0_0.declare_sample_delay(0)
        self.interp_fir_filter_xxx_0_0 = filter.interp_fir_filter_fff(
            sps, (rrc_tx))
        self.interp_fir_filter_xxx_0_0.declare_sample_delay(0)
        self.interp_fir_filter_xxx_0 = filter.interp_fir_filter_fff(
            sps, (rrc_tx))
        self.interp_fir_filter_xxx_0.declare_sample_delay(0)
        self.fir_filter_xxx_0_1 = filter.fir_filter_fff(1, (rrc_rx))
        self.fir_filter_xxx_0_1.declare_sample_delay(0)
        self.fir_filter_xxx_0_0_0 = filter.fir_filter_fff(1, (rrc_rx))
        self.fir_filter_xxx_0_0_0.declare_sample_delay(0)
        self.fir_filter_xxx_0_0 = filter.fir_filter_fff(1, (rrc_rx))
        self.fir_filter_xxx_0_0.declare_sample_delay(0)
        self.fir_filter_xxx_0 = filter.fir_filter_fff(1, (rrc_rx))
        self.fir_filter_xxx_0.declare_sample_delay(0)
        self.blocks_vector_source_x_0_1 = blocks.vector_source_f(
            51 * [
                0,
            ] + [
                1,
            ] + 48 * [
                0,
            ], True, 1, [])
        self.blocks_vector_source_x_0_0_0 = blocks.vector_source_f(
            52 * [
                0,
            ] + [
                1,
            ] + 47 * [
                0,
            ], True, 1, [])
        self.blocks_vector_source_x_0_0 = blocks.vector_source_f(
            50 * [
                0,
            ] + [
                1,
            ] + 49 * [
                0,
            ], True, 1, [])
        self.blocks_vector_source_x_0 = blocks.vector_source_f(
            49 * [
                0,
            ] + [
                1,
            ] + 50 * [
                0,
            ], True, 1, [])
        self.blocks_throttle_0_1 = blocks.throttle(gr.sizeof_float * 1,
                                                   samp_rate, True)
        self.blocks_throttle_0_0_0 = blocks.throttle(gr.sizeof_float * 1,
                                                     samp_rate, True)
        self.blocks_throttle_0_0 = blocks.throttle(gr.sizeof_float * 1,
                                                   samp_rate, True)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_float * 1,
                                                 samp_rate, True)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_throttle_0, 0),
                     (self.interp_fir_filter_xxx_0, 0))
        self.connect((self.blocks_throttle_0_0, 0),
                     (self.interp_fir_filter_xxx_0_0, 0))
        self.connect((self.blocks_throttle_0_0_0, 0),
                     (self.interp_fir_filter_xxx_0_0_0, 0))
        self.connect((self.blocks_throttle_0_1, 0),
                     (self.interp_fir_filter_xxx_0_1, 0))
        self.connect((self.blocks_vector_source_x_0, 0),
                     (self.blocks_throttle_0, 0))
        self.connect((self.blocks_vector_source_x_0_0, 0),
                     (self.blocks_throttle_0_0, 0))
        self.connect((self.blocks_vector_source_x_0_0_0, 0),
                     (self.blocks_throttle_0_0_0, 0))
        self.connect((self.blocks_vector_source_x_0_1, 0),
                     (self.blocks_throttle_0_1, 0))
        self.connect((self.fir_filter_xxx_0, 0),
                     (self.qtgui_time_sink_x_0_0, 0))
        self.connect((self.fir_filter_xxx_0_0, 0),
                     (self.qtgui_time_sink_x_0_0, 1))
        self.connect((self.fir_filter_xxx_0_0_0, 0),
                     (self.qtgui_time_sink_x_0_0, 3))
        self.connect((self.fir_filter_xxx_0_1, 0),
                     (self.qtgui_time_sink_x_0_0, 2))
        self.connect((self.interp_fir_filter_xxx_0, 0),
                     (self.pfb_arb_resampler_xxx_0, 0))
        self.connect((self.interp_fir_filter_xxx_0, 0),
                     (self.qtgui_time_sink_x_0, 0))
        self.connect((self.interp_fir_filter_xxx_0_0, 0),
                     (self.pfb_arb_resampler_xxx_0_0, 0))
        self.connect((self.interp_fir_filter_xxx_0_0, 0),
                     (self.qtgui_time_sink_x_0, 1))
        self.connect((self.interp_fir_filter_xxx_0_0_0, 0),
                     (self.pfb_arb_resampler_xxx_0_0_1, 0))
        self.connect((self.interp_fir_filter_xxx_0_0_0, 0),
                     (self.qtgui_time_sink_x_0, 3))
        self.connect((self.interp_fir_filter_xxx_0_1, 0),
                     (self.pfb_arb_resampler_xxx_0_0_0, 0))
        self.connect((self.interp_fir_filter_xxx_0_1, 0),
                     (self.qtgui_time_sink_x_0, 2))
        self.connect((self.pfb_arb_resampler_xxx_0, 0),
                     (self.fir_filter_xxx_0, 0))
        self.connect((self.pfb_arb_resampler_xxx_0_0, 0),
                     (self.fir_filter_xxx_0_0, 0))
        self.connect((self.pfb_arb_resampler_xxx_0_0_0, 0),
                     (self.fir_filter_xxx_0_1, 0))
        self.connect((self.pfb_arb_resampler_xxx_0_0_1, 0),
                     (self.fir_filter_xxx_0_0_0, 0))
Ejemplo n.º 26
0
    def __init__(self, samp_rate=4E6, audio_rate=8000, record=True):
        gr.hier_block2.__init__(self, "TunerDemod",
                                gr.io_signature(1, 1, gr.sizeof_gr_complex),
                                gr.io_signature(1, 1, gr.sizeof_float))

        # Default values
        self.center_freq = 0
        squelch_db = -60
        self.quad_demod_gain = 0.050
        self.file_name = "/dev/null"
        self.record = record

        # Decimation values for four stages of decimation
        decims = (5, int(samp_rate / 1E6))

        # Low pass filter taps for decimation by 5
        low_pass_filter_taps_0 = \
            grfilter.firdes_low_pass(1, 1, 0.090, 0.010,
                                     grfilter.firdes.WIN_HAMMING)

        # Frequency translating FIR filter decimating by 5
        self.freq_xlating_fir_filter_ccc = \
            grfilter.freq_xlating_fir_filter_ccc(decims[0],
                                                 low_pass_filter_taps_0,
                                                 self.center_freq, samp_rate)

        # FIR filter decimating by 5
        fir_filter_ccc_0 = grfilter.fir_filter_ccc(decims[0],
                                                   low_pass_filter_taps_0)

        # Low pass filter taps for decimation from samp_rate/25 to 40-79.9 ksps
        # In other words, decimation by int(samp_rate/1E6)
        # 12.5 kHz cutoff for NBFM channel bandwidth
        low_pass_filter_taps_1 = grfilter.firdes_low_pass(
            1, samp_rate / decims[0]**2, 12.5E3, 1E3,
            grfilter.firdes.WIN_HAMMING)

        # FIR filter decimation by int(samp_rate/1E6)
        fir_filter_ccc_1 = grfilter.fir_filter_ccc(decims[1],
                                                   low_pass_filter_taps_1)

        # Non blocking power squelch
        self.analog_pwr_squelch_cc = analog.pwr_squelch_cc(
            squelch_db, 1e-1, 0, False)

        # Quadrature demod with gain set for decent audio
        # This will be later multiplied by the volume
        self.analog_quadrature_demod_cf = \
            analog.quadrature_demod_cf(self.quad_demod_gain)

        # 3.5 kHz cutoff for audio bandwidth
        low_pass_filter_taps_2 = grfilter.firdes_low_pass(1,\
                        samp_rate/(decims[1] * decims[0]**2),\
                        3.5E3, 500, grfilter.firdes.WIN_HAMMING)

        # FIR filter decimating by 5 from 40-79.9 ksps to 8-15.98 ksps
        fir_filter_fff_0 = grfilter.fir_filter_fff(decims[0],
                                                   low_pass_filter_taps_2)

        # Polyphase resampler allows arbitary RF sample rates
        # Takes 8-15.98 ksps to a constant 8 ksps for audio
        pfb_resamp = audio_rate / float(samp_rate / (decims[1] * decims[0]**3))
        pfb_arb_resampler_fff = pfb.arb_resampler_fff(pfb_resamp,
                                                      taps=None,
                                                      flt_size=32)

        # Connect the blocks for the demod
        self.connect(self, self.freq_xlating_fir_filter_ccc)
        self.connect(self.freq_xlating_fir_filter_ccc, fir_filter_ccc_0)
        self.connect(fir_filter_ccc_0, fir_filter_ccc_1)
        self.connect(fir_filter_ccc_1, self.analog_pwr_squelch_cc)
        self.connect(self.analog_pwr_squelch_cc,
                     self.analog_quadrature_demod_cf)
        self.connect(self.analog_quadrature_demod_cf, fir_filter_fff_0)
        self.connect(fir_filter_fff_0, pfb_arb_resampler_fff)
        self.connect(pfb_arb_resampler_fff, self)

        # Need to set this to a very low value of -200 since it is after demod
        # Only want it to gate when the previuos squelch has gone to zero
        analog_pwr_squelch_ff = analog.pwr_squelch_ff(-200, 1e-1, 0, True)

        # File sink with single channel and 8 bits/sample
        self.blocks_wavfile_sink = blocks.wavfile_sink(self.file_name, 1,
                                                       audio_rate, 8)

        # Connect the blocks for recording
        self.connect(pfb_arb_resampler_fff, analog_pwr_squelch_ff)
        self.connect(analog_pwr_squelch_ff, self.blocks_wavfile_sink)
Ejemplo n.º 27
0
    def __init__(self):
        gr.top_block.__init__(self, "Fm Channelizer")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Fm Channelizer")
        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_channelizer")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.synth_channels = synth_channels = 6
        self.channels = channels = 10
        self.ch_rate = ch_rate = 100e3
        self.samp_rate = samp_rate = ch_rate * channels
        self.gain = gain = 20
        self.fm_quad_rate = fm_quad_rate = ch_rate * synth_channels
        self.ch_tb = ch_tb = 20e3
        self.ch_bw = ch_bw = ch_rate / 2
        self.audio_rate = audio_rate = 60e3
        self.atten = atten = 80
        self.volume = volume = 0.1
        self.tun_gain = tun_gain = gain
        self.pfb_taps = pfb_taps = firdes.low_pass_2(1, samp_rate, ch_bw, ch_tb, atten, firdes.WIN_BLACKMAN_HARRIS)
        self.pfb_synth_taps = pfb_synth_taps = firdes.low_pass_2(
            channels / 2, synth_channels * ch_rate, ch_bw, ch_tb, atten, firdes.WIN_BLACKMAN_HARRIS
        )
        self.freq_corr = freq_corr = 0
        self.fm_audio_decim = fm_audio_decim = int(fm_quad_rate / audio_rate) * 2
        self.channel = channel = 0
        self.center_freq = center_freq = 101.1e6 + 0e3
        self.address = address = ""

        ##################################################
        # Blocks
        ##################################################
        self._volume_layout = Qt.QVBoxLayout()
        self._volume_tool_bar = Qt.QToolBar(self)
        self._volume_layout.addWidget(self._volume_tool_bar)
        self._volume_tool_bar.addWidget(Qt.QLabel("Volume" + ": "))

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

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

        self._volume_counter = qwt_counter_pyslot()
        self._volume_counter.setRange(0, 10, 0.1)
        self._volume_counter.setNumButtons(2)
        self._volume_counter.setValue(self.volume)
        self._volume_tool_bar.addWidget(self._volume_counter)
        self._volume_counter.valueChanged.connect(self.set_volume)
        self._volume_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot)
        self._volume_slider.setRange(0, 10, 0.1)
        self._volume_slider.setValue(self.volume)
        self._volume_slider.setMinimumWidth(200)
        self._volume_slider.valueChanged.connect(self.set_volume)
        self._volume_layout.addWidget(self._volume_slider)
        self.top_grid_layout.addLayout(self._volume_layout, 3, 0, 1, 1)
        self._tun_gain_layout = Qt.QVBoxLayout()
        self._tun_gain_tool_bar = Qt.QToolBar(self)
        self._tun_gain_layout.addWidget(self._tun_gain_tool_bar)
        self._tun_gain_tool_bar.addWidget(Qt.QLabel("Gain (dB)" + ": "))

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

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

        self._tun_gain_counter = qwt_counter_pyslot()
        self._tun_gain_counter.setRange(0, 70, 1)
        self._tun_gain_counter.setNumButtons(2)
        self._tun_gain_counter.setValue(self.tun_gain)
        self._tun_gain_tool_bar.addWidget(self._tun_gain_counter)
        self._tun_gain_counter.valueChanged.connect(self.set_tun_gain)
        self._tun_gain_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot)
        self._tun_gain_slider.setRange(0, 70, 1)
        self._tun_gain_slider.setValue(self.tun_gain)
        self._tun_gain_slider.setMinimumWidth(200)
        self._tun_gain_slider.valueChanged.connect(self.set_tun_gain)
        self._tun_gain_layout.addWidget(self._tun_gain_slider)
        self.top_grid_layout.addLayout(self._tun_gain_layout, 2, 1, 1, 1)
        self._freq_corr_layout = Qt.QVBoxLayout()
        self._freq_corr_tool_bar = Qt.QToolBar(self)
        self._freq_corr_layout.addWidget(self._freq_corr_tool_bar)
        self._freq_corr_tool_bar.addWidget(Qt.QLabel("Frequency Correction" + ": "))

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

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

        self._freq_corr_counter = qwt_counter_pyslot()
        self._freq_corr_counter.setRange(-40e3, 40e3, 100)
        self._freq_corr_counter.setNumButtons(2)
        self._freq_corr_counter.setValue(self.freq_corr)
        self._freq_corr_tool_bar.addWidget(self._freq_corr_counter)
        self._freq_corr_counter.valueChanged.connect(self.set_freq_corr)
        self._freq_corr_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot)
        self._freq_corr_slider.setRange(-40e3, 40e3, 100)
        self._freq_corr_slider.setValue(self.freq_corr)
        self._freq_corr_slider.setMinimumWidth(200)
        self._freq_corr_slider.valueChanged.connect(self.set_freq_corr)
        self._freq_corr_layout.addWidget(self._freq_corr_slider)
        self.top_grid_layout.addLayout(self._freq_corr_layout, 3, 1, 1, 1)
        self.uhd_usrp_source_0 = uhd.usrp_source(
            ",".join((address, "")), uhd.stream_args(cpu_format="fc32", channels=range(1))
        )
        self.uhd_usrp_source_0.set_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS)
        self.uhd_usrp_source_0.set_samp_rate(samp_rate)
        self.uhd_usrp_source_0.set_center_freq(center_freq + freq_corr, 0)
        self.uhd_usrp_source_0.set_gain(tun_gain, 0)
        self.uhd_usrp_source_0.set_antenna("RX2", 0)
        self.qtgui_freq_sink_x_0_0_0 = qtgui.freq_sink_c(
            1024,  # size
            firdes.WIN_FLATTOP,  # wintype
            0,  # fc
            ch_rate * synth_channels,  # bw
            "QT GUI Plot",  # name
            1,  # number of inputs
        )
        self.qtgui_freq_sink_x_0_0_0.set_update_time(0.10)
        self.qtgui_freq_sink_x_0_0_0.set_y_axis(-140, 10)
        self.qtgui_freq_sink_x_0_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "")
        self.qtgui_freq_sink_x_0_0_0.enable_autoscale(False)
        self.qtgui_freq_sink_x_0_0_0.enable_grid(False)
        self.qtgui_freq_sink_x_0_0_0.set_fft_average(1.0)

        if complex == type(float()):
            self.qtgui_freq_sink_x_0_0_0.set_plot_pos_half(not True)

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

        self._qtgui_freq_sink_x_0_0_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0_0_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_0_0_win, 1, 1, 1, 1)
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c(
            1024,  # size
            firdes.WIN_BLACKMAN_hARRIS,  # wintype
            0,  # fc
            samp_rate,  # bw
            "QT GUI Plot",  # 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)

        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_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win, 0, 0, 1, 2)
        self.pfb_synthesizer_ccf_0 = filter.pfb_synthesizer_ccf(synth_channels, (pfb_synth_taps), True)
        self.pfb_synthesizer_ccf_0.set_channel_map(([10, 11, 0, 1, 2, 3]))
        self.pfb_synthesizer_ccf_0.declare_sample_delay(0)

        self.pfb_channelizer_ccf_0 = pfb.channelizer_ccf(channels, (pfb_taps), 2.0, atten)
        self.pfb_channelizer_ccf_0.set_channel_map(())
        self.pfb_channelizer_ccf_0.declare_sample_delay(0)

        self.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_fff(
            44.1e3 / (fm_quad_rate / fm_audio_decim), taps=None, flt_size=32
        )
        self.pfb_arb_resampler_xxx_0.declare_sample_delay(0)

        self.fir_filter_xxx_0 = filter.fir_filter_ccc(
            2, (firdes.low_pass_2(1, ch_rate * synth_channels, 250e3, 300e3, 40, firdes.WIN_BLACKMAN_HARRIS))
        )
        self.fir_filter_xxx_0.declare_sample_delay(0)
        self._channel_layout = Qt.QVBoxLayout()
        self._channel_tool_bar = Qt.QToolBar(self)
        self._channel_layout.addWidget(self._channel_tool_bar)
        self._channel_tool_bar.addWidget(Qt.QLabel("Output Channel" + ": "))

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

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

        self._channel_counter = qwt_counter_pyslot()
        self._channel_counter.setRange(0, channels - 1, 1)
        self._channel_counter.setNumButtons(2)
        self._channel_counter.setValue(self.channel)
        self._channel_tool_bar.addWidget(self._channel_counter)
        self._channel_counter.valueChanged.connect(self.set_channel)
        self._channel_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot)
        self._channel_slider.setRange(0, channels - 1, 1)
        self._channel_slider.setValue(self.channel)
        self._channel_slider.setMinimumWidth(200)
        self._channel_slider.valueChanged.connect(self.set_channel)
        self._channel_layout.addWidget(self._channel_slider)
        self.top_grid_layout.addLayout(self._channel_layout, 2, 0, 1, 1)
        self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_gr_complex * 1)
        self.blocks_multiply_const_vxx = blocks.multiply_const_vff((volume,))
        self.audio_sink = audio.sink(44100, "", True)
        self.analog_wfm_rcv = analog.wfm_rcv(quad_rate=fm_quad_rate, audio_decimation=fm_audio_decim)
        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.pfb_channelizer_ccf_0, 0))
        self.connect((self.analog_agc2_xx_0, 0), (self.qtgui_freq_sink_x_0, 0))
        self.connect((self.analog_wfm_rcv, 0), (self.pfb_arb_resampler_xxx_0, 0))
        self.connect((self.blocks_multiply_const_vxx, 0), (self.audio_sink, 0))
        self.connect((self.fir_filter_xxx_0, 0), (self.analog_wfm_rcv, 0))
        self.connect((self.fir_filter_xxx_0, 0), (self.qtgui_freq_sink_x_0_0_0, 0))
        self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.blocks_multiply_const_vxx, 0))
        self.connect((self.pfb_channelizer_ccf_0, 6), (self.blocks_null_sink_0, 0))
        self.connect((self.pfb_channelizer_ccf_0, 7), (self.blocks_null_sink_0, 1))
        self.connect((self.pfb_channelizer_ccf_0, 8), (self.blocks_null_sink_0, 2))
        self.connect((self.pfb_channelizer_ccf_0, 9), (self.blocks_null_sink_0, 3))
        self.connect((self.pfb_channelizer_ccf_0, 0), (self.pfb_synthesizer_ccf_0, 0))
        self.connect((self.pfb_channelizer_ccf_0, 1), (self.pfb_synthesizer_ccf_0, 1))
        self.connect((self.pfb_channelizer_ccf_0, 2), (self.pfb_synthesizer_ccf_0, 2))
        self.connect((self.pfb_channelizer_ccf_0, 3), (self.pfb_synthesizer_ccf_0, 3))
        self.connect((self.pfb_channelizer_ccf_0, 4), (self.pfb_synthesizer_ccf_0, 4))
        self.connect((self.pfb_channelizer_ccf_0, 5), (self.pfb_synthesizer_ccf_0, 5))
        self.connect((self.pfb_synthesizer_ccf_0, 0), (self.fir_filter_xxx_0, 0))
        self.connect((self.uhd_usrp_source_0, 0), (self.analog_agc2_xx_0, 0))
    def __init__(self):
        gr.top_block.__init__(self, "Symbol Differential Filter Phases")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Symbol Differential Filter Phases")
        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",
                                     "symbol_differential_filter_phases")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.sps = sps = 4
        self.ntaps = ntaps = 45
        self.eb = eb = 0.25
        self.samp_rate = samp_rate = 32000
        self.rrc_tx = rrc_tx = firdes.root_raised_cosine(
            sps, sps, 1, eb, sps * ntaps)
        self.rrc_rx = rrc_rx = firdes.root_raised_cosine(
            1.0, sps, 1, eb, ntaps)
        self.rate = rate = 1.2

        ##################################################
        # Blocks
        ##################################################
        self.qtgui_time_sink_x_0_0 = qtgui.time_sink_f(
            7 * sps,  #size
            samp_rate,  #samp_rate
            "QT GUI Plot",  #name
            6  #number of inputs
        )
        self.qtgui_time_sink_x_0_0.set_update_time(0.01)
        self.qtgui_time_sink_x_0_0.set_y_axis(-0.5, 1.25)

        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_NORM,
                                                    qtgui.TRIG_SLOPE_POS, 0.8,
                                                    0.00005 * sps, 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_control_panel(False)

        if not True:
            self.qtgui_time_sink_x_0_0.disable_legend()

        labels = [
            "sym0", "d(sym0)/dt", "d(sym0)/dt + phi1", "d(sym0)/dt + phi2",
            "d(sym0)/dt + phi3", "d(sym0)/dt + phi4", "", "", "", ""
        ]
        widths = [2, 2, 2, 2, 2, 2, 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 = [0, 0, 0, 0, 0, 0, -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(6):
            if len(labels[i]) == 0:
                self.qtgui_time_sink_x_0_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_0_0.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_0_0.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_0_0.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_0_0.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_0_0.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_0_0.set_line_alpha(i, alphas[i])

        self._qtgui_time_sink_x_0_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_0_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_0_win, 0, 1,
                                       1, 1)
        self.pfb_arb_resampler_xxx_0_0_1 = pfb.arb_resampler_fff(rate,
                                                                 taps=None,
                                                                 flt_size=32)
        self.pfb_arb_resampler_xxx_0_0_1.declare_sample_delay(0)

        self.interp_fir_filter_xxx_0 = filter.interp_fir_filter_fff(
            sps, (rrc_tx))
        self.interp_fir_filter_xxx_0.declare_sample_delay(0)
        self.fractional_resampler_xx_0_2 = filter.fractional_resampler_ff(
            0 * 1.0 / 5, 1)
        self.fractional_resampler_xx_0_1_0 = filter.fractional_resampler_ff(
            4 * 1.0 / 5, 1)
        self.fractional_resampler_xx_0_1 = filter.fractional_resampler_ff(
            3 * 1.0 / 5, 1)
        self.fractional_resampler_xx_0_0 = filter.fractional_resampler_ff(
            2 * 1.0 / 5, 1)
        self.fractional_resampler_xx_0 = filter.fractional_resampler_ff(
            1 * 1.0 / 5, 1)
        self.fir_filter_xxx_0_2_0_1_0 = filter.fir_filter_fff(
            1, ([0, -1, 0, 1]))
        self.fir_filter_xxx_0_2_0_1_0.declare_sample_delay(0)
        self.fir_filter_xxx_0_2_0_1 = filter.fir_filter_fff(1, ([0, -1, 0, 1]))
        self.fir_filter_xxx_0_2_0_1.declare_sample_delay(0)
        self.fir_filter_xxx_0_2_0_0 = filter.fir_filter_fff(1, ([0, -1, 0, 1]))
        self.fir_filter_xxx_0_2_0_0.declare_sample_delay(0)
        self.fir_filter_xxx_0_2_0 = filter.fir_filter_fff(1, ([0, -1, 0, 1]))
        self.fir_filter_xxx_0_2_0.declare_sample_delay(0)
        self.fir_filter_xxx_0_2 = filter.fir_filter_fff(1, ([-1, 0, 1]))
        self.fir_filter_xxx_0_2.declare_sample_delay(0)
        self.fir_filter_xxx_0 = filter.fir_filter_fff(1, (rrc_rx))
        self.fir_filter_xxx_0.declare_sample_delay(0)
        self.blocks_vector_source_x_0 = blocks.vector_source_f(
            49 * [
                0,
            ] + [
                1,
            ] + 50 * [
                0,
            ], True, 1, [])
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_float * 1,
                                                 samp_rate, True)
        self.blocks_delay_0_0_4 = blocks.delay(gr.sizeof_float * 1, 1)
        self.blocks_delay_0_0_3 = blocks.delay(gr.sizeof_float * 1, 1)
        self.blocks_delay_0_0_2 = blocks.delay(gr.sizeof_float * 1, 1)
        self.blocks_delay_0_0_1 = blocks.delay(gr.sizeof_float * 1, 1)
        self.blocks_delay_0_0_0 = blocks.delay(gr.sizeof_float * 1, 1)
        self.blocks_delay_0_0 = blocks.delay(gr.sizeof_float * 1, 0)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_delay_0_0, 0),
                     (self.qtgui_time_sink_x_0_0, 0))
        self.connect((self.blocks_delay_0_0_0, 0),
                     (self.qtgui_time_sink_x_0_0, 5))
        self.connect((self.blocks_delay_0_0_1, 0),
                     (self.qtgui_time_sink_x_0_0, 4))
        self.connect((self.blocks_delay_0_0_2, 0),
                     (self.qtgui_time_sink_x_0_0, 3))
        self.connect((self.blocks_delay_0_0_3, 0),
                     (self.qtgui_time_sink_x_0_0, 2))
        self.connect((self.blocks_delay_0_0_4, 0),
                     (self.qtgui_time_sink_x_0_0, 1))
        self.connect((self.blocks_throttle_0, 0),
                     (self.interp_fir_filter_xxx_0, 0))
        self.connect((self.blocks_vector_source_x_0, 0),
                     (self.blocks_throttle_0, 0))
        self.connect((self.fir_filter_xxx_0, 0), (self.blocks_delay_0_0, 0))
        self.connect((self.fir_filter_xxx_0, 0),
                     (self.fractional_resampler_xx_0, 0))
        self.connect((self.fir_filter_xxx_0, 0),
                     (self.fractional_resampler_xx_0_0, 0))
        self.connect((self.fir_filter_xxx_0, 0),
                     (self.fractional_resampler_xx_0_1, 0))
        self.connect((self.fir_filter_xxx_0, 0),
                     (self.fractional_resampler_xx_0_1_0, 0))
        self.connect((self.fir_filter_xxx_0, 0),
                     (self.fractional_resampler_xx_0_2, 0))
        self.connect((self.fir_filter_xxx_0_2, 0),
                     (self.blocks_delay_0_0_4, 0))
        self.connect((self.fir_filter_xxx_0_2_0, 0),
                     (self.blocks_delay_0_0_3, 0))
        self.connect((self.fir_filter_xxx_0_2_0_0, 0),
                     (self.blocks_delay_0_0_2, 0))
        self.connect((self.fir_filter_xxx_0_2_0_1, 0),
                     (self.blocks_delay_0_0_1, 0))
        self.connect((self.fir_filter_xxx_0_2_0_1_0, 0),
                     (self.blocks_delay_0_0_0, 0))
        self.connect((self.fractional_resampler_xx_0, 0),
                     (self.fir_filter_xxx_0_2_0, 0))
        self.connect((self.fractional_resampler_xx_0_0, 0),
                     (self.fir_filter_xxx_0_2_0_0, 0))
        self.connect((self.fractional_resampler_xx_0_1, 0),
                     (self.fir_filter_xxx_0_2_0_1, 0))
        self.connect((self.fractional_resampler_xx_0_1_0, 0),
                     (self.fir_filter_xxx_0_2_0_1_0, 0))
        self.connect((self.fractional_resampler_xx_0_2, 0),
                     (self.fir_filter_xxx_0_2, 0))
        self.connect((self.interp_fir_filter_xxx_0, 0),
                     (self.pfb_arb_resampler_xxx_0_0_1, 0))
        self.connect((self.pfb_arb_resampler_xxx_0_0_1, 0),
                     (self.fir_filter_xxx_0, 0))
Ejemplo n.º 29
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(
            self, title="Stereo FM receiver and RDS Decoder")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Variables
        ##################################################
        self.freq_offset = freq_offset = 250000
        self.freq = freq = 105.3e6
        self.volume = volume = -3
        self.samp_rate = samp_rate = 2000000
        self.gain = gain = 20
        self.freq_tune = freq_tune = freq - freq_offset

        ##################################################
        # Blocks
        ##################################################
        _volume_sizer = wx.BoxSizer(wx.VERTICAL)
        self._volume_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_volume_sizer,
            value=self.volume,
            callback=self.set_volume,
            label='Volume',
            converter=forms.float_converter(),
            proportion=0,
        )
        self._volume_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_volume_sizer,
            value=self.volume,
            callback=self.set_volume,
            minimum=-20,
            maximum=10,
            num_steps=300,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_volume_sizer, 0, 1, 1, 1)
        self.nb = self.nb = wx.Notebook(self.GetWin(), style=wx.NB_TOP)
        self.nb.AddPage(grc_wxgui.Panel(self.nb), "BB")
        self.nb.AddPage(grc_wxgui.Panel(self.nb), "Demod")
        self.nb.AddPage(grc_wxgui.Panel(self.nb), "Waterfall")
        self.nb.AddPage(grc_wxgui.Panel(self.nb), "L+R")
        self.nb.AddPage(grc_wxgui.Panel(self.nb), "L-R")
        self.nb.AddPage(grc_wxgui.Panel(self.nb), "RDS")
        self.nb.AddPage(grc_wxgui.Panel(self.nb), "Const")
        self.GridAdd(self.nb, 2, 0, 1, 2)
        _gain_sizer = wx.BoxSizer(wx.VERTICAL)
        self._gain_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_gain_sizer,
            value=self.gain,
            callback=self.set_gain,
            label='RF Gain',
            converter=forms.float_converter(),
            proportion=0,
        )
        self._gain_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_gain_sizer,
            value=self.gain,
            callback=self.set_gain,
            minimum=0,
            maximum=49.6,
            num_steps=124,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_gain_sizer, 0, 0, 1, 1)
        self.wxgui_waterfallsink2_0 = waterfallsink2.waterfall_sink_f(
            self.nb.GetPage(2).GetWin(),
            baseband_freq=0,
            dynamic_range=100,
            ref_level=0,
            ref_scale=2.0,
            sample_rate=250000,
            fft_size=512,
            fft_rate=15,
            average=False,
            avg_alpha=None,
            title='Waterfall Plot',
        )
        self.nb.GetPage(2).Add(self.wxgui_waterfallsink2_0.win)
        self.wxgui_scopesink2_1 = scopesink2.scope_sink_c(
            self.nb.GetPage(6).GetWin(),
            title='Scope Plot',
            sample_rate=2375 * 4,
            v_scale=0.4,
            v_offset=0,
            t_scale=0,
            ac_couple=False,
            xy_mode=True,
            num_inputs=1,
            trig_mode=wxgui.TRIG_MODE_AUTO,
            y_axis_label='Counts',
        )
        self.nb.GetPage(6).Add(self.wxgui_scopesink2_1.win)
        self.wxgui_fftsink2_0_0_0_1_0_1 = fftsink2.fft_sink_c(
            self.nb.GetPage(5).GetWin(),
            baseband_freq=0,
            y_per_div=10,
            y_divs=10,
            ref_level=0,
            ref_scale=2.0,
            sample_rate=19000,
            fft_size=1024,
            fft_rate=15,
            average=False,
            avg_alpha=None,
            title='RDS',
            peak_hold=False,
        )
        self.nb.GetPage(5).Add(self.wxgui_fftsink2_0_0_0_1_0_1.win)
        self.wxgui_fftsink2_0_0_0_1 = fftsink2.fft_sink_f(
            self.nb.GetPage(4).GetWin(),
            baseband_freq=0,
            y_per_div=10,
            y_divs=10,
            ref_level=0,
            ref_scale=2.0,
            sample_rate=48000,
            fft_size=1024,
            fft_rate=15,
            average=False,
            avg_alpha=None,
            title='L-R',
            peak_hold=False,
        )
        self.nb.GetPage(4).Add(self.wxgui_fftsink2_0_0_0_1.win)
        self.wxgui_fftsink2_0_0_0 = fftsink2.fft_sink_f(
            self.nb.GetPage(3).GetWin(),
            baseband_freq=0,
            y_per_div=10,
            y_divs=10,
            ref_level=0,
            ref_scale=2.0,
            sample_rate=48000,
            fft_size=1024,
            fft_rate=15,
            average=False,
            avg_alpha=None,
            title='L+R',
            peak_hold=False,
        )
        self.nb.GetPage(3).Add(self.wxgui_fftsink2_0_0_0.win)
        self.wxgui_fftsink2_0_0 = fftsink2.fft_sink_f(
            self.nb.GetPage(1).GetWin(),
            baseband_freq=0,
            y_per_div=10,
            y_divs=10,
            ref_level=0,
            ref_scale=2.0,
            sample_rate=250000,
            fft_size=1024,
            fft_rate=15,
            average=True,
            avg_alpha=0.8,
            title='FM Demod',
            peak_hold=False,
        )
        self.nb.GetPage(1).Add(self.wxgui_fftsink2_0_0.win)
        self.wxgui_fftsink2_0 = fftsink2.fft_sink_c(
            self.nb.GetPage(0).GetWin(),
            baseband_freq=0,
            y_per_div=10,
            y_divs=10,
            ref_level=-30,
            ref_scale=2.0,
            sample_rate=samp_rate,
            fft_size=1024,
            fft_rate=15,
            average=True,
            avg_alpha=0.8,
            title='Baseband',
            peak_hold=False,
        )
        self.nb.GetPage(0).Add(self.wxgui_fftsink2_0.win)
        self.rtlsdr_source_0_0 = osmosdr.source(args="numchan=" + str(1) +
                                                " " + '')
        self.rtlsdr_source_0_0.set_sample_rate(samp_rate)
        self.rtlsdr_source_0_0.set_center_freq(freq_tune, 0)
        self.rtlsdr_source_0_0.set_freq_corr(0, 0)
        self.rtlsdr_source_0_0.set_dc_offset_mode(0, 0)
        self.rtlsdr_source_0_0.set_iq_balance_mode(0, 0)
        self.rtlsdr_source_0_0.set_gain_mode(False, 0)
        self.rtlsdr_source_0_0.set_gain(14, 0)
        self.rtlsdr_source_0_0.set_if_gain(24, 0)
        self.rtlsdr_source_0_0.set_bb_gain(gain, 0)
        self.rtlsdr_source_0_0.set_antenna('', 0)
        self.rtlsdr_source_0_0.set_bandwidth(0, 0)

        self.root_raised_cosine_filter_0 = filter.fir_filter_ccf(
            2, firdes.root_raised_cosine(1, 19000, 2375, .35, 100))
        self.pfb_arb_resampler_xxx_1 = pfb.arb_resampler_fff(240000.0 / 250000,
                                                             taps=None,
                                                             flt_size=32)
        self.pfb_arb_resampler_xxx_1.declare_sample_delay(0)

        self.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_ccf(19000 / 250e3,
                                                             taps=None,
                                                             flt_size=32)
        self.pfb_arb_resampler_xxx_0.declare_sample_delay(0)

        self.freq_xlating_fir_filter_xxx_2 = filter.freq_xlating_fir_filter_fcf(
            5, (firdes.low_pass(1.0, 240000, 13e3, 3e3, firdes.WIN_HAMMING)),
            38000, 240000)
        self.freq_xlating_fir_filter_xxx_1_0 = filter.freq_xlating_fir_filter_fcc(
            1,
            (firdes.low_pass(2500.0, 250000, 2.6e3, 2e3, firdes.WIN_HAMMING)),
            57e3, 250000)
        self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(
            1, (firdes.low_pass(1, samp_rate, 80000, 20000)), freq_offset,
            samp_rate)
        _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, 1, 0, 1, 2)
        self.fir_filter_xxx_1 = filter.fir_filter_fff(
            5, (firdes.low_pass(1.0, 240000, 13e3, 3e3, firdes.WIN_HAMMING)))
        self.fir_filter_xxx_1.declare_sample_delay(0)
        self.blocks_sub_xx_0 = blocks.sub_ff(1)
        self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vff(
            (10**(1. * (volume) / 10), ))
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff(
            (10**(1. * (volume) / 10), ))
        self.blocks_complex_to_real_0 = blocks.complex_to_real(1)
        self.blocks_add_xx_0 = blocks.add_vff(1)
        self.audio_sink_0 = audio.sink(48000, '', True)
        self.analog_wfm_rcv_0 = analog.wfm_rcv(
            quad_rate=samp_rate,
            audio_decimation=8,
        )
        self.analog_fm_deemph_0_0_0 = analog.fm_deemph(fs=48000, tau=75e-6)
        self.analog_fm_deemph_0_0 = analog.fm_deemph(fs=48000, tau=75e-6)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_fm_deemph_0_0, 0),
                     (self.blocks_multiply_const_vxx_0_0, 0))
        self.connect((self.analog_fm_deemph_0_0_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.analog_wfm_rcv_0, 0),
                     (self.freq_xlating_fir_filter_xxx_1_0, 0))
        self.connect((self.analog_wfm_rcv_0, 0),
                     (self.pfb_arb_resampler_xxx_1, 0))
        self.connect((self.analog_wfm_rcv_0, 0), (self.wxgui_fftsink2_0_0, 0))
        self.connect((self.analog_wfm_rcv_0, 0),
                     (self.wxgui_waterfallsink2_0, 0))
        self.connect((self.blocks_add_xx_0, 0),
                     (self.analog_fm_deemph_0_0_0, 0))
        self.connect((self.blocks_complex_to_real_0, 0),
                     (self.blocks_add_xx_0, 1))
        self.connect((self.blocks_complex_to_real_0, 0),
                     (self.blocks_sub_xx_0, 1))
        self.connect((self.blocks_complex_to_real_0, 0),
                     (self.wxgui_fftsink2_0_0_0_1, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.audio_sink_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0_0, 0),
                     (self.audio_sink_0, 1))
        self.connect((self.blocks_sub_xx_0, 0), (self.analog_fm_deemph_0_0, 0))
        self.connect((self.fir_filter_xxx_1, 0), (self.blocks_add_xx_0, 0))
        self.connect((self.fir_filter_xxx_1, 0), (self.blocks_sub_xx_0, 0))
        self.connect((self.fir_filter_xxx_1, 0),
                     (self.wxgui_fftsink2_0_0_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0),
                     (self.analog_wfm_rcv_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_1_0, 0),
                     (self.pfb_arb_resampler_xxx_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_2, 0),
                     (self.blocks_complex_to_real_0, 0))
        self.connect((self.pfb_arb_resampler_xxx_0, 0),
                     (self.root_raised_cosine_filter_0, 0))
        self.connect((self.pfb_arb_resampler_xxx_0, 0),
                     (self.wxgui_fftsink2_0_0_0_1_0_1, 0))
        self.connect((self.pfb_arb_resampler_xxx_1, 0),
                     (self.fir_filter_xxx_1, 0))
        self.connect((self.pfb_arb_resampler_xxx_1, 0),
                     (self.freq_xlating_fir_filter_xxx_2, 0))
        self.connect((self.root_raised_cosine_filter_0, 0),
                     (self.wxgui_scopesink2_1, 0))
        self.connect((self.rtlsdr_source_0_0, 0),
                     (self.freq_xlating_fir_filter_xxx_0, 0))