def __init__(self, input_path, sample_rate, output_path): gr.top_block.__init__(self) # We don't use the existing NBFM demodulator block because it # contains a lowpass output filter which is unsuitable for 9600 # GMSK (it's designed for voice). self.source = gr.file_source(gr.sizeof_gr_complex * 1, input_path, False) self.low_pass_filter = gr.fir_filter_ccf( 4, firdes.low_pass(1, sample_rate, 15000, 100, firdes.WIN_HAMMING, 6.76)) # High pass filter to remove the DC component. This is important # when the signal is near the SDR's local oscillator. # NOTE(tstranex): Disabled since we are now shifting the FCD # center frequency instead. #self.high_pass_filter = gr.fir_filter_ccf(1, firdes.high_pass( # 1, sample_rate/4, 100, 100, firdes.WIN_HAMMING, 6.76)) self.quadrature_demod = gr.quadrature_demod_cf(sample_rate / 4 / (2 * 3.14 * 3000)) self.fm_deemph = blks2.fm_deemph(fs=sample_rate / 4, tau=75e-6) self.boost_volume = gr.multiply_const_vff((1.52, )) self.sink = gr.wavfile_sink(output_path, 1, sample_rate / 4, 16) self.connect((self.source, 0), (self.low_pass_filter, 0)) #self.connect((self.low_pass_filter, 0), (self.high_pass_filter, 0)) #self.connect((self.high_pass_filter, 0), (self.quadrature_demod, 0)) self.connect((self.low_pass_filter, 0), (self.quadrature_demod, 0)) self.connect((self.quadrature_demod, 0), (self.fm_deemph, 0)) self.connect((self.fm_deemph, 0), (self.boost_volume, 0)) self.connect((self.boost_volume, 0), (self.sink, 0))
def __init__(self, input_path, sample_rate, output_path): gr.top_block.__init__(self) # We don't use the existing NBFM demodulator block because it # contains a lowpass output filter which is unsuitable for 9600 # GMSK (it's designed for voice). self.source = gr.file_source(gr.sizeof_gr_complex * 1, input_path, False) self.low_pass_filter = gr.fir_filter_ccf( 4, firdes.low_pass(1, sample_rate, 15000, 100, firdes.WIN_HAMMING, 6.76) ) # High pass filter to remove the DC component. This is important # when the signal is near the SDR's local oscillator. # NOTE(tstranex): Disabled since we are now shifting the FCD # center frequency instead. # self.high_pass_filter = gr.fir_filter_ccf(1, firdes.high_pass( # 1, sample_rate/4, 100, 100, firdes.WIN_HAMMING, 6.76)) self.quadrature_demod = gr.quadrature_demod_cf(sample_rate / 4 / (2 * 3.14 * 3000)) self.fm_deemph = blks2.fm_deemph(fs=sample_rate / 4, tau=75e-6) self.boost_volume = gr.multiply_const_vff((1.52,)) self.sink = gr.wavfile_sink(output_path, 1, sample_rate / 4, 16) self.connect((self.source, 0), (self.low_pass_filter, 0)) # self.connect((self.low_pass_filter, 0), (self.high_pass_filter, 0)) # self.connect((self.high_pass_filter, 0), (self.quadrature_demod, 0)) self.connect((self.low_pass_filter, 0), (self.quadrature_demod, 0)) self.connect((self.quadrature_demod, 0), (self.fm_deemph, 0)) self.connect((self.fm_deemph, 0), (self.boost_volume, 0)) self.connect((self.boost_volume, 0), (self.sink, 0))
def __init__(self, devid="type=b100", rdsfile="rds_fifo", gain=35.0, freq=101.1e6, xmlport=13777, arate=int(48e3), mute=-15.0, ftune=0, ant="J1", subdev="A:0", ahw="pulse", deemph=75.0e-6, prenames='["UWRF","89.3","950","WEVR"]', prefreqs="[88.715e6,89.3e6,950.735e6,106.317e6]", volume=1.0): grc_wxgui.top_block_gui.__init__(self, title="Simple FM (Stereo) Receiver") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Parameters ################################################## self.devid = devid self.rdsfile = rdsfile self.gain = gain self.freq = freq self.xmlport = xmlport self.arate = arate self.mute = mute self.ftune = ftune self.ant = ant self.subdev = subdev self.ahw = ahw self.deemph = deemph self.prenames = prenames self.prefreqs = prefreqs self.volume = volume ################################################## # Variables ################################################## self.pthresh = pthresh = 350 self.preselect = preselect = eval(prefreqs)[0] self.pilot_level = pilot_level = 0 self.ifreq = ifreq = freq self.stpilotdet = stpilotdet = True if (pilot_level > pthresh) else False self.stereo = stereo = True self.rf_pwr_lvl = rf_pwr_lvl = 0 self.cur_freq = cur_freq = simple_fm_helper.freq_select(ifreq,preselect) self.vol = vol = volume self.variable_static_text_0 = variable_static_text_0 = 10.0*math.log(rf_pwr_lvl+1.0e-11)/math.log(10) self.tone_med = tone_med = 5 self.tone_low = tone_low = 5 self.tone_high = tone_high = 5 self.stereo_0 = stereo_0 = stpilotdet self.st_enabled = st_enabled = 1 if (stereo == True and pilot_level > pthresh) else 0 self.squelch_probe = squelch_probe = 0 self.sq_thresh = sq_thresh = mute self.samp_rate = samp_rate = 250e3 self.rtext_0 = rtext_0 = cur_freq self.record = record = False self.rdsrate = rdsrate = 25e3 self.osmo_taps = osmo_taps = firdes.low_pass(1.0,1.00e6,95e3,20e3,firdes.WIN_HAMMING,6.76) self.mod_reset = mod_reset = 0 self.igain = igain = gain self.fine = fine = ftune self.farate = farate = arate self.dm = dm = deemph self.discrim_dc = discrim_dc = 0 self.capture_file = capture_file = "capture.wav" self.asrate = asrate = 125e3 ################################################## # Blocks ################################################## _sq_thresh_sizer = wx.BoxSizer(wx.VERTICAL) self._sq_thresh_text_box = forms.text_box( parent=self.GetWin(), sizer=_sq_thresh_sizer, value=self.sq_thresh, callback=self.set_sq_thresh, label="Mute Level", converter=forms.float_converter(), proportion=0, ) self._sq_thresh_slider = forms.slider( parent=self.GetWin(), sizer=_sq_thresh_sizer, value=self.sq_thresh, callback=self.set_sq_thresh, minimum=-30.0, maximum=-5.0, num_steps=40, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_sq_thresh_sizer, 1, 5, 1, 1) self.input_power = gr.probe_avg_mag_sqrd_c(sq_thresh, 1.0/(samp_rate/10)) self.dc_level = gr.probe_signal_f() _vol_sizer = wx.BoxSizer(wx.VERTICAL) self._vol_text_box = forms.text_box( parent=self.GetWin(), sizer=_vol_sizer, value=self.vol, callback=self.set_vol, label="Volume", converter=forms.float_converter(), proportion=0, ) self._vol_slider = forms.slider( parent=self.GetWin(), sizer=_vol_sizer, value=self.vol, callback=self.set_vol, minimum=0, maximum=11, num_steps=110, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_vol_sizer, 0, 3, 1, 1) _tone_med_sizer = wx.BoxSizer(wx.VERTICAL) self._tone_med_text_box = forms.text_box( parent=self.GetWin(), sizer=_tone_med_sizer, value=self.tone_med, callback=self.set_tone_med, label="1Khz-4Khz", converter=forms.float_converter(), proportion=0, ) self._tone_med_slider = forms.slider( parent=self.GetWin(), sizer=_tone_med_sizer, value=self.tone_med, callback=self.set_tone_med, minimum=0, maximum=10, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_tone_med_sizer, 1, 3, 1, 1) _tone_low_sizer = wx.BoxSizer(wx.VERTICAL) self._tone_low_text_box = forms.text_box( parent=self.GetWin(), sizer=_tone_low_sizer, value=self.tone_low, callback=self.set_tone_low, label="0-1Khz", converter=forms.float_converter(), proportion=0, ) self._tone_low_slider = forms.slider( parent=self.GetWin(), sizer=_tone_low_sizer, value=self.tone_low, callback=self.set_tone_low, minimum=0, maximum=10, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_tone_low_sizer, 1, 2, 1, 1) _tone_high_sizer = wx.BoxSizer(wx.VERTICAL) self._tone_high_text_box = forms.text_box( parent=self.GetWin(), sizer=_tone_high_sizer, value=self.tone_high, callback=self.set_tone_high, label="4Khz-15Khz", converter=forms.float_converter(), proportion=0, ) self._tone_high_slider = forms.slider( parent=self.GetWin(), sizer=_tone_high_sizer, value=self.tone_high, callback=self.set_tone_high, minimum=0, maximum=10, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_tone_high_sizer, 1, 4, 1, 1) def _squelch_probe_probe(): while True: val = self.input_power.unmuted() try: self.set_squelch_probe(val) except AttributeError, e: pass time.sleep(1.0/(10)) _squelch_probe_thread = threading.Thread(target=_squelch_probe_probe) _squelch_probe_thread.daemon = True _squelch_probe_thread.start() self._record_check_box = forms.check_box( parent=self.GetWin(), value=self.record, callback=self.set_record, label="Record Audio", true=True, false=False, ) self.GridAdd(self._record_check_box, 2, 2, 1, 1) self.pilot_probe = gr.probe_signal_f() _fine_sizer = wx.BoxSizer(wx.VERTICAL) self._fine_text_box = forms.text_box( parent=self.GetWin(), sizer=_fine_sizer, value=self.fine, callback=self.set_fine, label="Fine Tuning", converter=forms.float_converter(), proportion=0, ) self._fine_slider = forms.slider( parent=self.GetWin(), sizer=_fine_sizer, value=self.fine, callback=self.set_fine, minimum=-50.0e3, maximum=50.e03, num_steps=400, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_fine_sizer, 1, 0, 1, 1) def _discrim_dc_probe(): while True: val = self.dc_level.level() try: self.set_discrim_dc(val) except AttributeError, e: pass time.sleep(1.0/(2.5)) _discrim_dc_thread = threading.Thread(target=_discrim_dc_probe) _discrim_dc_thread.daemon = True _discrim_dc_thread.start() self._capture_file_text_box = forms.text_box( parent=self.GetWin(), value=self.capture_file, callback=self.set_capture_file, label="Record Filename", converter=forms.str_converter(), ) self.GridAdd(self._capture_file_text_box, 2, 0, 1, 2) self.Main = self.Main = wx.Notebook(self.GetWin(), style=wx.NB_TOP) self.Main.AddPage(grc_wxgui.Panel(self.Main), "L/R") self.Main.AddPage(grc_wxgui.Panel(self.Main), "FM Demod Spectrum") self.Add(self.Main) self.wxgui_waterfallsink2_0 = waterfallsink2.waterfall_sink_c( self.GetWin(), baseband_freq=0, dynamic_range=100, ref_level=0, ref_scale=2.0, sample_rate=samp_rate, fft_size=512, fft_rate=15, average=False, avg_alpha=None, title="Waterfall Plot", ) self.Add(self.wxgui_waterfallsink2_0.win) self.wxgui_scopesink2_0 = scopesink2.scope_sink_f( self.Main.GetPage(0).GetWin(), title="Audio Channels (L and R)", sample_rate=farate, v_scale=0, v_offset=0, t_scale=0, ac_couple=False, xy_mode=False, num_inputs=2, trig_mode=gr.gr_TRIG_MODE_AUTO, y_axis_label="Rel. Audio Level", ) self.Main.GetPage(0).Add(self.wxgui_scopesink2_0.win) self.wxgui_fftsink2_0 = fftsink2.fft_sink_f( self.Main.GetPage(1).GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=asrate, fft_size=1024, fft_rate=6, average=True, avg_alpha=0.1, title="FM Demod Spectrum", peak_hold=False, ) self.Main.GetPage(1).Add(self.wxgui_fftsink2_0.win) self._variable_static_text_0_static_text = forms.static_text( parent=self.GetWin(), value=self.variable_static_text_0, callback=self.set_variable_static_text_0, label="RF Power ", converter=forms.float_converter(formatter=lambda x: "%4.1f" % x), ) self.GridAdd(self._variable_static_text_0_static_text, 0, 2, 1, 1) self._stereo_0_check_box = forms.check_box( parent=self.GetWin(), value=self.stereo_0, callback=self.set_stereo_0, label="Stereo Detect", true=True, false=False, ) self.GridAdd(self._stereo_0_check_box, 2, 5, 1, 1) self._stereo_check_box = forms.check_box( parent=self.GetWin(), value=self.stereo, callback=self.set_stereo, label="Stereo", true=True, false=False, ) self.GridAdd(self._stereo_check_box, 2, 4, 1, 1) self.rtl2832_source_0 = baz.rtl_source_c(defer_creation=True) self.rtl2832_source_0.set_verbose(True) self.rtl2832_source_0.set_vid(0x0) self.rtl2832_source_0.set_pid(0x0) self.rtl2832_source_0.set_tuner_name("") self.rtl2832_source_0.set_default_timeout(0) self.rtl2832_source_0.set_use_buffer(True) self.rtl2832_source_0.set_fir_coefficients(([])) if self.rtl2832_source_0.create() == False: raise Exception("Failed to create RTL2832 Source: rtl2832_source_0") self.rtl2832_source_0.set_sample_rate(1.0e6) self.rtl2832_source_0.set_frequency(cur_freq+200e3) self.rtl2832_source_0.set_auto_gain_mode(False) self.rtl2832_source_0.set_relative_gain(True) self.rtl2832_source_0.set_gain(gain) self._rtext_0_static_text = forms.static_text( parent=self.GetWin(), value=self.rtext_0, callback=self.set_rtext_0, label="CURRENT FREQUENCY>>", converter=forms.float_converter(), ) self.GridAdd(self._rtext_0_static_text, 0, 1, 1, 1) def _rf_pwr_lvl_probe(): while True: val = self.input_power.level() try: self.set_rf_pwr_lvl(val) except AttributeError, e: pass time.sleep(1.0/(2)) _rf_pwr_lvl_thread = threading.Thread(target=_rf_pwr_lvl_probe) _rf_pwr_lvl_thread.daemon = True _rf_pwr_lvl_thread.start() self._preselect_chooser = forms.radio_buttons( parent=self.GetWin(), value=self.preselect, callback=self.set_preselect, label='preselect', choices=eval(prefreqs), labels=eval(prenames), style=wx.RA_HORIZONTAL, ) self.GridAdd(self._preselect_chooser, 0, 4, 1, 1) def _pilot_level_probe(): while True: val = self.pilot_probe.level() try: self.set_pilot_level(val) except AttributeError, e: pass time.sleep(1.0/(5)) _pilot_level_thread = threading.Thread(target=_pilot_level_probe) _pilot_level_thread.daemon = True _pilot_level_thread.start() self.low_pass_filter_3 = gr.fir_filter_fff(1, firdes.low_pass( 3, asrate/500, 10, 3, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_2 = gr.fir_filter_fff(10, firdes.low_pass( 3, asrate/50, 100, 30, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_1 = gr.fir_filter_fff(10, firdes.low_pass( 3, asrate/5, 1e3, 200, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_0 = gr.fir_filter_fff(5, firdes.low_pass( 3, asrate, 10e3, 2e3, firdes.WIN_HAMMING, 6.76)) _igain_sizer = wx.BoxSizer(wx.VERTICAL) self._igain_text_box = forms.text_box( parent=self.GetWin(), sizer=_igain_sizer, value=self.igain, callback=self.set_igain, label="RF Gain", converter=forms.float_converter(), proportion=0, ) self._igain_slider = forms.slider( parent=self.GetWin(), sizer=_igain_sizer, value=self.igain, callback=self.set_igain, minimum=0, maximum=50, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_igain_sizer, 1, 1, 1, 1) _ifreq_sizer = wx.BoxSizer(wx.VERTICAL) self._ifreq_text_box = forms.text_box( parent=self.GetWin(), sizer=_ifreq_sizer, value=self.ifreq, callback=self.set_ifreq, label="Center Frequency", converter=forms.float_converter(), proportion=0, ) self._ifreq_slider = forms.slider( parent=self.GetWin(), sizer=_ifreq_sizer, value=self.ifreq, callback=self.set_ifreq, minimum=88.1e6, maximum=108.1e6, num_steps=200, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_ifreq_sizer, 0, 0, 1, 1) self.gr_wavfile_sink_0 = gr.wavfile_sink("/dev/null" if record == False else capture_file, 2, int(farate), 16) self.gr_sub_xx_0 = gr.sub_ff(1) self.gr_single_pole_iir_filter_xx_1 = gr.single_pole_iir_filter_ff(2.5/(asrate/500), 1) self.gr_single_pole_iir_filter_xx_0 = gr.single_pole_iir_filter_ff(1.0/(asrate/3), 1) self.gr_multiply_xx_1 = gr.multiply_vff(1) self.gr_multiply_xx_0_0 = gr.multiply_vff(1) self.gr_multiply_xx_0 = gr.multiply_vff(1) self.gr_multiply_const_vxx_3 = gr.multiply_const_vff((3.16e3 if st_enabled else 0, )) self.gr_multiply_const_vxx_2 = gr.multiply_const_vff((1.0 if st_enabled else 1.414, )) self.gr_multiply_const_vxx_1_0 = gr.multiply_const_vff((0 if st_enabled else 1, )) self.gr_multiply_const_vxx_1 = gr.multiply_const_vff((0 if squelch_probe == 0 else 1.0, )) self.gr_multiply_const_vxx_0_0 = gr.multiply_const_vff((vol*1.5*10.0, )) self.gr_multiply_const_vxx_0 = gr.multiply_const_vff((vol*1.5*10.0 if st_enabled else 0, )) self.gr_keep_one_in_n_0 = gr.keep_one_in_n(gr.sizeof_float*1, int(asrate/3)) self.gr_freq_xlating_fir_filter_xxx_0 = gr.freq_xlating_fir_filter_ccc(4, (osmo_taps), 200e3+fine+(-12e3*discrim_dc), 1.0e6) self.gr_fractional_interpolator_xx_0_0 = gr.fractional_interpolator_ff(0, asrate/farate) self.gr_fractional_interpolator_xx_0 = gr.fractional_interpolator_ff(0, asrate/farate) self.gr_fft_filter_xxx_1_0_0 = gr.fft_filter_fff(1, (firdes.band_pass(tone_high/10.0,asrate,3.5e3,15.0e3,5.0e3,firdes.WIN_HAMMING)), 1) self.gr_fft_filter_xxx_1_0 = gr.fft_filter_fff(1, (firdes.band_pass(tone_med/10.0,asrate,1.0e3,4.0e3,2.0e3,firdes.WIN_HAMMING)), 1) self.gr_fft_filter_xxx_1 = gr.fft_filter_fff(1, (firdes.low_pass(tone_low/10.0,asrate,1.2e3,500,firdes.WIN_HAMMING)), 1) self.gr_fft_filter_xxx_0_0_0 = gr.fft_filter_fff(1, (firdes.band_pass(tone_high/10.0,asrate,3.5e3,13.5e3,3.5e3,firdes.WIN_HAMMING)), 1) self.gr_fft_filter_xxx_0_0 = gr.fft_filter_fff(1, (firdes.band_pass(tone_med/10.0,asrate,1.0e3,4.0e3,2.0e3,firdes.WIN_HAMMING)), 1) self.gr_fft_filter_xxx_0 = gr.fft_filter_fff(1, (firdes.low_pass(tone_low/10.0,asrate,1.2e3,500,firdes.WIN_HAMMING)), 1) self.gr_divide_xx_0 = gr.divide_ff(1) self.gr_agc_xx_1 = gr.agc_cc(1e-2, 0.35, 1.0, 5000) self.gr_add_xx_2_0 = gr.add_vff(1) self.gr_add_xx_2 = gr.add_vff(1) self.gr_add_xx_1 = gr.add_vff(1) self.gr_add_xx_0 = gr.add_vff(1) self.gr_add_const_vxx_0 = gr.add_const_vff((1.0e-7, )) self._dm_chooser = forms.radio_buttons( parent=self.GetWin(), value=self.dm, callback=self.set_dm, label="FM Deemphasis", choices=[75.0e-6, 50.0e-6], labels=["NA", "EU"], style=wx.RA_HORIZONTAL, ) self.GridAdd(self._dm_chooser, 0, 5, 1, 1) self.blks2_wfm_rcv_0 = blks2.wfm_rcv( quad_rate=samp_rate, audio_decimation=2, ) self.blks2_fm_deemph_0_0 = blks2.fm_deemph(fs=farate, tau=deemph) self.blks2_fm_deemph_0 = blks2.fm_deemph(fs=farate, tau=deemph) self.band_pass_filter_2_0 = gr.fir_filter_fff(1, firdes.band_pass( 20, asrate, 17.5e3, 17.9e3, 250, firdes.WIN_HAMMING, 6.76)) self.band_pass_filter_2 = gr.fir_filter_fff(1, firdes.band_pass( 10, asrate, 18.8e3, 19.2e3, 350, firdes.WIN_HAMMING, 6.76)) self.band_pass_filter_0_0 = gr.fir_filter_fff(1, firdes.band_pass( 1, asrate, 38e3-(15e3), 38e3+(15e3), 4.0e3, firdes.WIN_HAMMING, 6.76)) self.audio_sink_0 = audio.sink(int(farate), "" if ahw == "Default" else ahw, True) ################################################## # Connections ################################################## self.connect((self.gr_add_xx_1, 0), (self.gr_fractional_interpolator_xx_0, 0)) self.connect((self.gr_sub_xx_0, 0), (self.gr_fractional_interpolator_xx_0_0, 0)) self.connect((self.band_pass_filter_0_0, 0), (self.gr_multiply_xx_1, 0)) self.connect((self.gr_multiply_const_vxx_1_0, 0), (self.gr_add_xx_0, 0)) self.connect((self.band_pass_filter_2_0, 0), (self.gr_multiply_xx_0, 0)) self.connect((self.band_pass_filter_2_0, 0), (self.gr_multiply_xx_0, 1)) self.connect((self.gr_multiply_xx_0_0, 0), (self.gr_divide_xx_0, 0)) self.connect((self.gr_divide_xx_0, 0), (self.gr_single_pole_iir_filter_xx_0, 0)) self.connect((self.gr_multiply_xx_0, 0), (self.gr_add_const_vxx_0, 0)) self.connect((self.gr_add_const_vxx_0, 0), (self.gr_divide_xx_0, 1)) self.connect((self.gr_single_pole_iir_filter_xx_0, 0), (self.gr_keep_one_in_n_0, 0)) self.connect((self.gr_keep_one_in_n_0, 0), (self.pilot_probe, 0)) self.connect((self.band_pass_filter_2, 0), (self.gr_multiply_xx_1, 2)) self.connect((self.band_pass_filter_2, 0), (self.gr_multiply_xx_0_0, 0)) self.connect((self.gr_multiply_const_vxx_2, 0), (self.gr_add_xx_1, 0)) self.connect((self.gr_multiply_const_vxx_2, 0), (self.gr_sub_xx_0, 0)) self.connect((self.gr_multiply_const_vxx_3, 0), (self.gr_sub_xx_0, 1)) self.connect((self.gr_multiply_const_vxx_3, 0), (self.gr_add_xx_1, 1)) self.connect((self.gr_fractional_interpolator_xx_0, 0), (self.gr_multiply_const_vxx_0_0, 0)) self.connect((self.gr_fractional_interpolator_xx_0_0, 0), (self.gr_multiply_const_vxx_0, 0)) self.connect((self.band_pass_filter_2, 0), (self.gr_multiply_xx_1, 1)) self.connect((self.gr_multiply_xx_1, 0), (self.gr_fft_filter_xxx_0, 0)) self.connect((self.gr_fft_filter_xxx_1, 0), (self.gr_add_xx_2, 0)) self.connect((self.gr_fft_filter_xxx_1_0, 0), (self.gr_add_xx_2, 1)) self.connect((self.gr_fft_filter_xxx_1_0_0, 0), (self.gr_add_xx_2, 2)) self.connect((self.gr_add_xx_2, 0), (self.gr_multiply_const_vxx_2, 0)) self.connect((self.gr_add_xx_2_0, 0), (self.gr_multiply_const_vxx_3, 0)) self.connect((self.gr_fft_filter_xxx_0, 0), (self.gr_add_xx_2_0, 0)) self.connect((self.gr_fft_filter_xxx_0_0, 0), (self.gr_add_xx_2_0, 1)) self.connect((self.gr_multiply_xx_1, 0), (self.gr_fft_filter_xxx_0_0, 0)) self.connect((self.gr_fft_filter_xxx_0_0_0, 0), (self.gr_add_xx_2_0, 2)) self.connect((self.gr_multiply_xx_1, 0), (self.gr_fft_filter_xxx_0_0_0, 0)) self.connect((self.blks2_fm_deemph_0, 0), (self.gr_multiply_const_vxx_1_0, 0)) self.connect((self.blks2_fm_deemph_0, 0), (self.gr_wavfile_sink_0, 0)) self.connect((self.gr_multiply_const_vxx_1, 0), (self.gr_fft_filter_xxx_1, 0)) self.connect((self.gr_multiply_const_vxx_1, 0), (self.gr_fft_filter_xxx_1_0, 0)) self.connect((self.gr_multiply_const_vxx_1, 0), (self.gr_fft_filter_xxx_1_0_0, 0)) self.connect((self.gr_multiply_const_vxx_1, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.gr_multiply_const_vxx_0_0, 0), (self.blks2_fm_deemph_0, 0)) self.connect((self.gr_add_xx_0, 0), (self.audio_sink_0, 1)) self.connect((self.gr_multiply_const_vxx_0, 0), (self.blks2_fm_deemph_0_0, 0)) self.connect((self.blks2_fm_deemph_0_0, 0), (self.gr_add_xx_0, 1)) self.connect((self.band_pass_filter_2, 0), (self.gr_multiply_xx_0_0, 1)) self.connect((self.gr_multiply_const_vxx_1, 0), (self.band_pass_filter_2, 0)) self.connect((self.blks2_fm_deemph_0, 0), (self.audio_sink_0, 0)) self.connect((self.gr_multiply_const_vxx_1, 0), (self.band_pass_filter_2_0, 0)) self.connect((self.gr_multiply_const_vxx_1, 0), (self.band_pass_filter_0_0, 0)) self.connect((self.gr_add_xx_0, 0), (self.gr_wavfile_sink_0, 1)) self.connect((self.blks2_fm_deemph_0, 0), (self.wxgui_scopesink2_0, 0)) self.connect((self.gr_add_xx_0, 0), (self.wxgui_scopesink2_0, 1)) self.connect((self.blks2_wfm_rcv_0, 0), (self.gr_multiply_const_vxx_1, 0)) self.connect((self.gr_agc_xx_1, 0), (self.blks2_wfm_rcv_0, 0)) self.connect((self.gr_freq_xlating_fir_filter_xxx_0, 0), (self.gr_agc_xx_1, 0)) self.connect((self.gr_freq_xlating_fir_filter_xxx_0, 0), (self.input_power, 0)) self.connect((self.blks2_wfm_rcv_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.low_pass_filter_1, 0)) self.connect((self.low_pass_filter_1, 0), (self.low_pass_filter_2, 0)) self.connect((self.low_pass_filter_2, 0), (self.low_pass_filter_3, 0)) self.connect((self.gr_single_pole_iir_filter_xx_1, 0), (self.dc_level, 0)) self.connect((self.low_pass_filter_3, 0), (self.gr_single_pole_iir_filter_xx_1, 0)) self.connect((self.rtl2832_source_0, 0), (self.gr_freq_xlating_fir_filter_xxx_0, 0)) self.connect((self.gr_freq_xlating_fir_filter_xxx_0, 0), (self.wxgui_waterfallsink2_0, 0))
def __init__(self,frame,panel,vbox,argv): stdgui2.std_top_block.__init__ (self,frame,panel,vbox,argv) parser=OptionParser(option_class=eng_option) parser.add_option("-a", "--args", type="string", default="", help="UHD device address args [default=%default]") parser.add_option("", "--spec", type="string", default=None, help="Subdevice of UHD device where appropriate") parser.add_option("-A", "--antenna", type="string", default=None, help="select Rx Antenna where appropriate") parser.add_option("-f", "--freq", type="eng_float", default=100.1e6, help="set frequency to FREQ", metavar="FREQ") parser.add_option("-g", "--gain", type="eng_float", default=None, help="set gain in dB (default is midpoint)") parser.add_option("-V", "--volume", type="eng_float", default=None, help="set volume (default is midpoint)") parser.add_option("-O", "--audio-output", type="string", default="default", help="pcm device name. E.g., hw:0,0 or surround51 or /dev/dsp") parser.add_option("", "--freq-min", type="eng_float", default=87.9e6, help="Set a minimum frequency [default=%default]") parser.add_option("", "--freq-max", type="eng_float", default=108.1e6, help="Set a maximum frequency [default=%default]") (options, args) = parser.parse_args() if len(args) != 0: parser.print_help() sys.exit(1) self.frame = frame self.panel = panel self.vol = 0 self.state = "FREQ" self.freq = 0 self.fm_freq_min = options.freq_min self.fm_freq_max = options.freq_max # build graph self.u = uhd.usrp_source(device_addr=options.args, stream_args=uhd.stream_args('fc32')) # Set the subdevice spec if(options.spec): self.u.set_subdev_spec(options.spec, 0) # Set the antenna if(options.antenna): self.u.set_antenna(options.antenna, 0) usrp_rate = 320e3 demod_rate = 320e3 audio_rate = 32e3 sca_demod_rate = 64e3 audio_decim = int(demod_rate / audio_rate) sca_chanfilt_decim = int(demod_rate / sca_demod_rate) self.u.set_samp_rate(usrp_rate) dev_rate = self.u.get_samp_rate() nfilts = 32 chan_coeffs = optfir.low_pass (nfilts, # gain nfilts*usrp_rate, # sampling rate 100e3, # passband cutoff 140e3, # stopband cutoff 0.1, # passband ripple 60) # stopband attenuation rrate = usrp_rate / dev_rate self.chan_filt = blks2.pfb_arb_resampler_ccf(rrate, chan_coeffs, nfilts) #Create demodulator block for Main FM Channel max_dev = 75e3 fm_demod_gain = demod_rate/(2*math.pi*max_dev) self.fm_demod = gr.quadrature_demod_cf (fm_demod_gain) # Note - deemphasis is not applied to the Main FM Channel as # main audio is not decoded # SCA Devation is 10% of carrier but some references say 20% # if mono with one SCA (6 KHz seems typical) max_sca_dev = 6e3 # Create filter to get SCA channel we want sca_chan_coeffs = gr.firdes.low_pass (1.0, # gain demod_rate, # sampling rate max_sca_dev, # cutoff freq max_sca_dev/3, # trans. band gr.firdes.WIN_HANN) # filter type self.ddc = gr.freq_xlating_fir_filter_fcf(sca_chanfilt_decim, # decim rate sca_chan_coeffs, # taps 0, # freq translation amount (Gets set by the UI) demod_rate) # input sample rate #Create demodulator block for SCA Channel sca_demod_gain = sca_demod_rate/(2*math.pi*max_sca_dev) self.fm_demod_sca = gr.quadrature_demod_cf (sca_demod_gain) # SCA analog audio is bandwidth limited to 5 KHz max_sca_audio_freq = 5.0e3 # SCA analog deephasis is 150 uS (75 uS may be used) sca_tau = 150e-6 # compute FIR filter taps for SCA audio filter audio_coeffs = gr.firdes.low_pass (1.0, # gain sca_demod_rate, # sampling rate max_sca_audio_freq, # cutoff freq max_sca_audio_freq/2.5, # trans. band gr.firdes.WIN_HAMMING) # input: float; output: float self.audio_filter = gr.fir_filter_fff (audio_decim, audio_coeffs) # Create deemphasis block that is applied after SCA demodulation self.deemph = blks2.fm_deemph (audio_rate, sca_tau) self.volume_control = gr.multiply_const_ff(self.vol) # sound card as final sink self.audio_sink = audio.sink (int (audio_rate), options.audio_output, False) # ok_to_block # now wire it all together self.connect (self.u, self.chan_filt, self.fm_demod, self.ddc, self.fm_demod_sca) self.connect (self.fm_demod_sca, self.audio_filter, self.deemph, self.volume_control, self.audio_sink) self._build_gui(vbox, usrp_rate, demod_rate, sca_demod_rate, audio_rate) if options.gain is None: # if no gain was specified, use the mid-point in dB g = self.u.get_gain_range() options.gain = float(g.start()+g.stop())/2 if options.volume is None: g = self.volume_range() options.volume = float(g[0]+g[1])/2 frange = self.u.get_freq_range() if(frange.start() > self.fm_freq_max or frange.stop() < self.fm_freq_min): sys.stderr.write("Radio does not support required frequency range.\n") sys.exit(1) if(options.freq < self.fm_freq_min or options.freq > self.fm_freq_max): sys.stderr.write("Requested frequency is outside of required frequency range.\n") sys.exit(1) # set initial values self.set_gain(options.gain) self.set_vol(options.volume) if not(self.set_freq(options.freq)): self._set_status_msg("Failed to set initial frequency") self.set_sca_freq(67000) # A common SCA Frequency
def __init__(self, ahw="default", freq=150.0e6, ppm=0.0, vol=1.0, ftune=0.0, xftune=0.0, srate=1.0e6, upclo=0.0, devinfo="rtl=0", agc=0, arate=48.0e3, upce=0, mthresh=-10.0, offs=50.e3, flist="", dfifo="multimode_fifo", mbw=2.0e3, deemph=75.0e-6, dmode="NFM1"): grc_wxgui.top_block_gui.__init__(self, title="Multimode Radio Receiver") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Parameters ################################################## self.ahw = ahw self.freq = freq self.ppm = ppm self.vol = vol self.ftune = ftune self.xftune = xftune self.srate = srate self.upclo = upclo self.devinfo = devinfo self.agc = agc self.arate = arate self.upce = upce self.mthresh = mthresh self.offs = offs self.flist = flist self.dfifo = dfifo self.mbw = mbw self.deemph = deemph self.dmode = dmode ################################################## # Variables ################################################## self.sc_list_str = sc_list_str = flist self.zoom = zoom = 1 self.thresh = thresh = mthresh self.scan_rate = scan_rate = 15 self.scan_power = scan_power = 0 self.sc_low = sc_low = 150e6 self.sc_listm = sc_listm = False self.sc_list = sc_list = eval("["+sc_list_str+"]") self.sc_incr = sc_incr = 12.5e3 self.sc_high = sc_high = 300e6 self.sc_ena = sc_ena = False self.samp_rate = samp_rate = int(mh.get_good_rate(devinfo,srate)) self.rf_power = rf_power = 0 self.ifreq = ifreq = freq self.zoomed_lp = zoomed_lp = (samp_rate/2.1)/zoom self.wbfm = wbfm = 200e3 self.rf_d_power = rf_d_power = 0 self.mode = mode = dmode self.logpower = logpower = math.log10(rf_power+1.0e-14)*10.0 self.cur_freq = cur_freq = mh.scan_freq_out(sc_ena,sc_low,sc_high,freq,ifreq,scan_power+1.0e-14,thresh,sc_incr,scan_rate,sc_listm,sc_list) self.bw = bw = mbw self.audio_int_rate = audio_int_rate = 40e3 self.zoom_taps = zoom_taps = firdes.low_pass(1.0,samp_rate,zoomed_lp,zoomed_lp/3,firdes.WIN_HAMMING,6.76) self.xfine = xfine = xftune self.volume = volume = vol self.variable_static_text_1 = variable_static_text_1 = cur_freq self.variable_static_text_0_0 = variable_static_text_0_0 = samp_rate self.variable_static_text_0 = variable_static_text_0 = float(int(math.log10(rf_d_power+1.0e-14)*100.0)/10.0) self.upc_offset = upc_offset = upclo self.upc = upc = upce self.ssbo = ssbo = -bw/2 if mode == "LSB" else 0.0 self.sc_list_len = sc_list_len = len(sc_list) self.rfgain = rfgain = 25 self.record_file = record_file = "recording.wav" self.record = record = False self.offset = offset = offs self.muted = muted = 0.0 if logpower >= thresh else 1 self.main_taps = main_taps = firdes.low_pass(1.0,wbfm,mh.get_mode_deviation(mode,bw)*1.05,mh.get_mode_deviation(mode,bw)/2.0,firdes.WIN_HAMMING,6.76) self.k = k = wbfm/(2*math.pi*mh.get_mode_deviation(mode,bw)) self.iagc = iagc = agc self.freq_update = freq_update = 0 self.fine = fine = ftune self.digi_rate = digi_rate = 50e3 self.aratio = aratio = int(wbfm/audio_int_rate) ################################################## # Blocks ################################################## self.rf_probe = gr.probe_avg_mag_sqrd_c(0, 0.015) self.Main = self.Main = wx.Notebook(self.GetWin(), style=wx.NB_TOP) self.Main.AddPage(grc_wxgui.Panel(self.Main), "Main Controls") self.Main.AddPage(grc_wxgui.Panel(self.Main), "Scan/Upconv Controls") self.Add(self.Main) self._zoom_chooser = forms.drop_down( parent=self.Main.GetPage(0).GetWin(), value=self.zoom, callback=self.set_zoom, label="Spectral Zoom Ratio", choices=[1, 2, 5, 10, 20, 50, 100], labels=[], ) self.Main.GetPage(0).GridAdd(self._zoom_chooser, 1, 4, 1, 1) _xfine_sizer = wx.BoxSizer(wx.VERTICAL) self._xfine_text_box = forms.text_box( parent=self.Main.GetPage(0).GetWin(), sizer=_xfine_sizer, value=self.xfine, callback=self.set_xfine, label="Extra Fine Tuning", converter=forms.float_converter(), proportion=0, ) self._xfine_slider = forms.slider( parent=self.Main.GetPage(0).GetWin(), sizer=_xfine_sizer, value=self.xfine, callback=self.set_xfine, minimum=-1.0e3, maximum=1.0e3, num_steps=200, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Main.GetPage(0).GridAdd(_xfine_sizer, 0, 3, 1, 1) _volume_sizer = wx.BoxSizer(wx.VERTICAL) self._volume_text_box = forms.text_box( parent=self.Main.GetPage(0).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.Main.GetPage(0).GetWin(), sizer=_volume_sizer, value=self.volume, callback=self.set_volume, minimum=1.0, maximum=10.0, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Main.GetPage(0).GridAdd(_volume_sizer, 0, 0, 1, 1) self._upc_offset_text_box = forms.text_box( parent=self.Main.GetPage(1).GetWin(), value=self.upc_offset, callback=self.set_upc_offset, label="Upconv. LO Freq", converter=forms.float_converter(), ) self.Main.GetPage(1).GridAdd(self._upc_offset_text_box, 3, 2, 1, 2) self._upc_check_box = forms.check_box( parent=self.Main.GetPage(1).GetWin(), value=self.upc, callback=self.set_upc, label="Ext. Upconv.", true=1, false=0, ) self.Main.GetPage(1).GridAdd(self._upc_check_box, 3, 0, 1, 1) _rfgain_sizer = wx.BoxSizer(wx.VERTICAL) self._rfgain_text_box = forms.text_box( parent=self.Main.GetPage(0).GetWin(), sizer=_rfgain_sizer, value=self.rfgain, callback=self.set_rfgain, label="RF Gain", converter=forms.float_converter(), proportion=0, ) self._rfgain_slider = forms.slider( parent=self.Main.GetPage(0).GetWin(), sizer=_rfgain_sizer, value=self.rfgain, callback=self.set_rfgain, minimum=0, maximum=50, num_steps=200, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Main.GetPage(0).GridAdd(_rfgain_sizer, 2, 1, 1, 1) self._record_file_text_box = forms.text_box( parent=self.Main.GetPage(0).GetWin(), value=self.record_file, callback=self.set_record_file, label="Recording Filename", converter=forms.str_converter(), ) self.Main.GetPage(0).GridAdd(self._record_file_text_box, 2, 3, 1, 3) self._record_check_box = forms.check_box( parent=self.Main.GetPage(0).GetWin(), value=self.record, callback=self.set_record, label="Record", true=True, false=False, ) self.Main.GetPage(0).GridAdd(self._record_check_box, 2, 2, 1, 1) _offset_sizer = wx.BoxSizer(wx.VERTICAL) self._offset_text_box = forms.text_box( parent=self.Main.GetPage(0).GetWin(), sizer=_offset_sizer, value=self.offset, callback=self.set_offset, label="LO Offset", converter=forms.float_converter(), proportion=0, ) self._offset_slider = forms.slider( parent=self.Main.GetPage(0).GetWin(), sizer=_offset_sizer, value=self.offset, callback=self.set_offset, minimum=25e3, maximum=500e3, num_steps=200, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Main.GetPage(0).GridAdd(_offset_sizer, 1, 3, 1, 1) self._mode_chooser = forms.drop_down( parent=self.Main.GetPage(0).GetWin(), value=self.mode, callback=self.set_mode, label="Mode", choices=mh.get_modes_values(), labels=mh.get_modes_names(), ) self.Main.GetPage(0).GridAdd(self._mode_chooser, 0, 4, 1, 1) self._iagc_check_box = forms.check_box( parent=self.Main.GetPage(0).GetWin(), value=self.iagc, callback=self.set_iagc, label="AGC", true=1, false=0, ) self.Main.GetPage(0).GridAdd(self._iagc_check_box, 2, 0, 1, 1) def _freq_update_probe(): while True: val = self.rf_probe.level() try: self.set_freq_update(val) except AttributeError, e: pass time.sleep(1.0/(1.0/(2.5))) _freq_update_thread = threading.Thread(target=_freq_update_probe) _freq_update_thread.daemon = True _freq_update_thread.start() _fine_sizer = wx.BoxSizer(wx.VERTICAL) self._fine_text_box = forms.text_box( parent=self.Main.GetPage(0).GetWin(), sizer=_fine_sizer, value=self.fine, callback=self.set_fine, label="Fine Tuning", converter=forms.float_converter(), proportion=0, ) self._fine_slider = forms.slider( parent=self.Main.GetPage(0).GetWin(), sizer=_fine_sizer, value=self.fine, callback=self.set_fine, minimum=-35e3, maximum=35e3, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Main.GetPage(0).GridAdd(_fine_sizer, 0, 2, 1, 1) self.display_probe = gr.probe_avg_mag_sqrd_c(0, 0.002) _bw_sizer = wx.BoxSizer(wx.VERTICAL) self._bw_text_box = forms.text_box( parent=self.Main.GetPage(0).GetWin(), sizer=_bw_sizer, value=self.bw, callback=self.set_bw, label="AM/SSB Bandwidth", converter=forms.float_converter(), proportion=0, ) self._bw_slider = forms.slider( parent=self.Main.GetPage(0).GetWin(), sizer=_bw_sizer, value=self.bw, callback=self.set_bw, minimum=1.0e3, maximum=audio_int_rate/2, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Main.GetPage(0).GridAdd(_bw_sizer, 1, 2, 1, 1) self.wxgui_waterfallsink2_0 = waterfallsink2.waterfall_sink_c( self.Main.GetPage(0).GetWin(), baseband_freq=mh.get_last_returned(freq_update), dynamic_range=40, ref_level=0, ref_scale=2.0, sample_rate=samp_rate/zoom, fft_size=1024, fft_rate=4, average=True, avg_alpha=None, title="Spectrogram", win=window.hamming, ) self.Main.GetPage(0).Add(self.wxgui_waterfallsink2_0.win) def wxgui_waterfallsink2_0_callback(x, y): self.set_freq(x) self.wxgui_waterfallsink2_0.set_callback(wxgui_waterfallsink2_0_callback) self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.Main.GetPage(0).GetWin(), baseband_freq=mh.get_last_returned(freq_update), y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=samp_rate/zoom, fft_size=1024, fft_rate=4, average=True, avg_alpha=0.1, title="Panorama", peak_hold=False, win=window.hamming, ) self.Main.GetPage(0).Add(self.wxgui_fftsink2_0.win) def wxgui_fftsink2_0_callback(x, y): self.set_freq(x) self.wxgui_fftsink2_0.set_callback(wxgui_fftsink2_0_callback) self._variable_static_text_1_static_text = forms.static_text( parent=self.Main.GetPage(1).GetWin(), value=self.variable_static_text_1, callback=self.set_variable_static_text_1, label="Current Scan Freq", converter=forms.float_converter(), ) self.Main.GetPage(1).GridAdd(self._variable_static_text_1_static_text, 0, 5, 1, 2) self._variable_static_text_0_0_static_text = forms.static_text( parent=self.Main.GetPage(0).GetWin(), value=self.variable_static_text_0_0, callback=self.set_variable_static_text_0_0, label="Actual srate", converter=forms.float_converter(), ) self.Main.GetPage(0).GridAdd(self._variable_static_text_0_0_static_text, 1, 5, 1, 1) self._variable_static_text_0_static_text = forms.static_text( parent=self.Main.GetPage(0).GetWin(), value=self.variable_static_text_0, callback=self.set_variable_static_text_0, label="RF Level", converter=forms.float_converter(), ) self.Main.GetPage(0).GridAdd(self._variable_static_text_0_static_text, 1, 0, 1, 1) _thresh_sizer = wx.BoxSizer(wx.VERTICAL) self._thresh_text_box = forms.text_box( parent=self.Main.GetPage(0).GetWin(), sizer=_thresh_sizer, value=self.thresh, callback=self.set_thresh, label="Mute Threshold", converter=forms.float_converter(), proportion=0, ) self._thresh_slider = forms.slider( parent=self.Main.GetPage(0).GetWin(), sizer=_thresh_sizer, value=self.thresh, callback=self.set_thresh, minimum=-50, maximum=10, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Main.GetPage(0).GridAdd(_thresh_sizer, 1, 1, 1, 1) def _scan_power_probe(): while True: val = self.rf_probe.level() try: self.set_scan_power(val) except AttributeError, e: pass time.sleep(1.0/(scan_rate)) _scan_power_thread = threading.Thread(target=_scan_power_probe) _scan_power_thread.daemon = True _scan_power_thread.start() self._sc_low_text_box = forms.text_box( parent=self.Main.GetPage(1).GetWin(), value=self.sc_low, callback=self.set_sc_low, label="Scan Low", converter=forms.float_converter(), ) self.Main.GetPage(1).GridAdd(self._sc_low_text_box, 0, 1, 1, 1) self._sc_listm_check_box = forms.check_box( parent=self.Main.GetPage(1).GetWin(), value=self.sc_listm, callback=self.set_sc_listm, label="Scan List Mode", true=True, false=False, ) self.Main.GetPage(1).GridAdd(self._sc_listm_check_box, 2, 0, 1, 1) self._sc_list_str_text_box = forms.text_box( parent=self.Main.GetPage(1).GetWin(), value=self.sc_list_str, callback=self.set_sc_list_str, label="Scan List", converter=forms.str_converter(), ) self.Main.GetPage(1).GridAdd(self._sc_list_str_text_box, 2, 1, 1, 5) self._sc_incr_chooser = forms.drop_down( parent=self.Main.GetPage(1).GetWin(), value=self.sc_incr, callback=self.set_sc_incr, label="Scan Increment (Hz)", choices=[5.0e3,6.25e3,10.0e3,12.5e3,15e3,25e3], labels=[], ) self.Main.GetPage(1).GridAdd(self._sc_incr_chooser, 0, 0, 1, 1) self._sc_high_text_box = forms.text_box( parent=self.Main.GetPage(1).GetWin(), value=self.sc_high, callback=self.set_sc_high, label="Scan High", converter=forms.float_converter(), ) self.Main.GetPage(1).GridAdd(self._sc_high_text_box, 0, 2, 1, 1) self._sc_ena_check_box = forms.check_box( parent=self.Main.GetPage(1).GetWin(), value=self.sc_ena, callback=self.set_sc_ena, label="Scan Enable", true=True, false=False, ) self.Main.GetPage(1).GridAdd(self._sc_ena_check_box, 0, 3, 1, 1) def _rf_power_probe(): while True: val = self.rf_probe.level() try: self.set_rf_power(val) except AttributeError, e: pass time.sleep(1.0/(10)) _rf_power_thread = threading.Thread(target=_rf_power_probe) _rf_power_thread.daemon = True _rf_power_thread.start() def _rf_d_power_probe(): while True: val = self.display_probe.level() try: self.set_rf_d_power(val) except AttributeError, e: pass time.sleep(1.0/(5)) _rf_d_power_thread = threading.Thread(target=_rf_d_power_probe) _rf_d_power_thread.daemon = True _rf_d_power_thread.start() self.osmosdr_source_c_0 = osmosdr.source_c( args="nchan=" + str(1) + " " + devinfo ) self.osmosdr_source_c_0.set_sample_rate(samp_rate) self.osmosdr_source_c_0.set_center_freq(cur_freq+offset+(upc_offset*float(upc)), 0) self.osmosdr_source_c_0.set_freq_corr(ppm, 0) self.osmosdr_source_c_0.set_gain_mode(iagc, 0) self.osmosdr_source_c_0.set_gain(25 if iagc == 1 else rfgain, 0) self.osmosdr_source_c_0.set_if_gain(20, 0) self._ifreq_text_box = forms.text_box( parent=self.Main.GetPage(0).GetWin(), value=self.ifreq, callback=self.set_ifreq, label="Frequency", converter=forms.float_converter(), ) self.Main.GetPage(0).GridAdd(self._ifreq_text_box, 0, 1, 1, 1) self.gr_wavfile_sink_0 = gr.wavfile_sink("/dev/null" if record == False else record_file, 1, int(audio_int_rate), 8) self.gr_quadrature_demod_cf_0 = gr.quadrature_demod_cf(k) self.gr_multiply_const_vxx_2 = gr.multiply_const_vff((1.0 if mh.get_mode_type(mode) == "FM" else 0.0, )) self.gr_multiply_const_vxx_1 = gr.multiply_const_vff((0.0 if muted else volume/4.5, )) self.gr_multiply_const_vxx_0_0_0 = gr.multiply_const_vff((0.85 if mh.get_mode_type(mode) == "AM" else 0.0, )) self.gr_multiply_const_vxx_0_0 = gr.multiply_const_vff((0.85 if mh.get_mode_type(mode) == "SSB" else 0.0, )) self.gr_multiply_const_vxx_0 = gr.multiply_const_vcc(((1.0/math.sqrt(mh.get_mode_deviation(mode,bw))*250), )) self.gr_keep_one_in_n_1 = gr.keep_one_in_n(gr.sizeof_gr_complex*1, aratio) self.gr_keep_one_in_n_0_0 = gr.keep_one_in_n(gr.sizeof_gr_complex*1, zoom) self.gr_keep_one_in_n_0 = gr.keep_one_in_n(gr.sizeof_gr_complex*1, int(wbfm/digi_rate)) self.gr_freq_xlating_fir_filter_xxx_0_1 = gr.freq_xlating_fir_filter_ccc(1, (1.0, ), (offset+fine+xfine)/(samp_rate/1.0e6), samp_rate) self.gr_fractional_interpolator_xx_0 = gr.fractional_interpolator_ff(0, audio_int_rate/arate) self.gr_file_sink_0 = gr.file_sink(gr.sizeof_gr_complex*1, "/dev/null" if mh.get_mode_type(mode) != "DIG" else dfifo) self.gr_file_sink_0.set_unbuffered(True) self.gr_fft_filter_xxx_3 = gr.fft_filter_ccc(1, (zoom_taps), 1) self.gr_fft_filter_xxx_2_0 = gr.fft_filter_fff(5, (firdes.low_pass(1.0,wbfm,14.5e3,8.5e3,firdes.WIN_HAMMING,6.76)), 1) self.gr_fft_filter_xxx_2 = gr.fft_filter_ccc(1, (main_taps), 1) self.gr_fft_filter_xxx_0 = gr.fft_filter_ccc(int(samp_rate/wbfm), (firdes.low_pass(1.0,samp_rate,98.5e3,66e3,firdes.WIN_HAMMING,6.76)), 1) self.gr_feedforward_agc_cc_0 = gr.feedforward_agc_cc(1024, 0.75) self.gr_complex_to_real_0 = gr.complex_to_real(1) self.gr_complex_to_mag_squared_0 = gr.complex_to_mag_squared(1) self.gr_add_xx_0 = gr.add_vff(1) self.blks2_fm_deemph_0 = blks2.fm_deemph(fs=audio_int_rate, tau=deemph) self.audio_sink_0 = audio.sink(int(arate), ahw, True) ################################################## # Connections ################################################## self.connect((self.gr_multiply_const_vxx_0_0, 0), (self.gr_add_xx_0, 1)) self.connect((self.gr_fractional_interpolator_xx_0, 0), (self.gr_multiply_const_vxx_1, 0)) self.connect((self.gr_multiply_const_vxx_1, 0), (self.audio_sink_0, 0)) self.connect((self.gr_multiply_const_vxx_1, 0), (self.audio_sink_0, 1)) self.connect((self.gr_feedforward_agc_cc_0, 0), (self.gr_complex_to_mag_squared_0, 0)) self.connect((self.osmosdr_source_c_0, 0), (self.gr_freq_xlating_fir_filter_xxx_0_1, 0)) self.connect((self.gr_multiply_const_vxx_0_0_0, 0), (self.gr_add_xx_0, 2)) self.connect((self.gr_feedforward_agc_cc_0, 0), (self.gr_complex_to_real_0, 0)) self.connect((self.gr_complex_to_real_0, 0), (self.gr_multiply_const_vxx_0_0, 0)) self.connect((self.gr_multiply_const_vxx_2, 0), (self.gr_add_xx_0, 0)) self.connect((self.gr_complex_to_mag_squared_0, 0), (self.gr_multiply_const_vxx_0_0_0, 0)) self.connect((self.gr_multiply_const_vxx_0, 0), (self.display_probe, 0)) self.connect((self.gr_multiply_const_vxx_0, 0), (self.rf_probe, 0)) self.connect((self.gr_add_xx_0, 0), (self.gr_fractional_interpolator_xx_0, 0)) self.connect((self.gr_add_xx_0, 0), (self.gr_wavfile_sink_0, 0)) self.connect((self.gr_freq_xlating_fir_filter_xxx_0_1, 0), (self.gr_fft_filter_xxx_0, 0)) self.connect((self.gr_keep_one_in_n_0, 0), (self.gr_file_sink_0, 0)) self.connect((self.gr_freq_xlating_fir_filter_xxx_0_1, 0), (self.gr_fft_filter_xxx_3, 0)) self.connect((self.gr_fft_filter_xxx_3, 0), (self.gr_keep_one_in_n_0_0, 0)) self.connect((self.gr_keep_one_in_n_0_0, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.gr_keep_one_in_n_0_0, 0), (self.wxgui_waterfallsink2_0, 0)) self.connect((self.blks2_fm_deemph_0, 0), (self.gr_multiply_const_vxx_2, 0)) self.connect((self.gr_quadrature_demod_cf_0, 0), (self.gr_fft_filter_xxx_2_0, 0)) self.connect((self.gr_fft_filter_xxx_2, 0), (self.gr_keep_one_in_n_0, 0)) self.connect((self.gr_fft_filter_xxx_2, 0), (self.gr_multiply_const_vxx_0, 0)) self.connect((self.gr_fft_filter_xxx_0, 0), (self.gr_fft_filter_xxx_2, 0)) self.connect((self.gr_keep_one_in_n_1, 0), (self.gr_feedforward_agc_cc_0, 0)) self.connect((self.gr_fft_filter_xxx_2, 0), (self.gr_keep_one_in_n_1, 0)) self.connect((self.gr_fft_filter_xxx_2, 0), (self.gr_quadrature_demod_cf_0, 0)) self.connect((self.gr_fft_filter_xxx_2_0, 0), (self.blks2_fm_deemph_0, 0))
def __init__(self): gr.top_block.__init__(self, "FM radio to test FCDPROplus") Qt.QWidget.__init__(self) self.setWindowTitle("FM radio to test FCDPROplus") self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) 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) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 192000 self.Volume = Volume = 1 self.RxFrequency = RxFrequency = 94300 self.PPM = PPM = 0 self.Mixergain = Mixergain = 1 self.Lna = Lna = 1 self.Ifgain = Ifgain = 0 ################################################## # Blocks ################################################## self._Volume_layout = Qt.QHBoxLayout() self._Volume_layout.addWidget(Qt.QLabel("Volume"+": ")) self._Volume_counter = Qwt.QwtCounter() self._Volume_counter.setRange(1, 50, 1) self._Volume_counter.setNumButtons(2) self._Volume_counter.setMinimumWidth(45) self._Volume_counter.setValue(self.Volume) self._Volume_layout.addWidget(self._Volume_counter) self._Volume_counter.valueChanged.connect(self.set_Volume) self.top_grid_layout.addLayout(self._Volume_layout, 0,5,1,1) self._RxFrequency_layout = Qt.QHBoxLayout() self._RxFrequency_layout.addWidget(Qt.QLabel("Set Frequency "+": ")) self._RxFrequency_counter = Qwt.QwtCounter() self._RxFrequency_counter.setRange(3000, 100000, 1) self._RxFrequency_counter.setNumButtons(2) self._RxFrequency_counter.setMinimumWidth(200) self._RxFrequency_counter.setValue(self.RxFrequency) self._RxFrequency_layout.addWidget(self._RxFrequency_counter) self._RxFrequency_counter.valueChanged.connect(self.set_RxFrequency) self.top_grid_layout.addLayout(self._RxFrequency_layout, 0,0,1,1) self._PPM_layout = Qt.QHBoxLayout() self._PPM_layout.addWidget(Qt.QLabel("set PPM"+": ")) self._PPM_counter = Qwt.QwtCounter() self._PPM_counter.setRange(-100, 100, 1) self._PPM_counter.setNumButtons(2) self._PPM_counter.setMinimumWidth(40) self._PPM_counter.setValue(self.PPM) self._PPM_layout.addWidget(self._PPM_counter) self._PPM_counter.valueChanged.connect(self.set_PPM) self.top_grid_layout.addLayout(self._PPM_layout, 0,6,1,1) self._Mixergain_options = (0, 1, ) self._Mixergain_labels = ("Off", "On", ) self._Mixergain_tool_bar = Qt.QToolBar(self) self._Mixergain_tool_bar.addWidget(Qt.QLabel("Mixergain"+": ")) self._Mixergain_combo_box = Qt.QComboBox() self._Mixergain_tool_bar.addWidget(self._Mixergain_combo_box) for label in self._Mixergain_labels: self._Mixergain_combo_box.addItem(label) self._Mixergain_callback = lambda i: self._Mixergain_combo_box.setCurrentIndex(self._Mixergain_options.index(i)) self._Mixergain_callback(self.Mixergain) self._Mixergain_combo_box.currentIndexChanged.connect( lambda i: self.set_Mixergain(self._Mixergain_options[i])) self.top_grid_layout.addWidget(self._Mixergain_tool_bar, 0,2,1,1) self._Lna_options = (0, 1, ) self._Lna_labels = ("Off", "On", ) self._Lna_tool_bar = Qt.QToolBar(self) self._Lna_tool_bar.addWidget(Qt.QLabel("Lna"+": ")) self._Lna_combo_box = Qt.QComboBox() self._Lna_tool_bar.addWidget(self._Lna_combo_box) for label in self._Lna_labels: self._Lna_combo_box.addItem(label) self._Lna_callback = lambda i: self._Lna_combo_box.setCurrentIndex(self._Lna_options.index(i)) self._Lna_callback(self.Lna) self._Lna_combo_box.currentIndexChanged.connect( lambda i: self.set_Lna(self._Lna_options[i])) self.top_grid_layout.addWidget(self._Lna_tool_bar, 0,1,1,1) self._Ifgain_layout = Qt.QHBoxLayout() self._Ifgain_layout.addWidget(Qt.QLabel("Ifgain"+": ")) self._Ifgain_counter = Qwt.QwtCounter() self._Ifgain_counter.setRange(0, 59, 1) self._Ifgain_counter.setNumButtons(2) self._Ifgain_counter.setMinimumWidth(45) self._Ifgain_counter.setValue(self.Ifgain) self._Ifgain_layout.addWidget(self._Ifgain_counter) self._Ifgain_counter.valueChanged.connect(self.set_Ifgain) self.top_grid_layout.addLayout(self._Ifgain_layout, 0,3,1,1) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 1024, #size samp_rate/4, #bw "QT GUI Plot", #name 1 #number of inputs ) 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, 1,4,1,3) self.qtgui_sink_x_0 = qtgui.sink_c( 1024, #fftsize firdes.WIN_BLACKMAN_hARRIS, #wintype RxFrequency*1000, #fc samp_rate, #bw "QT GUI Plot", #name True, #plotfreq True, #plotwaterfall False, #plottime False, #plotconst ) self.qtgui_sink_x_0.set_update_time(1.0 / 10) self._qtgui_sink_x_0_win = sip.wrapinstance(self.qtgui_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_sink_x_0_win, 1,0,1,4) self.low_pass_filter_1 = gr.fir_filter_fff(4, firdes.low_pass( 1, samp_rate, 16000, 300, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_0 = gr.fir_filter_ccf(1, firdes.low_pass( 5, samp_rate, 40000, 300, firdes.WIN_HAMMING, 6.76)) self.gr_quadrature_demod_cf_0 = gr.quadrature_demod_cf(1) self.gr_multiply_const_vxx_0 = gr.multiply_const_vff((Volume, )) self.fcdproplus_fcdproplus_0 = fcdproplus.fcdproplus("",1000) self.fcdproplus_fcdproplus_0.set_lna(Lna) self.fcdproplus_fcdproplus_0.set_mixer_gain(Mixergain) self.fcdproplus_fcdproplus_0.set_if_gain(int(Ifgain)) self.fcdproplus_fcdproplus_0.set_freq_corr(int( PPM)) self.fcdproplus_fcdproplus_0.set_freq(RxFrequency) self.blks2_fm_deemph_0 = blks2.fm_deemph(fs=samp_rate, tau=25e-6) self.audio_sink_0 = audio.sink(48000, "default", True) ################################################## # Connections ################################################## self.connect((self.fcdproplus_fcdproplus_0, 0), (self.qtgui_sink_x_0, 0)) self.connect((self.fcdproplus_fcdproplus_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.gr_multiply_const_vxx_0, 0), (self.audio_sink_0, 0)) self.connect((self.gr_multiply_const_vxx_0, 0), (self.audio_sink_0, 1)) self.connect((self.gr_multiply_const_vxx_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.gr_quadrature_demod_cf_0, 0)) self.connect((self.low_pass_filter_1, 0), (self.gr_multiply_const_vxx_0, 0)) self.connect((self.gr_quadrature_demod_cf_0, 0), (self.blks2_fm_deemph_0, 0)) self.connect((self.blks2_fm_deemph_0, 0), (self.low_pass_filter_1, 0))
def __init__(self, frame, panel, vbox, argv): stdgui2.std_top_block.__init__(self, frame, panel, vbox, argv) parser = OptionParser(option_class=eng_option) parser.add_option("-a", "--args", type="string", default="", help="UHD device address args [default=%default]") parser.add_option("", "--spec", type="string", default=None, help="Subdevice of UHD device where appropriate") parser.add_option("-A", "--antenna", type="string", default=None, help="select Rx Antenna where appropriate") parser.add_option("-f", "--freq", type="eng_float", default=100.1e6, help="set frequency to FREQ", metavar="FREQ") parser.add_option("-g", "--gain", type="eng_float", default=40, help="set gain in dB (default is midpoint)") parser.add_option("-V", "--volume", type="eng_float", default=None, help="set volume (default is midpoint)") parser.add_option( "-O", "--audio-output", type="string", default="", help="pcm device name. E.g., hw:0,0 or surround51 or /dev/dsp") parser.add_option("", "--freq-min", type="eng_float", default=87.9e6, help="Set a minimum frequency [default=%default]") parser.add_option("", "--freq-max", type="eng_float", default=108.1e6, help="Set a maximum frequency [default=%default]") (options, args) = parser.parse_args() if len(args) != 0: parser.print_help() sys.exit(1) self.frame = frame self.panel = panel self.vol = 0 self.state = "FREQ" self.freq = 0 self.fm_freq_min = options.freq_min self.fm_freq_max = options.freq_max # build graph self.u = uhd.usrp_source(device_addr=options.args, stream_args=uhd.stream_args('fc32')) # Set the subdevice spec if (options.spec): self.u.set_subdev_spec(options.spec, 0) # Set the antenna if (options.antenna): self.u.set_antenna(options.antenna, 0) usrp_rate = 320e3 demod_rate = 320e3 audio_rate = 32e3 sca_demod_rate = 64e3 audio_decim = int(demod_rate / audio_rate) sca_chanfilt_decim = int(demod_rate / sca_demod_rate) self.u.set_samp_rate(usrp_rate) dev_rate = self.u.get_samp_rate() nfilts = 32 chan_coeffs = optfir.low_pass( nfilts, # gain nfilts * usrp_rate, # sampling rate 100e3, # passband cutoff 140e3, # stopband cutoff 0.1, # passband ripple 60) # stopband attenuation rrate = usrp_rate / dev_rate self.chan_filt = blks2.pfb_arb_resampler_ccf(rrate, chan_coeffs, nfilts) #Create demodulator block for Main FM Channel max_dev = 75e3 fm_demod_gain = demod_rate / (2 * math.pi * max_dev) self.fm_demod = gr.quadrature_demod_cf(fm_demod_gain) # Note - deemphasis is not applied to the Main FM Channel as # main audio is not decoded # SCA Devation is 10% of carrier but some references say 20% # if mono with one SCA (6 KHz seems typical) max_sca_dev = 6e3 # Create filter to get SCA channel we want sca_chan_coeffs = gr.firdes.low_pass( 1.0, # gain demod_rate, # sampling rate max_sca_dev, # cutoff freq max_sca_dev / 3, # trans. band gr.firdes.WIN_HANN) # filter type self.ddc = gr.freq_xlating_fir_filter_fcf( sca_chanfilt_decim, # decim rate sca_chan_coeffs, # taps 0, # freq translation amount (Gets set by the UI) demod_rate) # input sample rate #Create demodulator block for SCA Channel sca_demod_gain = sca_demod_rate / (2 * math.pi * max_sca_dev) self.fm_demod_sca = gr.quadrature_demod_cf(sca_demod_gain) # SCA analog audio is bandwidth limited to 5 KHz max_sca_audio_freq = 5.0e3 # SCA analog deephasis is 150 uS (75 uS may be used) sca_tau = 150e-6 # compute FIR filter taps for SCA audio filter audio_coeffs = gr.firdes.low_pass( 1.0, # gain sca_demod_rate, # sampling rate max_sca_audio_freq, # cutoff freq max_sca_audio_freq / 2.5, # trans. band gr.firdes.WIN_HAMMING) # input: float; output: float self.audio_filter = gr.fir_filter_fff(audio_decim, audio_coeffs) # Create deemphasis block that is applied after SCA demodulation self.deemph = blks2.fm_deemph(audio_rate, sca_tau) self.volume_control = gr.multiply_const_ff(self.vol) # sound card as final sink self.audio_sink = audio.sink(int(audio_rate), options.audio_output, False) # ok_to_block # now wire it all together self.connect(self.u, self.chan_filt, self.fm_demod, self.ddc, self.fm_demod_sca) self.connect(self.fm_demod_sca, self.audio_filter, self.deemph, self.volume_control, self.audio_sink) self._build_gui(vbox, usrp_rate, demod_rate, sca_demod_rate, audio_rate) if options.gain is None: # if no gain was specified, use the mid-point in dB g = self.u.get_gain_range() options.gain = float(g.start() + g.stop()) / 2 if options.volume is None: g = self.volume_range() options.volume = float(g[0] + g[1]) / 2 frange = self.u.get_freq_range() if (frange.start() > self.fm_freq_max or frange.stop() < self.fm_freq_min): sys.stderr.write( "Radio does not support required frequency range.\n") sys.exit(1) if (options.freq < self.fm_freq_min or options.freq > self.fm_freq_max): sys.stderr.write( "Requested frequency is outside of required frequency range.\n" ) sys.exit(1) # set initial values self.set_gain(options.gain) self.set_vol(options.volume) if not (self.set_freq(options.freq)): self._set_status_msg("Failed to set initial frequency") self.set_sca_freq(67000) # A common SCA Frequency
def __init__(self): grc_wxgui.top_block_gui.__init__( self, title="Stereo FM receiver and RDS Decoder") ################################################## # Variables ################################################## self.xlate_decim = xlate_decim = 4 self.samp_rate = samp_rate = 1000000 self.freq_offset = freq_offset = 250e3 self.freq = freq = 88.5e6 self.baseband_rate = baseband_rate = samp_rate / xlate_decim self.audio_decim = audio_decim = 4 self.xlate_bandwidth = xlate_bandwidth = 250e3 self.volume = volume = 0 self.loop_bw = loop_bw = 16e3 * 0 + 18e3 * 1 self.gain = gain = 10 self.freq_tune = freq_tune = freq - freq_offset self.audio_rate = audio_rate = 48000 self.audio_decim_rate = audio_decim_rate = baseband_rate / audio_decim self.antenna = antenna = 'TX/RX' ################################################## # Message Queues ################################################## gr_rds_data_decoder_0_msgq_out = gr_rds_panel_0_msgq_in = gr.msg_queue( 2) ################################################## # 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.Add(_volume_sizer) 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), "L+R") self.nb.AddPage(grc_wxgui.Panel(self.nb), "Pilot") self.nb.AddPage(grc_wxgui.Panel(self.nb), "DSBSC") self.nb.AddPage(grc_wxgui.Panel(self.nb), "RDS Raw") self.nb.AddPage(grc_wxgui.Panel(self.nb), "L-R") self.nb.AddPage(grc_wxgui.Panel(self.nb), "RDS") self.Add(self.nb) _loop_bw_sizer = wx.BoxSizer(wx.VERTICAL) self._loop_bw_text_box = forms.text_box( parent=self.GetWin(), sizer=_loop_bw_sizer, value=self.loop_bw, callback=self.set_loop_bw, label="Loop BW", converter=forms.float_converter(), proportion=0, ) self._loop_bw_slider = forms.slider( parent=self.GetWin(), sizer=_loop_bw_sizer, value=self.loop_bw, callback=self.set_loop_bw, minimum=0, maximum=baseband_rate, num_steps=1000, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_loop_bw_sizer) _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="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=50, num_steps=50, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_gain_sizer) self._freq_offset_text_box = forms.text_box( parent=self.GetWin(), value=self.freq_offset, callback=self.set_freq_offset, label="Freq Offset", converter=forms.float_converter(), ) self.Add(self._freq_offset_text_box) _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=87.5e6, maximum=108e6, num_steps=205, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_freq_sizer) self._antenna_chooser = forms.drop_down( parent=self.GetWin(), value=self.antenna, callback=self.set_antenna, label="Antenna", choices=['TX/RX', 'RX2'], labels=[], ) self.Add(self._antenna_chooser) self.wxgui_scopesink2_0 = scopesink2.scope_sink_f( self.nb.GetPage(3).GetWin(), title="Pilot", sample_rate=baseband_rate, v_scale=0, v_offset=0, t_scale=0, ac_couple=False, xy_mode=False, num_inputs=1, trig_mode=gr.gr_TRIG_MODE_AUTO, y_axis_label="Counts", ) self.nb.GetPage(3).Add(self.wxgui_scopesink2_0.win) self.wxgui_fftsink2_0_0_0_1_0_1 = fftsink2.fft_sink_f( self.nb.GetPage(7).GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=-50, ref_scale=2.0, sample_rate=baseband_rate, fft_size=1024, fft_rate=15, average=False, avg_alpha=None, title="RDS", peak_hold=False, ) self.nb.GetPage(7).Add(self.wxgui_fftsink2_0_0_0_1_0_1.win) self.wxgui_fftsink2_0_0_0_1_0_0 = fftsink2.fft_sink_f( self.nb.GetPage(6).GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=-50, ref_scale=2.0, sample_rate=baseband_rate, fft_size=1024, fft_rate=15, average=False, avg_alpha=None, title="L-R", peak_hold=False, ) self.nb.GetPage(6).Add(self.wxgui_fftsink2_0_0_0_1_0_0.win) self.wxgui_fftsink2_0_0_0_1_0 = fftsink2.fft_sink_f( self.nb.GetPage(5).GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=baseband_rate, 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.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=baseband_rate, fft_size=1024, fft_rate=15, average=False, avg_alpha=None, title="DSBSC Sub-carrier", 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(2).GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=audio_decim_rate, fft_size=1024, fft_rate=15, average=False, avg_alpha=None, title="L+R", peak_hold=False, ) self.nb.GetPage(2).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=baseband_rate, 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=baseband_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.uhd_usrp_source_0 = uhd.usrp_source( device_addr="", stream_args=uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_source_0.set_samp_rate(samp_rate) self.uhd_usrp_source_0.set_center_freq(freq_tune, 0) self.uhd_usrp_source_0.set_gain(gain, 0) self.uhd_usrp_source_0.set_antenna(antenna, 0) self.gr_rds_panel_0 = rds.rdsPanel(gr_rds_panel_0_msgq_in, freq, self.GetWin()) self.Add(self.gr_rds_panel_0) self.gr_rds_freq_divider_0 = rds.freq_divider(16) self.gr_rds_data_decoder_0 = rds.data_decoder( gr_rds_data_decoder_0_msgq_out) self.gr_rds_bpsk_demod_0 = rds.bpsk_demod(audio_decim_rate) self.gr_pll_freqdet_cf_0 = gr.pll_freqdet_cf( 1.0 * 0 + (loop_bw * 2 * math.pi / baseband_rate), +(2.0 * math.pi * 90e3 / baseband_rate), -(2.0 * math.pi * 90e3 / baseband_rate)) self.gr_multiply_const_vxx_0_0 = gr.multiply_const_vff( (10**(1. * volume / 10), )) self.gr_multiply_const_vxx_0 = gr.multiply_const_vff( (10**(1. * volume / 10), )) self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc( xlate_decim, (firdes.low_pass(1, samp_rate, xlate_bandwidth / 2, 1000)), freq_offset, samp_rate) self.fir_filter_xxx_7 = filter.fir_filter_fff( audio_decim, (firdes.low_pass(1, baseband_rate, 1.2e3, 1.5e3, firdes.WIN_HAMMING))) self.fir_filter_xxx_6 = filter.fir_filter_fff( audio_decim, (firdes.low_pass(1, baseband_rate, 1.5e3, 2e3, firdes.WIN_HAMMING))) self.fir_filter_xxx_5 = filter.fir_filter_fff( audio_decim, (firdes.low_pass(1.0, baseband_rate, 15e3, 1e3, firdes.WIN_HAMMING))) self.fir_filter_xxx_4 = filter.fir_filter_fff( 1, (firdes.band_pass(1.0, baseband_rate, 57e3 - 3e3, 57e3 + 3e3, 3e3, firdes.WIN_HAMMING))) self.fir_filter_xxx_3 = filter.fir_filter_fff( 1, (firdes.band_pass(1.0, baseband_rate, 38e3 - 15e3 / 2, 38e3 + 15e3 / 2, 1e3, firdes.WIN_HAMMING))) self.fir_filter_xxx_2 = filter.fir_filter_fff( 1, (firdes.band_pass(1.0, baseband_rate, 19e3 - 500, 19e3 + 500, 1e3, firdes.WIN_HAMMING))) self.fir_filter_xxx_1 = filter.fir_filter_fff( audio_decim, (firdes.low_pass(1.0, baseband_rate, 15e3, 1e3, firdes.WIN_HAMMING))) self.fir_filter_xxx_0 = filter.fir_filter_ccc(1, (firdes.low_pass( 1.0, baseband_rate, 80e3, 35e3, firdes.WIN_HAMMING))) 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_0 = blocks.multiply_vff(1) self.blocks_multiply_xx_0 = blocks.multiply_vff(1) self.blocks_add_xx_0 = blocks.add_vff(1) self.blks2_rational_resampler_xxx_0_0 = blks2.rational_resampler_fff( interpolation=audio_rate, decimation=audio_decim_rate, taps=None, fractional_bw=None, ) self.blks2_rational_resampler_xxx_0 = blks2.rational_resampler_fff( interpolation=audio_rate, decimation=audio_decim_rate, taps=None, fractional_bw=None, ) self.blks2_fm_deemph_0_0_0 = blks2.fm_deemph(fs=baseband_rate, tau=75e-6) self.blks2_fm_deemph_0_0 = blks2.fm_deemph(fs=baseband_rate, tau=75e-6) self.audio_sink_0 = audio.sink(audio_rate, "", True) ################################################## # Connections ################################################## self.connect((self.uhd_usrp_source_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.fir_filter_xxx_0, 0)) self.connect((self.fir_filter_xxx_0, 0), (self.gr_pll_freqdet_cf_0, 0)) self.connect((self.gr_pll_freqdet_cf_0, 0), (self.fir_filter_xxx_1, 0)) self.connect((self.gr_pll_freqdet_cf_0, 0), (self.fir_filter_xxx_2, 0)) self.connect((self.gr_pll_freqdet_cf_0, 0), (self.fir_filter_xxx_4, 0)) self.connect((self.fir_filter_xxx_2, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.fir_filter_xxx_2, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.fir_filter_xxx_2, 0), (self.blocks_multiply_xx_0_0, 0)) self.connect((self.fir_filter_xxx_2, 0), (self.blocks_multiply_xx_0_0, 1)) self.connect((self.fir_filter_xxx_3, 0), (self.blocks_multiply_xx_0, 2)) self.connect((self.fir_filter_xxx_4, 0), (self.blocks_multiply_xx_0_0, 3)) self.connect((self.fir_filter_xxx_2, 0), (self.blocks_multiply_xx_0_0, 2)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.fir_filter_xxx_1, 0), (self.blocks_sub_xx_0, 0)) self.connect((self.fir_filter_xxx_2, 0), (self.gr_rds_freq_divider_0, 0)) self.connect((self.fir_filter_xxx_1, 0), (self.blocks_add_xx_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.fir_filter_xxx_5, 0)) self.connect((self.gr_pll_freqdet_cf_0, 0), (self.fir_filter_xxx_3, 0)) self.connect((self.gr_multiply_const_vxx_0, 0), (self.blks2_rational_resampler_xxx_0, 0)) self.connect((self.blks2_rational_resampler_xxx_0, 0), (self.audio_sink_0, 0)) self.connect((self.blks2_rational_resampler_xxx_0_0, 0), (self.audio_sink_0, 1)) self.connect((self.gr_multiply_const_vxx_0_0, 0), (self.blks2_rational_resampler_xxx_0_0, 0)) self.connect((self.gr_rds_freq_divider_0, 0), (self.fir_filter_xxx_7, 0)) self.connect((self.fir_filter_xxx_7, 0), (self.gr_rds_bpsk_demod_0, 1)) self.connect((self.digital_diff_decoder_bb_0, 0), (self.gr_rds_data_decoder_0, 0)) self.connect((self.gr_rds_bpsk_demod_0, 0), (self.digital_diff_decoder_bb_0, 0)) self.connect((self.fir_filter_xxx_6, 0), (self.gr_rds_bpsk_demod_0, 0)) self.connect((self.fir_filter_xxx_2, 0), (self.wxgui_scopesink2_0, 0)) self.connect((self.fir_filter_xxx_1, 0), (self.wxgui_fftsink2_0_0_0, 0)) self.connect((self.fir_filter_xxx_3, 0), (self.wxgui_fftsink2_0_0_0_1, 0)) self.connect((self.fir_filter_xxx_4, 0), (self.wxgui_fftsink2_0_0_0_1_0, 0)) self.connect((self.blocks_multiply_xx_0_0, 0), (self.fir_filter_xxx_6, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.wxgui_fftsink2_0_0_0_1_0_0, 0)) self.connect((self.fir_filter_xxx_5, 0), (self.blocks_add_xx_0, 1)) self.connect((self.fir_filter_xxx_5, 0), (self.blocks_sub_xx_0, 1)) self.connect((self.blocks_multiply_xx_0_0, 0), (self.wxgui_fftsink2_0_0_0_1_0_1, 0)) self.connect((self.blocks_sub_xx_0, 0), (self.blks2_fm_deemph_0_0, 0)) self.connect((self.blks2_fm_deemph_0_0, 0), (self.gr_multiply_const_vxx_0_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.blks2_fm_deemph_0_0_0, 0)) self.connect((self.blks2_fm_deemph_0_0_0, 0), (self.gr_multiply_const_vxx_0, 0)) self.connect((self.gr_pll_freqdet_cf_0, 0), (self.wxgui_fftsink2_0_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Stereo FM receiver and RDS Decoder") ################################################## # Variables ################################################## self.xlate_decim = xlate_decim = 4 self.samp_rate = samp_rate = 1000000 self.freq_offset = freq_offset = 250e3 self.freq = freq = 88.5e6 self.baseband_rate = baseband_rate = samp_rate/xlate_decim self.audio_decim = audio_decim = 4 self.xlate_bandwidth = xlate_bandwidth = 250e3 self.volume = volume = 0 self.loop_bw = loop_bw = 16e3*0 + 18e3*1 self.gain = gain = 10 self.freq_tune = freq_tune = freq - freq_offset self.audio_rate = audio_rate = 48000 self.audio_decim_rate = audio_decim_rate = baseband_rate/audio_decim self.antenna = antenna = 'TX/RX' ################################################## # Message Queues ################################################## gr_rds_data_decoder_0_msgq_out = gr_rds_panel_0_msgq_in = gr.msg_queue(2) ################################################## # 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.Add(_volume_sizer) 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), "L+R") self.nb.AddPage(grc_wxgui.Panel(self.nb), "Pilot") self.nb.AddPage(grc_wxgui.Panel(self.nb), "DSBSC") self.nb.AddPage(grc_wxgui.Panel(self.nb), "RDS Raw") self.nb.AddPage(grc_wxgui.Panel(self.nb), "L-R") self.nb.AddPage(grc_wxgui.Panel(self.nb), "RDS") self.Add(self.nb) _loop_bw_sizer = wx.BoxSizer(wx.VERTICAL) self._loop_bw_text_box = forms.text_box( parent=self.GetWin(), sizer=_loop_bw_sizer, value=self.loop_bw, callback=self.set_loop_bw, label="Loop BW", converter=forms.float_converter(), proportion=0, ) self._loop_bw_slider = forms.slider( parent=self.GetWin(), sizer=_loop_bw_sizer, value=self.loop_bw, callback=self.set_loop_bw, minimum=0, maximum=baseband_rate, num_steps=1000, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_loop_bw_sizer) _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="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=50, num_steps=50, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_gain_sizer) self._freq_offset_text_box = forms.text_box( parent=self.GetWin(), value=self.freq_offset, callback=self.set_freq_offset, label="Freq Offset", converter=forms.float_converter(), ) self.Add(self._freq_offset_text_box) _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=87.5e6, maximum=108e6, num_steps=205, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_freq_sizer) self._antenna_chooser = forms.drop_down( parent=self.GetWin(), value=self.antenna, callback=self.set_antenna, label="Antenna", choices=['TX/RX', 'RX2'], labels=[], ) self.Add(self._antenna_chooser) self.wxgui_scopesink2_0 = scopesink2.scope_sink_f( self.nb.GetPage(3).GetWin(), title="Pilot", sample_rate=baseband_rate, v_scale=0, v_offset=0, t_scale=0, ac_couple=False, xy_mode=False, num_inputs=1, trig_mode=gr.gr_TRIG_MODE_AUTO, y_axis_label="Counts", ) self.nb.GetPage(3).Add(self.wxgui_scopesink2_0.win) self.wxgui_fftsink2_0_0_0_1_0_1 = fftsink2.fft_sink_f( self.nb.GetPage(7).GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=-50, ref_scale=2.0, sample_rate=baseband_rate, fft_size=1024, fft_rate=15, average=False, avg_alpha=None, title="RDS", peak_hold=False,) self.nb.GetPage(7).Add(self.wxgui_fftsink2_0_0_0_1_0_1.win) self.wxgui_fftsink2_0_0_0_1_0_0 = fftsink2.fft_sink_f( self.nb.GetPage(6).GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=-50, ref_scale=2.0, sample_rate=baseband_rate, fft_size=1024, fft_rate=15, average=False, avg_alpha=None, title="L-R", peak_hold=False,) self.nb.GetPage(6).Add(self.wxgui_fftsink2_0_0_0_1_0_0.win) self.wxgui_fftsink2_0_0_0_1_0 = fftsink2.fft_sink_f( self.nb.GetPage(5).GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=baseband_rate, 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.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=baseband_rate, fft_size=1024, fft_rate=15, average=False, avg_alpha=None, title="DSBSC Sub-carrier", 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(2).GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=audio_decim_rate, fft_size=1024, fft_rate=15, average=False, avg_alpha=None, title="L+R", peak_hold=False,) self.nb.GetPage(2).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=baseband_rate, 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=baseband_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.uhd_usrp_source_0 = uhd.usrp_source( device_addr="", stream_args=uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_source_0.set_samp_rate(samp_rate) self.uhd_usrp_source_0.set_center_freq(freq_tune, 0) self.uhd_usrp_source_0.set_gain(gain, 0) self.uhd_usrp_source_0.set_antenna(antenna, 0) self.gr_rds_panel_0 = rds.rdsPanel(gr_rds_panel_0_msgq_in, freq, self.GetWin()) self.Add(self.gr_rds_panel_0) self.gr_rds_freq_divider_0 = rds.freq_divider(16) self.gr_rds_data_decoder_0 = rds.data_decoder(gr_rds_data_decoder_0_msgq_out) self.gr_rds_bpsk_demod_0 = rds.bpsk_demod(audio_decim_rate) self.gr_pll_freqdet_cf_0 = gr.pll_freqdet_cf(1.0*0 + (loop_bw*2*math.pi/baseband_rate), +(2.0 * math.pi * 90e3 / baseband_rate), -(2.0 * math.pi * 90e3 / baseband_rate)) self.gr_multiply_const_vxx_0_0 = gr.multiply_const_vff((10**(1.*volume/10), )) self.gr_multiply_const_vxx_0 = gr.multiply_const_vff((10**(1.*volume/10), )) self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(xlate_decim, (firdes.low_pass(1, samp_rate, xlate_bandwidth/2, 1000)), freq_offset, samp_rate) self.fir_filter_xxx_7 = filter.fir_filter_fff(audio_decim, (firdes.low_pass(1,baseband_rate,1.2e3,1.5e3,firdes.WIN_HAMMING))) self.fir_filter_xxx_6 = filter.fir_filter_fff(audio_decim, (firdes.low_pass(1,baseband_rate,1.5e3,2e3,firdes.WIN_HAMMING))) self.fir_filter_xxx_5 = filter.fir_filter_fff(audio_decim, (firdes.low_pass(1.0,baseband_rate,15e3,1e3,firdes.WIN_HAMMING))) self.fir_filter_xxx_4 = filter.fir_filter_fff(1, (firdes.band_pass(1.0,baseband_rate,57e3-3e3,57e3+3e3,3e3,firdes.WIN_HAMMING))) self.fir_filter_xxx_3 = filter.fir_filter_fff(1, (firdes.band_pass(1.0,baseband_rate,38e3-15e3/2,38e3+15e3/2,1e3,firdes.WIN_HAMMING))) self.fir_filter_xxx_2 = filter.fir_filter_fff(1, (firdes.band_pass(1.0,baseband_rate,19e3-500,19e3+500,1e3,firdes.WIN_HAMMING))) self.fir_filter_xxx_1 = filter.fir_filter_fff(audio_decim, (firdes.low_pass(1.0,baseband_rate,15e3,1e3,firdes.WIN_HAMMING))) self.fir_filter_xxx_0 = filter.fir_filter_ccc(1, (firdes.low_pass(1.0, baseband_rate, 80e3,35e3,firdes.WIN_HAMMING))) 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_0 = blocks.multiply_vff(1) self.blocks_multiply_xx_0 = blocks.multiply_vff(1) self.blocks_add_xx_0 = blocks.add_vff(1) self.blks2_rational_resampler_xxx_0_0 = blks2.rational_resampler_fff( interpolation=audio_rate, decimation=audio_decim_rate, taps=None, fractional_bw=None, ) self.blks2_rational_resampler_xxx_0 = blks2.rational_resampler_fff( interpolation=audio_rate, decimation=audio_decim_rate, taps=None, fractional_bw=None, ) self.blks2_fm_deemph_0_0_0 = blks2.fm_deemph(fs=baseband_rate, tau=75e-6) self.blks2_fm_deemph_0_0 = blks2.fm_deemph(fs=baseband_rate, tau=75e-6) self.audio_sink_0 = audio.sink(audio_rate, "", True) ################################################## # Connections ################################################## self.connect((self.uhd_usrp_source_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.fir_filter_xxx_0, 0)) self.connect((self.fir_filter_xxx_0, 0), (self.gr_pll_freqdet_cf_0, 0)) self.connect((self.gr_pll_freqdet_cf_0, 0), (self.fir_filter_xxx_1, 0)) self.connect((self.gr_pll_freqdet_cf_0, 0), (self.fir_filter_xxx_2, 0)) self.connect((self.gr_pll_freqdet_cf_0, 0), (self.fir_filter_xxx_4, 0)) self.connect((self.fir_filter_xxx_2, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.fir_filter_xxx_2, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.fir_filter_xxx_2, 0), (self.blocks_multiply_xx_0_0, 0)) self.connect((self.fir_filter_xxx_2, 0), (self.blocks_multiply_xx_0_0, 1)) self.connect((self.fir_filter_xxx_3, 0), (self.blocks_multiply_xx_0, 2)) self.connect((self.fir_filter_xxx_4, 0), (self.blocks_multiply_xx_0_0, 3)) self.connect((self.fir_filter_xxx_2, 0), (self.blocks_multiply_xx_0_0, 2)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.fir_filter_xxx_1, 0), (self.blocks_sub_xx_0, 0)) self.connect((self.fir_filter_xxx_2, 0), (self.gr_rds_freq_divider_0, 0)) self.connect((self.fir_filter_xxx_1, 0), (self.blocks_add_xx_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.fir_filter_xxx_5, 0)) self.connect((self.gr_pll_freqdet_cf_0, 0), (self.fir_filter_xxx_3, 0)) self.connect((self.gr_multiply_const_vxx_0, 0), (self.blks2_rational_resampler_xxx_0, 0)) self.connect((self.blks2_rational_resampler_xxx_0, 0), (self.audio_sink_0, 0)) self.connect((self.blks2_rational_resampler_xxx_0_0, 0), (self.audio_sink_0, 1)) self.connect((self.gr_multiply_const_vxx_0_0, 0), (self.blks2_rational_resampler_xxx_0_0, 0)) self.connect((self.gr_rds_freq_divider_0, 0), (self.fir_filter_xxx_7, 0)) self.connect((self.fir_filter_xxx_7, 0), (self.gr_rds_bpsk_demod_0, 1)) self.connect((self.digital_diff_decoder_bb_0, 0), (self.gr_rds_data_decoder_0, 0)) self.connect((self.gr_rds_bpsk_demod_0, 0), (self.digital_diff_decoder_bb_0, 0)) self.connect((self.fir_filter_xxx_6, 0), (self.gr_rds_bpsk_demod_0, 0)) self.connect((self.fir_filter_xxx_2, 0), (self.wxgui_scopesink2_0, 0)) self.connect((self.fir_filter_xxx_1, 0), (self.wxgui_fftsink2_0_0_0, 0)) self.connect((self.fir_filter_xxx_3, 0), (self.wxgui_fftsink2_0_0_0_1, 0)) self.connect((self.fir_filter_xxx_4, 0), (self.wxgui_fftsink2_0_0_0_1_0, 0)) self.connect((self.blocks_multiply_xx_0_0, 0), (self.fir_filter_xxx_6, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.wxgui_fftsink2_0_0_0_1_0_0, 0)) self.connect((self.fir_filter_xxx_5, 0), (self.blocks_add_xx_0, 1)) self.connect((self.fir_filter_xxx_5, 0), (self.blocks_sub_xx_0, 1)) self.connect((self.blocks_multiply_xx_0_0, 0), (self.wxgui_fftsink2_0_0_0_1_0_1, 0)) self.connect((self.blocks_sub_xx_0, 0), (self.blks2_fm_deemph_0_0, 0)) self.connect((self.blks2_fm_deemph_0_0, 0), (self.gr_multiply_const_vxx_0_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.blks2_fm_deemph_0_0_0, 0)) self.connect((self.blks2_fm_deemph_0_0_0, 0), (self.gr_multiply_const_vxx_0, 0)) self.connect((self.gr_pll_freqdet_cf_0, 0), (self.wxgui_fftsink2_0_0, 0))