def __init__(self): gr.top_block.__init__(self, "Phase Diff") ################################################## # Variables ################################################## self.samp_rate = samp_rate = 44100 ################################################## # Blocks ################################################## self.gr_file_sink_0 = gr.file_sink(gr.sizeof_float*1, "phase_diffs.dat") self.gr_float_to_complex_0 = gr.float_to_complex() self.gr_float_to_complex_1 = gr.float_to_complex() self.gr_wavfile_source_0 = gr.wavfile_source("8k.wav", False) self.gr_wavfile_source_1 = gr.wavfile_source("14k.wav", False) self.wmu_phase_compute_cf_0 = wmu.phase_compute_cf() ################################################## # Connections ################################################## self.connect((self.gr_wavfile_source_0, 0), (self.gr_float_to_complex_0, 0)) self.connect((self.gr_wavfile_source_0, 1), (self.gr_float_to_complex_0, 1)) self.connect((self.gr_wavfile_source_1, 0), (self.gr_float_to_complex_1, 0)) self.connect((self.gr_wavfile_source_1, 1), (self.gr_float_to_complex_1, 1)) self.connect((self.gr_float_to_complex_1, 0), (self.wmu_phase_compute_cf_0, 1)) self.connect((self.gr_float_to_complex_0, 0), (self.wmu_phase_compute_cf_0, 0)) self.connect((self.wmu_phase_compute_cf_0, 0), (self.gr_file_sink_0, 0))
def _setup_head(self): """ Sets up the input of the flow graph, i.e. determine which kind of file source is necessary. """ if self.filename[-4:].lower() == '.wav': if self.options.verbose: print 'Reading data from a WAV file.' src = gr.wavfile_source(self.filename, True) f2c = gr.float_to_complex() self.connect((src, 0), (f2c, 0)) if src.channels() == 2: self.connect((src, 1), (f2c, 1)) self.connect(f2c, self.head) else: if self.options.verbose: print 'Reading data from a raw data file.' src = gr.file_source(self.options.sample_size, self.filename, True) if self.options.sample_size == gr.sizeof_float: f2c = gr.float_to_complex() self.connect(src, f2c, self.head) if self.options.verbose: print ' Input data is considered real.' else: self.connect(src, self.head) if self.options.verbose: print ' Input data is considered complex.'
def __init__(self): gr.top_block.__init__(self) self.frequency = 13.56e6 self.gain = 100 self.usrp_interpol = 32 # USRP settings self.u_tx = usrp.sink_c() #create the USRP sink for TX #try and set the LF_RX for this self.tx_subdev_spec = usrp.pick_subdev(self.u_tx, (usrp_dbid.LF_RX, usrp_dbid.LF_TX)) #set the interpolation rate to match the USRP's 128 MS/s self.u_tx.set_interp_rate(self.usrp_interpol) #Configure the MUX for the daughterboard self.u_tx.set_mux(usrp.determine_tx_mux_value(self.u_tx, self.tx_subdev_spec)) #Tell it to use the LF_TX self.subdev_tx = usrp.selected_subdev(self.u_tx, self.tx_subdev_spec) #Make sure it worked print "Using TX dboard %s" % (self.subdev_tx.side_and_name(),) #Set gain.. duh self.subdev_tx.set_gain(self.gain) #Tune the center frequency self.u_tx.tune(0, self.subdev_tx, self.frequency) self.src = gr.wavfile_source("RFID_command_52_4M_1610.wav", False) self.conv = gr.float_to_complex() self.amp = gr.multiply_const_cc(10.0 ** (self.gain / 20.0)) self.connect(self.src, self.conv, self.amp, self.u_tx)
def qa_linker(): import time from gnuradio import window from system import System from signal_psk31 import PSK31Signal def mag(c): """Magnitude of complex number.""" return (c*c.conjugate()).real src = gr.wavfile_source("../example.WAV", False) samp_rate = 44100 tb = gr.top_block() system = System(tb, src, samp_rate, throttle=False, src_is_float=True, center_freq=0) linker = Linker(1000, 80, samp_rate) snk = gr.null_sink(gr.sizeof_gr_complex) system.connect(system.out, linker, snk) system.refresh() system.start() time.sleep(5) system.stop() data = linker.probe.level() print(data[:10]) print(linker.samp_rate) plot_fft([mag(x) for x in data], linker.samp_rate)
def __init__(self): gr.top_block.__init__(self) self.frequency = 13.56e6 self.gain = 100 # for 4 MS/s, 32 # self.usrp_interpol = 32 # USRP settings self.u_tx = usrp.sink_c() #create the USRP sink for TX #try and set the LF_RX for this self.tx_subdev_spec = usrp.pick_subdev(self.u_tx, (usrp_dbid.LF_RX, usrp_dbid.LF_TX)) #set the interpolation rate to match the USRP's 128 MS/s self.u_tx.set_interp_rate(self.usrp_interpol) #Configure the MUX for the daughterboard self.u_tx.set_mux(usrp.determine_tx_mux_value(self.u_tx, self.tx_subdev_spec)) #Tell it to use the LF_TX self.subdev_tx = usrp.selected_subdev(self.u_tx, self.tx_subdev_spec) #Make sure it worked print "Using TX dboard %s" % (self.subdev_tx.side_and_name(),) #Set gain.. duh self.subdev_tx.set_gain(self.gain) #Tune the center frequency self.u_tx.tune(0, self.subdev_tx, self.frequency) # self.src = gr.wavfile_source("RFID_command_52_4M_1610.wav", True) self.src = gr.wavfile_source("wave52.wav", True) self.conv = gr.float_to_complex() self.amp = gr.multiply_const_cc(10.0 ** (self.gain / 20.0)) self.connect(self.src, self.conv, self.amp, self.u_tx)
def __init__(self): gr.top_block.__init__(self, "am modulator") ################################################## # Variables ################################################## self.samp_rate = samp_rate = 44100 self.freq = freq = 8000 ################################################## # Blocks ################################################## self.gr_complex_to_float_0 = gr.complex_to_float(1) self.gr_float_to_complex_0 = gr.float_to_complex() self.gr_multiply_vxx_0 = gr.multiply_vcc(1) self.gr_sig_source_x_0 = gr.sig_source_c(samp_rate, gr.GR_COS_WAVE, freq, 1, 0) self.gr_wavfile_sink_0 = gr.wavfile_sink("8k.wav", 2, samp_rate, 16) self.gr_wavfile_source_0 = gr.wavfile_source("orig.wav", False) ################################################## # Connections ################################################## self.connect((self.gr_sig_source_x_0, 0), (self.gr_multiply_vxx_0, 0)) self.connect((self.gr_wavfile_source_0, 0), (self.gr_float_to_complex_0, 0)) self.connect((self.gr_float_to_complex_0, 0), (self.gr_multiply_vxx_0, 1)) self.connect((self.gr_wavfile_source_0, 1), (self.gr_float_to_complex_0, 1)) self.connect((self.gr_multiply_vxx_0, 0), (self.gr_complex_to_float_0, 0)) self.connect((self.gr_complex_to_float_0, 0), (self.gr_wavfile_sink_0, 0)) self.connect((self.gr_complex_to_float_0, 1), (self.gr_wavfile_sink_0, 1))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="RTTY decoder example") ################################################## # Variables ################################################## self.samp_rate = samp_rate = 44100 ################################################## # Blocks ################################################## self.wxgui_scopesink2_0 = scopesink2.scope_sink_f( self.GetWin(), title="Scope Plot", sample_rate=samp_rate/40, v_scale=1, v_offset=0, t_scale=25e-3, ac_couple=False, xy_mode=False, num_inputs=1, trig_mode=gr.gr_TRIG_MODE_AUTO, y_axis_label="Counts", ) self.Add(self.wxgui_scopesink2_0.win) self.rtty_decode_ff_0 = rtty.decode_ff( samp_rate=samp_rate/40, baud_rate=45.45, polarity=True, ) self.low_pass_filter_0 = gr.fir_filter_fff(40, firdes.low_pass( 100, samp_rate, 45.45*3, 20, firdes.WIN_HANN, 6.76)) self.gr_wavfile_source_0 = gr.wavfile_source("/home/nick/Downloads/ksm_rtty.wav", False) self.gr_sub_xx_0 = gr.sub_ff(1) self.gr_quadrature_demod_cf_0 = gr.quadrature_demod_cf(1) self.gr_moving_average_xx_0 = gr.moving_average_ff(5000, 1.0/5000, 20000) self.gr_hilbert_fc_0 = gr.hilbert_fc(64) self.gr_file_sink_0 = gr.file_sink(gr.sizeof_char*1, "/home/nick/Desktop/rtty/test.dat") self.gr_file_sink_0.set_unbuffered(False) ################################################## # Connections ################################################## self.connect((self.low_pass_filter_0, 0), (self.gr_moving_average_xx_0, 0)) self.connect((self.gr_moving_average_xx_0, 0), (self.gr_sub_xx_0, 1)) self.connect((self.gr_sub_xx_0, 0), (self.wxgui_scopesink2_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.gr_sub_xx_0, 0)) self.connect((self.rtty_decode_ff_0, 0), (self.gr_file_sink_0, 0)) self.connect((self.gr_sub_xx_0, 0), (self.rtty_decode_ff_0, 0)) self.connect((self.gr_quadrature_demod_cf_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.gr_hilbert_fc_0, 0), (self.gr_quadrature_demod_cf_0, 0)) self.connect((self.gr_wavfile_source_0, 0), (self.gr_hilbert_fc_0, 0))
def __init__(self): tb = gr.top_block() src = gr.wavfile_source('example.WAV', True) samp_rate = 44100 self.system = System(tb, src, samp_rate, throttle=True, src_is_float=True, center_freq=0) self.detector = Detector(self.system) self.channelizer = Channelizer(self.system) self.app = QtGui.QApplication([]) self.widget = PSK31QWidget() self.timer = QtCore.QTimer() self.timer.timeout.connect(self.update) self.signals = []
def __init__(self, inputfile, callback, options): gr.top_block.__init__(self) # settings for the demodulator: /usr/local/lib/python2.5/site-packages/gnuradio/blks2impl/gmsk.py # settings for the demodulator: /usr/local/lib/python2.5/site-packages/gnuradio/blks2impl/pkt.py if options.dsp: self.src = audio.source(options.dsp_sample_rate, "", True) else: self.src = gr.wavfile_source( inputfile, False ) self.iq_to_c = gr.float_to_complex() if options.dsp and options.wait: samples = options.dsp_sample_rate * options.wait self._head0 = gr.head(gr.sizeof_float, samples) self._head1 = gr.head(gr.sizeof_float, samples) self.connect( (self.src, 0), self._head0, (self.iq_to_c, 0) ) self.connect( (self.src, 1), self._head1, (self.iq_to_c, 1) ) if verbose: print "installed %d second head filter on dsp (%d samples at %d sps)" % (options.wait, samples, options.dsp_sample_rate) else: self.connect( (self.src, 0), (self.iq_to_c, 0) ) self.connect( (self.src, 1), (self.iq_to_c, 1) ) self.demodulator = blks2.gmsk_demod(samples_per_symbol=options.samples_per_symbol) self.pkt_queue = blks2.demod_pkts( demodulator=self.demodulator, callback=callback, threshold=options.threshold ) if options.carrier_frequency == 0: self.mixer = self.iq_to_c else: self.carrier = gr.sig_source_c( options.carrier_sample_rate, gr.GR_SIN_WAVE, - options.carrier_frequency, 1.0 ) self.mixer = gr.multiply_vcc(1) self.connect(self.iq_to_c, (self.mixer, 0) ) self.connect(self.carrier, (self.mixer, 1) ) self.amp = gr.multiply_const_cc(1); self.amp.set_k(options.amp_amplitude) self.connect(self.mixer, self.amp, self.pkt_queue) if options.debug_wavs: from myblks import debugwav self._dpass = debugwav("rx_passband", options) self._dbase = debugwav("rx_baseband", options) self.connect(self.iq_to_c, self._dpass) self.connect(self.mixer, self._dbase) if options.debug_files: self._dpassf = gr.file_sink(gr.sizeof_gr_complex*1, "debug_rx_passband.d_c") self._dbasef = gr.file_sink(gr.sizeof_gr_complex*1, "debug_rx_baseband.d_c") self.connect(self.iq_to_c, self._dpassf) self.connect(self.mixer, self._dbasef)
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Top Block") ################################################## # Variables ################################################## self.samp_rate = samp_rate = 500e3 ################################################## # Blocks ################################################## self.blks2_nbfm_tx_0 = blks2.nbfm_tx( audio_rate=25000, quad_rate=100000, tau=75e-6, max_dev=5e3, ) self.blks2_rational_resampler_xxx_0 = blks2.rational_resampler_ccc( interpolation=5, decimation=1, taps=None, fractional_bw=None, ) self.gr_multiply_xx_0 = gr.multiply_vcc(1) self.gr_sig_source_x_0 = gr.sig_source_c(samp_rate, gr.GR_COS_WAVE, 6.9e3, 1, 0) self.gr_wavfile_source_0 = gr.wavfile_source("classical.wav", True) self.uhd_single_usrp_sink_0 = uhd.single_usrp_sink( device_addr="addr=192.168.10.2", io_type=uhd.io_type.COMPLEX_FLOAT32, num_channels=1, ) self.uhd_single_usrp_sink_0.set_samp_rate(samp_rate) self.uhd_single_usrp_sink_0.set_center_freq(462.5625e6, 0) self.uhd_single_usrp_sink_0.set_gain(30, 0) ################################################## # Connections ################################################## self.connect((self.gr_wavfile_source_0, 0), (self.blks2_nbfm_tx_0, 0)) self.connect((self.blks2_nbfm_tx_0, 0), (self.blks2_rational_resampler_xxx_0, 0)) self.connect((self.blks2_rational_resampler_xxx_0, 0), (self.gr_multiply_xx_0, 0)) self.connect((self.gr_sig_source_x_0, 0), (self.gr_multiply_xx_0, 1)) self.connect((self.gr_multiply_xx_0, 0), (self.uhd_single_usrp_sink_0, 0))
def _setup_head(self): """ Sets up the input of the flow graph, i.e. determine which kind of file source is necessary. """ if self.filename[-4:].lower() == '.wav': src = gr.wavfile_source(self.filename, True) f2c = gr.float_to_complex() self.connect((src, 0), (f2c, 0)) if src.channels() == 2: self.connect((src, 1), (f2c, 1)) self.connect(f2c, self.head) else: src = gr.file_source(self.options.sample_size, self.filename, True) if self.options.sample_size == gr.sizeof_float: f2c = gr.float_to_complex() self.connect(src, f2c, self.head) else: self.connect(src, self.head)
def __init__(self, frame, panel, vbox, argv): stdgui2.std_top_block.__init__(self, frame, panel, vbox, argv) self.frame = frame self.panel = panel parser = OptionParser(option_class=eng_option) parser.add_option("", "--fft-size", type="int", default=512, help="[default=%default]"); parser.add_option("", "--fft-rate", type="int", default=30, help="[default=%default]"); parser.add_option("", "--ref-scale", type="eng_float", default=1.0, help="[default=%default]"); parser.add_option("", "--ref-level", type="int", default=20, help="[default=%default]"); parser.add_option("", "--y-divs", type="int", default=12, help="[default=%default]"); parser.add_option("", "--y-per-div", type="int", default=10, help="[default=%default]"); parser.add_option("", "--baseband-freq", type="eng_float", default=0, help="[default=%default]") parser.add_option("", "--input-file", type="string", default=None, help="[default=%default]") (options, args) = parser.parse_args() if len(args) != 0: parser.print_help() raise SystemExit, 1 using_wav=False if options.input_file and os.path.exists(options.input_file): self.wav = gr.wavfile_source( options.input_file, True ) using_wav=True else: self.wav = audio.source(sample_rate, "", True) self.f2c = gr.float_to_complex() self.scope = fftsink2.fft_sink_c(panel, fft_size=options.fft_size, sample_rate=sample_rate, fft_rate=options.fft_rate, ref_scale=options.ref_scale, ref_level=options.ref_level, y_divs=options.y_divs, average=True, baseband_freq=options.baseband_freq, y_per_div=options.y_per_div) self.connect((self.wav, 0), (self.f2c, 0)) self.connect((self.wav, 1), (self.f2c, 1)) if using_wav: self.throttle = gr.throttle(gr.sizeof_gr_complex, sample_rate) self.connect(self.f2c, self.throttle, self.scope) else: self.connect((self.f2c, 0), (self.scope, 0)) vbox.Add(self.scope.win, 10, wx.EXPAND)
def test_002_checkwavcopy(self): infile = g_in_file outfile = "test_out.wav" wf_in = gr.wavfile_source(infile) wf_out = gr.wavfile_sink(outfile, wf_in.channels(), wf_in.sample_rate(), wf_in.bits_per_sample()) self.tb.connect(wf_in, wf_out) self.tb.run() wf_out.close() self.assertEqual(getsize(infile), getsize(outfile)) in_f = file(infile, 'rb') out_f = file(outfile, 'rb') in_data = in_f.read() out_data = out_f.read() out_f.close() os.remove(outfile) self.assertEqual(in_data, out_data)
def __init__(self): gr.top_block.__init__(self) parser = OptionParser(option_class=eng_option) parser.add_option("-I", "--filename", type="string", help="read input from wav FILE") parser.add_option("-s", "--input-rate", type="eng_float", default="500k", help="set sample rate to RATE (500k)") parser.add_option("-O", "--outname", type="string", help="output to wav file FILE") parser.add_option("-r", "--output-rate", type="eng_float", default="192k", help="set output sample rate to RATE (192k)") parser.add_option("-F", "--filter", action="store_true", default=False, help="filter out audible sounds, retain ultrasonic") (options, args) = parser.parse_args() if len(args) != 0: parser.print_help() raise SystemExit, 1 src = gr.wavfile_source (options.filename) input_rate = int(options.input_rate) output_rate = int(options.output_rate) interp = gru.lcm(input_rate, output_rate) / input_rate decim = gru.lcm(input_rate, output_rate) / output_rate dst = gr.wavfile_sink (options.outname, 1, output_rate) rr = blks2.rational_resampler_fff(int(interp), int(decim)) if options.filter: highpass = gr.firdes.high_pass (1, # gain output_rate, # sampling rate 15000, # cutoff freq 2000, # width of trans. band gr.firdes.WIN_HANN) # filter type filt = gr.fir_filter_fff(1,highpass) self.connect (src, rr, filt, dst) else: self.connect (src, rr, dst)
def __init__(self, frame, panel, vbox, argv): stdgui2.std_top_block.__init__(self, frame, panel, vbox, argv) self.frame = frame self.panel = panel parser = OptionParser(option_class=eng_option) parser.add_option("", "--frame-decim", type="int", default=15, help="[default=%default]") parser.add_option("", "--input-file", type="string", default=None, help="[default=%default]") (options, args) = parser.parse_args() if len(args) != 0: parser.print_help() raise SystemExit, 1 using_wav = False if options.input_file and os.path.exists(options.input_file): self.wav = gr.wavfile_source(options.input_file, True) using_wav = True else: self.wav = audio.source(sample_rate, "", True) self.f2c = gr.float_to_complex() self.scope = scopesink2.constellation_sink( panel, title="Constellation Plot", sample_rate=sample_rate, frame_decim=options.frame_decim ) self.connect((self.wav, 0), (self.f2c, 0)) self.connect((self.wav, 1), (self.f2c, 1)) if using_wav: self.throttle = gr.throttle(gr.sizeof_gr_complex, sample_rate) self.connect(self.f2c, self.throttle, self.scope) else: self.connect((self.f2c, 0), (self.scope, 0)) vbox.Add(self.scope.win, 10, wx.EXPAND)
def __init__(self): gr.hier_block2.__init__(self, "tx_path", gr.io_signature(0, 0, 0), gr.io_signature(0, 0, 0)) self.frequency = 13.56e6 self.normal_gain = 100 self.k = 0 self.usrp_interpol = int(128 / (SAMPLERATE / 1e6)) print "[+] Using interpolation rate of", self.usrp_interpol # USRP settings self.u_tx = usrp.sink_c() #create the USRP sink for TX #try and set the LF_RX for this self.tx_subdev_spec = usrp.pick_subdev( self.u_tx, (usrp_dbid.LF_RX, usrp_dbid.LF_TX)) #set the interpolation rate to match the USRP's 128 MS/s self.u_tx.set_interp_rate(self.usrp_interpol) #Configure the MUX for the daughterboard self.u_tx.set_mux( usrp.determine_tx_mux_value(self.u_tx, self.tx_subdev_spec)) #Tell it to use the LF_TX self.subdev_tx = usrp.selected_subdev(self.u_tx, self.tx_subdev_spec) #Make sure it worked print "Using TX dboard %s" % (self.subdev_tx.side_and_name(), ) #Set gain.. duh self.subdev_tx.set_gain(self.normal_gain) #Tune the center frequency self.u_tx.tune(0, self.subdev_tx, self.frequency) self.src = gr.wavfile_source("wave52.wav", True) self.conv = gr.float_to_complex() self.amp = gr.multiply_const_cc(10.0**(self.normal_gain / 20.0)) self.connect(self.src, self.conv, self.amp, self.u_tx)
def __init__(self): gr.hier_block2.__init__(self, "tx_path", gr.io_signature(0, 0, 0), gr.io_signature(0, 0, 0)) self.frequency = 13.56e6 self.normal_gain = 100 self.k = 0 self.usrp_interpol = int(128/(SAMPLERATE/1e6)) print "[+] Using interpolation rate of",self.usrp_interpol # USRP settings self.u_tx = usrp.sink_c() #create the USRP sink for TX #try and set the LF_RX for this self.tx_subdev_spec = usrp.pick_subdev(self.u_tx, (usrp_dbid.LF_RX, usrp_dbid.LF_TX)) #set the interpolation rate to match the USRP's 128 MS/s self.u_tx.set_interp_rate(self.usrp_interpol) #Configure the MUX for the daughterboard self.u_tx.set_mux(usrp.determine_tx_mux_value(self.u_tx, self.tx_subdev_spec)) #Tell it to use the LF_TX self.subdev_tx = usrp.selected_subdev(self.u_tx, self.tx_subdev_spec) #Make sure it worked print "Using TX dboard %s" % (self.subdev_tx.side_and_name(),) #Set gain.. duh self.subdev_tx.set_gain(self.normal_gain) #Tune the center frequency self.u_tx.tune(0, self.subdev_tx, self.frequency) self.src = gr.wavfile_source("wave52.wav", True) self.conv = gr.float_to_complex() self.amp = gr.multiply_const_cc(10.0 ** (self.normal_gain / 20.0)) self.connect(self.src, self.conv, self.amp, self.u_tx)
def test_002_checkwavcopy (self): infile = g_in_file outfile = "test_out.wav" wf_in = gr.wavfile_source(infile) wf_out = gr.wavfile_sink(outfile, wf_in.channels(), wf_in.sample_rate(), wf_in.bits_per_sample()) self.tb.connect(wf_in, wf_out) self.tb.run() wf_out.close() self.assertEqual(getsize(infile), getsize(outfile)) in_f = file(infile, 'rb') out_f = file(outfile, 'rb') in_data = in_f.read() out_data = out_f.read() out_f.close() os.remove(outfile) self.assertEqual(in_data, out_data)
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("-T", "--tx-subdev-spec", type="subdev", default=None, help="select USRP Tx side A or B") parser.add_option( "-f", "--freq", type="eng_float", default=107.2e6, help="set Tx frequency to FREQ [required]", metavar="FREQ", ) parser.add_option("--wavfile", type="string", default=None, help="open .wav audio file FILE") parser.add_option("--xml", type="string", default="rds_data.xml", help="open .xml RDS data FILE") (options, args) = parser.parse_args() if len(args) != 0: parser.print_help() sys.exit(1) usrp_interp = 500 self.u = usrp.sink_c(0, usrp_interp) print "USRP Serial: ", self.u.serial_number() usrp_rate = self.u.dac_rate() / usrp_interp # 256 kS/s # determine the daughterboard subdevice we're using if options.tx_subdev_spec is None: options.tx_subdev_spec = usrp.pick_tx_subdevice(self.u) self.u.set_mux(usrp.determine_tx_mux_value(self.u, options.tx_subdev_spec)) self.subdev = usrp.selected_subdev(self.u, options.tx_subdev_spec) print "Using d'board", self.subdev.side_and_name() # set max Tx gain, tune frequency and enable transmitter gain = self.subdev.gain_range()[1] self.subdev.set_gain(gain) print "Gain set to", gain if self.u.tune(self.subdev.which(), self.subdev, options.freq): print "Tuned to", options.freq / 1e6, "MHz" else: sys.exit(1) self.subdev.set_enable(True) # open wav file containing floats in the [-1, 1] range, repeat if options.wavfile is None: print "Please provide a wavfile to transmit! Exiting\n" sys.exit(1) self.src = gr.wavfile_source(options.wavfile, True) nchans = self.src.channels() sample_rate = self.src.sample_rate() bits_per_sample = self.src.bits_per_sample() print nchans, "channels,", sample_rate, "samples/sec,", bits_per_sample, "bits/sample" # resample to usrp rate self.resample_left = blks2.rational_resampler_fff(usrp_rate, sample_rate) self.resample_right = blks2.rational_resampler_fff(usrp_rate, sample_rate) self.connect((self.src, 0), self.resample_left) self.connect((self.src, 1), self.resample_right) # create L+R (mono) and L-R (stereo) self.audio_lpr = gr.add_ff() self.audio_lmr = gr.sub_ff() self.connect(self.resample_left, (self.audio_lpr, 0)) self.connect(self.resample_left, (self.audio_lmr, 0)) self.connect(self.resample_right, (self.audio_lpr, 1)) self.connect(self.resample_right, (self.audio_lmr, 1)) # low-pass filter for L+R audio_lpr_taps = gr.firdes.low_pass( 0.5, # gain usrp_rate, # sampling rate 15e3, # passband cutoff 1e3, # transition width gr.firdes.WIN_HAMMING, ) self.audio_lpr_filter = gr.fir_filter_fff(1, audio_lpr_taps) self.connect(self.audio_lpr, self.audio_lpr_filter) # create pilot tone at 19 kHz self.pilot = gr.sig_source_f( usrp_rate, gr.GR_SIN_WAVE, 19e3, 5e-2 # sampling rate # waveform # frequency ) # amplitude # upconvert L-R to 38 kHz and band-pass self.mix_stereo = gr.multiply_ff() audio_lmr_taps = gr.firdes.band_pass( 80, # gain usrp_rate, # sampling rate 38e3 - 15e3, # low cutoff 38e3 + 15e3, # high cutoff 1e3, # transition width gr.firdes.WIN_HAMMING, ) self.audio_lmr_filter = gr.fir_filter_fff(1, audio_lmr_taps) self.connect(self.audio_lmr, (self.mix_stereo, 0)) self.connect(self.pilot, (self.mix_stereo, 1)) self.connect(self.pilot, (self.mix_stereo, 2)) self.connect(self.mix_stereo, self.audio_lmr_filter) # create RDS bitstream # diff-encode, manchester-emcode, NRZ # enforce the 1187.5bps rate # pulse shaping filter (matched with receiver) # mix with 57kHz carrier (equivalent to BPSK) self.rds_enc = rds.data_encoder("rds_data.xml") self.diff_enc = gr.diff_encoder_bb(2) self.manchester1 = gr.map_bb([1, 2]) self.manchester2 = gr.unpack_k_bits_bb(2) self.nrz = gr.map_bb([-1, 1]) self.c2f = gr.char_to_float() self.rate_enforcer = rds.rate_enforcer(usrp_rate) pulse_shaping_taps = gr.firdes.low_pass( 1, # gain usrp_rate, # sampling rate 1.5e3, # passband cutoff 2e3, # transition width gr.firdes.WIN_HAMMING, ) self.pulse_shaping = gr.fir_filter_fff(1, pulse_shaping_taps) self.bpsk_mod = gr.multiply_ff() self.connect(self.rds_enc, self.diff_enc, self.manchester1, self.manchester2, self.nrz, self.c2f) self.connect(self.c2f, (self.rate_enforcer, 0)) self.connect(self.pilot, (self.rate_enforcer, 1)) self.connect(self.rate_enforcer, (self.bpsk_mod, 0)) self.connect(self.pilot, (self.bpsk_mod, 1)) self.connect(self.pilot, (self.bpsk_mod, 2)) self.connect(self.pilot, (self.bpsk_mod, 3)) # RDS band-pass filter rds_filter_taps = gr.firdes.band_pass( 50, # gain usrp_rate, # sampling rate 57e3 - 3e3, # low cutoff 57e3 + 3e3, # high cutoff 1e3, # transition width gr.firdes.WIN_HAMMING, ) self.rds_filter = gr.fir_filter_fff(1, rds_filter_taps) self.connect(self.bpsk_mod, self.rds_filter) # mix L+R, pilot, L-R and RDS self.mixer = gr.add_ff() self.connect(self.audio_lpr_filter, (self.mixer, 0)) self.connect(self.pilot, (self.mixer, 1)) self.connect(self.audio_lmr_filter, (self.mixer, 2)) self.connect(self.rds_filter, (self.mixer, 3)) # fm modulation, gain & TX max_dev = 75e3 k = 2 * math.pi * max_dev / usrp_rate # modulator sensitivity self.modulator = gr.frequency_modulator_fc(k) self.gain = gr.multiply_const_cc(5e3) self.connect(self.mixer, self.modulator, self.gain, self.u) # plot an FFT to verify we are sending what we want if 1: self.fft = fftsink2.fft_sink_f( panel, title="Pre FM modulation", fft_size=512 * 4, sample_rate=usrp_rate, y_per_div=20, ref_level=-20 ) self.connect(self.mixer, self.fft) vbox.Add(self.fft.win, 1, wx.EXPAND) if 0: self.scope = scopesink2.scope_sink_f(panel, title="RDS encoder output", sample_rate=usrp_rate) self.connect(self.rds_enc, self.scope) vbox.Add(self.scope.win, 1, wx.EXPAND)
def test_001_checkwavread(self): wf = gr.wavfile_source(g_in_file) self.assertEqual(wf.sample_rate(), 8000)
def __init__( self, frame, panel, vbox, argv): stdgui2.std_top_block.__init__( self, frame, panel, vbox, argv) self.frame = frame self.panel = panel self.offset = 0.0 # Channel frequency offset parser = OptionParser(option_class=eng_option) parser.add_option("-p", "--protocol", type="int", default=1, help="set protocol: 0 = RDLAP 19.2kbps; 1 = APCO25 (default)") parser.add_option("-g", "--gain", type="eng_float", default=1.0, help="set linear input gain (default: %default)") parser.add_option("-x", "--freq-translation", type="eng_float", default=0.0, help="initial channel frequency translation") parser.add_option("-n", "--frame-decim", type="int", default=1, help="set oscope frame decimation factor to n [default=1]") parser.add_option("-v", "--v-scale", type="eng_float", default=5000, help="set oscope initial V/div to SCALE [default=%default]") parser.add_option("-t", "--t-scale", type="eng_float", default=49e-6, help="set oscope initial s/div to SCALE [default=50us]") parser.add_option("-I", "--audio-input", type="string", default="", help="pcm input device name. E.g., hw:0,0 or /dev/dsp") parser.add_option("-r", "--sample-rate", type="eng_float", default=48000, help="set sample rate to RATE (default: %default)") parser.add_option("-d", "--channel-decim", type="int", default=None, help="set channel decimation factor to n [default depends on protocol]") parser.add_option("-w", "--wav-file", type="string", default=None, help="WAV input path") parser.add_option("-f", "--data-file", type="string", default=None, help="Data input path") parser.add_option("-B", "--base-band", action="store_true", default=False) parser.add_option("-R", "--repeat", action="store_true", default=False) parser.add_option("-o", "--wav-out", type="string", default=None, help="WAV output path") parser.add_option("-G", "--wav-out-gain", type="eng_float", default=0.05, help="set WAV output gain (default: %default)") parser.add_option("-F", "--data-out", type="string", default=None, help="Data output path") parser.add_option("-C", "--carrier-freq", type="eng_float", default=None, help="set data output carrier frequency to FREQ", metavar="FREQ") (options, args) = parser.parse_args() if len(args) != 0: parser.print_help() sys.exit(1) self.options = options if options.wav_file is not None: #try: self.input_file = gr.wavfile_source(options.wav_file, options.repeat) #except: # print "WAV file not found or not a WAV file" # sys.exit(1) print "WAV input: %i Hz, %i bits, %i channels" % (self.input_file.sample_rate(), self.input_file.bits_per_sample(), self.input_file.channels()) self.sample_rate = self.input_file.sample_rate() self.input_stream = gr.throttle(gr.sizeof_float, self.sample_rate) self.connect(self.input_file, self.input_stream) self.src = gr.multiply_const_ff(options.gain) elif options.data_file is not None: if options.base_band: sample_size = gr.sizeof_float print "Data file is baseband (float)" self.src = gr.multiply_const_ff(options.gain) else: sample_size = gr.sizeof_gr_complex print "Data file is IF (complex)" self.src = gr.multiply_const_cc(options.gain) self.input_file = gr.file_source(sample_size, options.data_file, options.repeat) self.sample_rate = options.sample_rate # E.g. 250000 print "Data file sampling rate = " + str(self.sample_rate) self.input_stream = gr.throttle(sample_size, self.sample_rate) self.connect(self.input_file, self.input_stream) else: self.sample_rate = options.sample_rate print "Soundcard sampling rate = " + str(self.sample_rate) self.input_stream = audio.source(self.sample_rate, options.audio_input) # float samples self.src = gr.multiply_const_ff(options.gain) print "Fixed input gain = " + str(options.gain) self.connect(self.input_stream, self.src) if options.wav_out is not None: output_rate = int(self.sample_rate) if options.channel_decim is not None: output_rate /= options.channel_decim self.wav_out = gr.wavfile_sink(options.wav_out, 1, output_rate, 16) print "Opened WAV output file: " + options.wav_out + " at rate: " + str(output_rate) else: self.wav_out = None if options.data_out is not None: if options.carrier_freq is None: self.data_out = gr.file_sink(gr.sizeof_float, options.data_out) print "Opened float data output file: " + options.data_out else: self.data_out = gr.file_sink(gr.sizeof_gr_complex, options.data_out) print "Opened complex data output file: " + options.data_out else: self.data_out = None self.num_inputs = 1 input_rate = self.sample_rate #title='IF', #size=(1024,800), if (options.data_file is not None) and (options.base_band == False): self.scope = scopesink2.scope_sink_c(panel, sample_rate=input_rate, frame_decim=options.frame_decim, v_scale=options.v_scale, t_scale=options.t_scale, num_inputs=self.num_inputs) else: self.scope = scopesink2.scope_sink_f(panel, sample_rate=input_rate, frame_decim=options.frame_decim, v_scale=options.v_scale, t_scale=options.t_scale, num_inputs=self.num_inputs) #self.di = gr.deinterleave(gr.sizeof_float) #self.di = gr.complex_to_float(1) #self.di = gr.complex_to_imag() #self.dr = gr.complex_to_real() #self.connect(self.src,self.dr) #self.connect(self.src,self.di) #self.null = gr.null_sink(gr.sizeof_double) #self.connect(self.src,self.di) #self.connect((self.di,0),(self.scope,0)) #self.connect((self.di,1),(self.scope,1)) #self.connect(self.dr,(self.scope,0)) #self.connect(self.di,(self.scope,1)) self.msgq = gr.msg_queue(2) # queue that holds a maximum of 2 messages self.queue_watcher = queue_watcher(self.msgq, self.adjust_freq_norm) #------------------------------------------------------------------------------- if options.protocol == 0: # ---------- RD-LAP 19.2 kbps (9600 ksps), 25kHz channel, print "RD-LAP selected" self.symbol_rate = 9600 # symbol rate; at 2 bits/symbol this corresponds to 19.2kbps if options.channel_decim is None: self.channel_decimation = 10 # decimation (final rate should be at least several symbol rate) else: self.channel_decimation = options.channel_decim self.max_frequency_offset = 12000.0 # coarse carrier tracker leash, ~ half a channel either way self.symbol_deviation = 1200.0 # this is frequency offset from center of channel to +1 / -1 symbols self.input_sample_rate = self.sample_rate self.protocol_processing = fsk4.rdlap_f(self.msgq, 0) # desired protocol processing block selected here self.channel_rate = self.input_sample_rate / self.channel_decimation # channel selection filter characteristics channel_taps = optfir.low_pass(1.0, # Filter gain self.input_sample_rate, # Sample rate 10000, # One-sided modulation bandwidth 12000, # One-sided channel bandwidth 0.1, # Passband ripple 60) # Stopband attenuation # symbol shaping filter characteristics symbol_coeffs = gr.firdes.root_raised_cosine (1.0, # gain self.channel_rate , # sampling rate self.symbol_rate, # symbol rate 0.2, # alpha 500) # taps if options.protocol == 1: # ---------- APCO-25 C4FM Test Data print "APCO selected" self.symbol_rate = 4800 # symbol rate if options.channel_decim is None: self.channel_decimation = 20 # decimation else: self.channel_decimation = options.channel_decim self.max_frequency_offset = 6000.0 # coarse carrier tracker leash self.symbol_deviation = 600.0 # this is frequency offset from center of channel to +1 / -1 symbols self.input_sample_rate = self.sample_rate self.protocol_processing = fsk4.apco25_f(self.msgq, 0) self.channel_rate = self.input_sample_rate / self.channel_decimation # channel selection filter if (options.data_file is not None) and (options.base_band == False): channel_taps = optfir.low_pass(1.0, # Filter gain self.input_sample_rate, # Sample rate 5000, # One-sided modulation bandwidth 6500, # One-sided channel bandwidth 0.2, # Passband ripple (was 0.1) 60) # Stopband attenuation else: channel_taps = None # symbol shaping filter symbol_coeffs = gr.firdes.root_raised_cosine (1.0, # gain self.channel_rate, # sampling rate self.symbol_rate, # symbol rate 0.2, # alpha 500) # taps # ----------------- End of setup block print "Input rate = " + str(self.input_sample_rate) print "Channel decimation = " + str(self.channel_decimation) print "Channel rate = " + str(self.channel_rate) if channel_taps is not None: self.chan = gr.freq_xlating_fir_filter_ccf(self.channel_decimation, # Decimation rate channel_taps, # Filter taps 0.0, # Offset frequency self.input_sample_rate) # Sample rate if (options.freq_translation != 0): print "Channel center frequency = " + str(options.freq_translation) self.chan.set_center_freq(options.freq_translation) else: self.chan = None if options.carrier_freq is not None: print "Carrier frequency = " + str(options.carrier_freq) self.sig_carrier = gr.sig_source_c(self.channel_rate, gr.GR_COS_WAVE, options.carrier_freq, 1, 0) self.carrier_mul = gr.multiply_vcc(1) # cc(gr.sizeof_gr_complex) self.connect(self.sig_carrier, (self.carrier_mul, 0)) self.connect(self.chan, (self.carrier_mul, 1)) self.sig_i_carrier = gr.sig_source_f(self.channel_rate, gr.GR_COS_WAVE, options.carrier_freq, 1, 0) self.sig_q_carrier = gr.sig_source_f(self.channel_rate, gr.GR_COS_WAVE, options.carrier_freq, 1, (pi / 2.0)) self.carrier_i_mul = gr.multiply_ff(1) self.carrier_q_mul = gr.multiply_ff(1) self.iq_to_float = gr.complex_to_float(1) self.carrier_iq_add = gr.add_ff(1) self.connect(self.carrier_mul, self.iq_to_float) self.connect((self.iq_to_float, 0), (self.carrier_i_mul, 0)) self.connect((self.iq_to_float, 1), (self.carrier_q_mul, 0)) self.connect(self.sig_i_carrier, (self.carrier_i_mul, 1)) self.connect(self.sig_q_carrier, (self.carrier_q_mul, 1)) self.connect(self.carrier_i_mul, (self.carrier_iq_add, 0)) self.connect(self.carrier_q_mul, (self.carrier_iq_add, 1)) else: self.sig_carrier = None self.carrier_mul = None #lf_channel_taps = optfir.low_pass(1.0, # Filter gain # self.input_sample_rate, # Sample rate # 2500, # One-sided modulation bandwidth # 3250, # One-sided channel bandwidth # 0.1, # Passband ripple (0.1) # 60, # Stopband attenuation # 9) # Extra taps (default 2, which doesn't work at 48kHz) #self.lf = gr.fir_filter_fff(self.channel_decimation, lf_channel_taps) self.scope2 = scopesink2.scope_sink_f(panel, sample_rate=self.symbol_rate, frame_decim=1, v_scale=2, t_scale=0.025, num_inputs=self.num_inputs) # also note: this specifies the nominal frequency deviation for the 4-level fsk signal self.fm_demod_gain = self.channel_rate / (2.0 * pi * self.symbol_deviation) self.fm_demod = gr.quadrature_demod_cf(self.fm_demod_gain) symbol_decim = 1 self.symbol_filter = gr.fir_filter_fff(symbol_decim, symbol_coeffs) # eventually specify: sample rate, symbol rate self.demod_fsk4 = fsk4.demod_ff(self.msgq, self.channel_rate, self.symbol_rate) if (self.chan is not None): self.connect(self.src, self.chan, self.fm_demod, self.symbol_filter, self.demod_fsk4, self.protocol_processing) if options.wav_out is not None: print "WAV output gain = " + str(options.wav_out_gain) self.scaled_wav_data = gr.multiply_const_ff(float(options.wav_out_gain)) self.connect(self.scaled_wav_data, self.wav_out) if self.carrier_mul is None: self.connect(self.fm_demod, self.scaled_wav_data) else: self.connect(self.carrier_iq_add, self.scaled_wav_data) if self.data_out is not None: if self.carrier_mul is None: self.connect(self.fm_demod, self.data_out) else: self.connect(self.carrier_mul, self.data_out) # During signal, -4..4 #self.connect(self.fm_demod, self.scope2) else: self.connect(self.src, self.symbol_filter, self.demod_fsk4, self.protocol_processing) self.connect(self.src, self.scope) #self.connect(self.lf, self.scope) self.connect(self.demod_fsk4, self.scope2) #self.connect(self.symbol_filter, self.scope2) # --------------- End of most of the 4L-FSK hack & slash self._build_gui(vbox) # set initial values if options.gain is None: options.gain = 0 self.set_gain(options.gain)
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="DVB Simulator (GMSK)") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.signal = signal = 1 self.samp_rate = samp_rate = 32000 self.noise = noise = 10 ################################################## # Blocks ################################################## _signal_sizer = wx.BoxSizer(wx.VERTICAL) self._signal_text_box = forms.text_box( parent=self.GetWin(), sizer=_signal_sizer, value=self.signal, callback=self.set_signal, label="Signal", converter=forms.float_converter(), proportion=0, ) self._signal_slider = forms.slider( parent=self.GetWin(), sizer=_signal_sizer, value=self.signal, callback=self.set_signal, minimum=0, maximum=1000, num_steps=1000, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_signal_sizer) _noise_sizer = wx.BoxSizer(wx.VERTICAL) self._noise_text_box = forms.text_box( parent=self.GetWin(), sizer=_noise_sizer, value=self.noise, callback=self.set_noise, label="Noise", converter=forms.float_converter(), proportion=0, ) self._noise_slider = forms.slider( parent=self.GetWin(), sizer=_noise_sizer, value=self.noise, callback=self.set_noise, minimum=0, maximum=1000, num_steps=1000, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_noise_sizer) self.gr_wavfile_source_0 = gr.wavfile_source("/home/traviscollins/GNURADIO/tfc_models/test.wav", False) self.gr_throttle_0 = gr.throttle(gr.sizeof_float*1, samp_rate) self.gr_noise_source_x_0 = gr.noise_source_c(gr.GR_GAUSSIAN, noise, 42) self.gr_multiply_const_vxx_0 = gr.multiply_const_vcc((signal, )) self.gr_file_sink_1_0 = gr.file_sink(gr.sizeof_float*1, "/home/traviscollins/GNURADIO/tfc_models/output_txt.wav") self.gr_file_sink_1_0.set_unbuffered(False) self.gr_channel_model_0 = gr.channel_model( noise_voltage=20, frequency_offset=0.0, epsilon=1.0, taps=(1.0 + 1.0j, ), noise_seed=42, ) self.gr_add_xx_0 = gr.add_vcc(1) self.digital_gmsk_mod_0 = digital.gmsk_mod( samples_per_symbol=2, bt=0.35, verbose=False, log=False, ) self.digital_gmsk_demod_0 = digital.gmsk_demod( samples_per_symbol=2, gain_mu=0.175, mu=0.5, omega_relative_limit=0.005, freq_error=0.0, verbose=False, log=False, ) self.blks2_packet_encoder_0 = grc_blks2.packet_mod_f(grc_blks2.packet_encoder( samples_per_symbol=2, bits_per_symbol=1, access_code="", pad_for_usrp=True, ), payload_length=0, ) self.blks2_packet_decoder_0 = grc_blks2.packet_demod_f(grc_blks2.packet_decoder( access_code="", threshold=-1, callback=lambda ok, payload: self.blks2_packet_decoder_0.recv_pkt(ok, payload), ), ) self.audio_sink_0 = audio.sink(samp_rate, "", True) ################################################## # Connections ################################################## self.connect((self.gr_noise_source_x_0, 0), (self.gr_add_xx_0, 1)) self.connect((self.gr_add_xx_0, 0), (self.digital_gmsk_demod_0, 0)) self.connect((self.blks2_packet_encoder_0, 0), (self.digital_gmsk_mod_0, 0)) self.connect((self.digital_gmsk_mod_0, 0), (self.gr_multiply_const_vxx_0, 0)) self.connect((self.gr_throttle_0, 0), (self.blks2_packet_encoder_0, 0)) self.connect((self.gr_throttle_0, 0), (self.gr_file_sink_1_0, 0)) self.connect((self.digital_gmsk_demod_0, 0), (self.blks2_packet_decoder_0, 0)) self.connect((self.gr_multiply_const_vxx_0, 0), (self.gr_channel_model_0, 0)) self.connect((self.gr_channel_model_0, 0), (self.gr_add_xx_0, 0)) self.connect((self.gr_wavfile_source_0, 0), (self.gr_throttle_0, 0)) self.connect((self.blks2_packet_decoder_0, 0), (self.audio_sink_0, 0))
def test_001_checkwavread (self): wf = gr.wavfile_source(g_in_file) self.assertEqual(wf.sample_rate(), 8000)
def __init__(self, frame, panel, vbox, argv): stdgui2.std_top_block.__init__(self, frame, panel, vbox, argv) self.frame = frame self.panel = panel self.offset = 0.0 # Channel frequency offset parser = OptionParser(option_class=eng_option) parser.add_option( "-p", "--protocol", type="int", default=1, help="set protocol: 0 = RDLAP 19.2kbps; 1 = APCO25 (default)") parser.add_option("-g", "--gain", type="eng_float", default=1.0, help="set linear input gain (default: %default)") parser.add_option("-x", "--freq-translation", type="eng_float", default=0.0, help="initial channel frequency translation") parser.add_option( "-n", "--frame-decim", type="int", default=1, help="set oscope frame decimation factor to n [default=1]") parser.add_option( "-v", "--v-scale", type="eng_float", default=5000, help="set oscope initial V/div to SCALE [default=%default]") parser.add_option( "-t", "--t-scale", type="eng_float", default=49e-6, help="set oscope initial s/div to SCALE [default=50us]") parser.add_option( "-I", "--audio-input", type="string", default="", help="pcm input device name. E.g., hw:0,0 or /dev/dsp") parser.add_option("-r", "--sample-rate", type="eng_float", default=48000, help="set sample rate to RATE (default: %default)") parser.add_option( "-d", "--channel-decim", type="int", default=None, help= "set channel decimation factor to n [default depends on protocol]") parser.add_option("-w", "--wav-file", type="string", default=None, help="WAV input path") parser.add_option("-f", "--data-file", type="string", default=None, help="Data input path") parser.add_option("-B", "--base-band", action="store_true", default=False) parser.add_option("-R", "--repeat", action="store_true", default=False) parser.add_option("-o", "--wav-out", type="string", default=None, help="WAV output path") parser.add_option("-G", "--wav-out-gain", type="eng_float", default=0.05, help="set WAV output gain (default: %default)") parser.add_option("-F", "--data-out", type="string", default=None, help="Data output path") parser.add_option("-C", "--carrier-freq", type="eng_float", default=None, help="set data output carrier frequency to FREQ", metavar="FREQ") (options, args) = parser.parse_args() if len(args) != 0: parser.print_help() sys.exit(1) self.options = options if options.wav_file is not None: #try: self.input_file = gr.wavfile_source(options.wav_file, options.repeat) #except: # print "WAV file not found or not a WAV file" # sys.exit(1) print "WAV input: %i Hz, %i bits, %i channels" % ( self.input_file.sample_rate(), self.input_file.bits_per_sample(), self.input_file.channels()) self.sample_rate = self.input_file.sample_rate() self.input_stream = gr.throttle(gr.sizeof_float, self.sample_rate) self.connect(self.input_file, self.input_stream) self.src = gr.multiply_const_ff(options.gain) elif options.data_file is not None: if options.base_band: sample_size = gr.sizeof_float print "Data file is baseband (float)" self.src = gr.multiply_const_ff(options.gain) else: sample_size = gr.sizeof_gr_complex print "Data file is IF (complex)" self.src = gr.multiply_const_cc(options.gain) self.input_file = gr.file_source(sample_size, options.data_file, options.repeat) self.sample_rate = options.sample_rate # E.g. 250000 print "Data file sampling rate = " + str(self.sample_rate) self.input_stream = gr.throttle(sample_size, self.sample_rate) self.connect(self.input_file, self.input_stream) else: self.sample_rate = options.sample_rate print "Soundcard sampling rate = " + str(self.sample_rate) self.input_stream = audio.source( self.sample_rate, options.audio_input) # float samples self.src = gr.multiply_const_ff(options.gain) print "Fixed input gain = " + str(options.gain) self.connect(self.input_stream, self.src) if options.wav_out is not None: output_rate = int(self.sample_rate) if options.channel_decim is not None: output_rate /= options.channel_decim self.wav_out = gr.wavfile_sink(options.wav_out, 1, output_rate, 16) print "Opened WAV output file: " + options.wav_out + " at rate: " + str( output_rate) else: self.wav_out = None if options.data_out is not None: if options.carrier_freq is None: self.data_out = gr.file_sink(gr.sizeof_float, options.data_out) print "Opened float data output file: " + options.data_out else: self.data_out = gr.file_sink(gr.sizeof_gr_complex, options.data_out) print "Opened complex data output file: " + options.data_out else: self.data_out = None self.num_inputs = 1 input_rate = self.sample_rate #title='IF', #size=(1024,800), if (options.data_file is not None) and (options.base_band == False): self.scope = scopesink2.scope_sink_c( panel, sample_rate=input_rate, frame_decim=options.frame_decim, v_scale=options.v_scale, t_scale=options.t_scale, num_inputs=self.num_inputs) else: self.scope = scopesink2.scope_sink_f( panel, sample_rate=input_rate, frame_decim=options.frame_decim, v_scale=options.v_scale, t_scale=options.t_scale, num_inputs=self.num_inputs) #self.di = gr.deinterleave(gr.sizeof_float) #self.di = gr.complex_to_float(1) #self.di = gr.complex_to_imag() #self.dr = gr.complex_to_real() #self.connect(self.src,self.dr) #self.connect(self.src,self.di) #self.null = gr.null_sink(gr.sizeof_double) #self.connect(self.src,self.di) #self.connect((self.di,0),(self.scope,0)) #self.connect((self.di,1),(self.scope,1)) #self.connect(self.dr,(self.scope,0)) #self.connect(self.di,(self.scope,1)) self.msgq = gr.msg_queue(2) # queue that holds a maximum of 2 messages self.queue_watcher = queue_watcher(self.msgq, self.adjust_freq_norm) #------------------------------------------------------------------------------- if options.protocol == 0: # ---------- RD-LAP 19.2 kbps (9600 ksps), 25kHz channel, print "RD-LAP selected" self.symbol_rate = 9600 # symbol rate; at 2 bits/symbol this corresponds to 19.2kbps if options.channel_decim is None: self.channel_decimation = 10 # decimation (final rate should be at least several symbol rate) else: self.channel_decimation = options.channel_decim self.max_frequency_offset = 12000.0 # coarse carrier tracker leash, ~ half a channel either way self.symbol_deviation = 1200.0 # this is frequency offset from center of channel to +1 / -1 symbols self.input_sample_rate = self.sample_rate self.protocol_processing = fsk4.rdlap_f( self.msgq, 0) # desired protocol processing block selected here self.channel_rate = self.input_sample_rate / self.channel_decimation # channel selection filter characteristics channel_taps = optfir.low_pass( 1.0, # Filter gain self.input_sample_rate, # Sample rate 10000, # One-sided modulation bandwidth 12000, # One-sided channel bandwidth 0.1, # Passband ripple 60) # Stopband attenuation # symbol shaping filter characteristics symbol_coeffs = gr.firdes.root_raised_cosine( 1.0, # gain self.channel_rate, # sampling rate self.symbol_rate, # symbol rate 0.2, # alpha 500) # taps if options.protocol == 1: # ---------- APCO-25 C4FM Test Data print "APCO selected" self.symbol_rate = 4800 # symbol rate if options.channel_decim is None: self.channel_decimation = 20 # decimation else: self.channel_decimation = options.channel_decim self.max_frequency_offset = 6000.0 # coarse carrier tracker leash self.symbol_deviation = 600.0 # this is frequency offset from center of channel to +1 / -1 symbols self.input_sample_rate = self.sample_rate self.protocol_processing = fsk4.apco25_f(self.msgq, 0) self.channel_rate = self.input_sample_rate / self.channel_decimation # channel selection filter if (options.data_file is not None) and (options.base_band == False): channel_taps = optfir.low_pass( 1.0, # Filter gain self.input_sample_rate, # Sample rate 5000, # One-sided modulation bandwidth 6500, # One-sided channel bandwidth 0.2, # Passband ripple (was 0.1) 60) # Stopband attenuation else: channel_taps = None # symbol shaping filter symbol_coeffs = gr.firdes.root_raised_cosine( 1.0, # gain self.channel_rate, # sampling rate self.symbol_rate, # symbol rate 0.2, # alpha 500) # taps # ----------------- End of setup block print "Input rate = " + str(self.input_sample_rate) print "Channel decimation = " + str(self.channel_decimation) print "Channel rate = " + str(self.channel_rate) if channel_taps is not None: self.chan = gr.freq_xlating_fir_filter_ccf( self.channel_decimation, # Decimation rate channel_taps, # Filter taps 0.0, # Offset frequency self.input_sample_rate) # Sample rate if (options.freq_translation != 0): print "Channel center frequency = " + str( options.freq_translation) self.chan.set_center_freq(options.freq_translation) else: self.chan = None if options.carrier_freq is not None: print "Carrier frequency = " + str(options.carrier_freq) self.sig_carrier = gr.sig_source_c(self.channel_rate, gr.GR_COS_WAVE, options.carrier_freq, 1, 0) self.carrier_mul = gr.multiply_vcc(1) # cc(gr.sizeof_gr_complex) self.connect(self.sig_carrier, (self.carrier_mul, 0)) self.connect(self.chan, (self.carrier_mul, 1)) self.sig_i_carrier = gr.sig_source_f(self.channel_rate, gr.GR_COS_WAVE, options.carrier_freq, 1, 0) self.sig_q_carrier = gr.sig_source_f(self.channel_rate, gr.GR_COS_WAVE, options.carrier_freq, 1, (pi / 2.0)) self.carrier_i_mul = gr.multiply_ff(1) self.carrier_q_mul = gr.multiply_ff(1) self.iq_to_float = gr.complex_to_float(1) self.carrier_iq_add = gr.add_ff(1) self.connect(self.carrier_mul, self.iq_to_float) self.connect((self.iq_to_float, 0), (self.carrier_i_mul, 0)) self.connect((self.iq_to_float, 1), (self.carrier_q_mul, 0)) self.connect(self.sig_i_carrier, (self.carrier_i_mul, 1)) self.connect(self.sig_q_carrier, (self.carrier_q_mul, 1)) self.connect(self.carrier_i_mul, (self.carrier_iq_add, 0)) self.connect(self.carrier_q_mul, (self.carrier_iq_add, 1)) else: self.sig_carrier = None self.carrier_mul = None #lf_channel_taps = optfir.low_pass(1.0, # Filter gain # self.input_sample_rate, # Sample rate # 2500, # One-sided modulation bandwidth # 3250, # One-sided channel bandwidth # 0.1, # Passband ripple (0.1) # 60, # Stopband attenuation # 9) # Extra taps (default 2, which doesn't work at 48kHz) #self.lf = gr.fir_filter_fff(self.channel_decimation, lf_channel_taps) self.scope2 = scopesink2.scope_sink_f(panel, sample_rate=self.symbol_rate, frame_decim=1, v_scale=2, t_scale=0.025, num_inputs=self.num_inputs) # also note: this specifies the nominal frequency deviation for the 4-level fsk signal self.fm_demod_gain = self.channel_rate / (2.0 * pi * self.symbol_deviation) self.fm_demod = gr.quadrature_demod_cf(self.fm_demod_gain) symbol_decim = 1 self.symbol_filter = gr.fir_filter_fff(symbol_decim, symbol_coeffs) # eventually specify: sample rate, symbol rate self.demod_fsk4 = fsk4.demod_ff(self.msgq, self.channel_rate, self.symbol_rate) if (self.chan is not None): self.connect(self.src, self.chan, self.fm_demod, self.symbol_filter, self.demod_fsk4, self.protocol_processing) if options.wav_out is not None: print "WAV output gain = " + str(options.wav_out_gain) self.scaled_wav_data = gr.multiply_const_ff( float(options.wav_out_gain)) self.connect(self.scaled_wav_data, self.wav_out) if self.carrier_mul is None: self.connect(self.fm_demod, self.scaled_wav_data) else: self.connect(self.carrier_iq_add, self.scaled_wav_data) if self.data_out is not None: if self.carrier_mul is None: self.connect(self.fm_demod, self.data_out) else: self.connect(self.carrier_mul, self.data_out) # During signal, -4..4 #self.connect(self.fm_demod, self.scope2) else: self.connect(self.src, self.symbol_filter, self.demod_fsk4, self.protocol_processing) self.connect(self.src, self.scope) #self.connect(self.lf, self.scope) self.connect(self.demod_fsk4, self.scope2) #self.connect(self.symbol_filter, self.scope2) # --------------- End of most of the 4L-FSK hack & slash self._build_gui(vbox) # set initial values if options.gain is None: options.gain = 0 self.set_gain(options.gain)
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("-T", "--tx-subdev-spec", type="subdev", default=None, help="select USRP Tx side A or B") parser.add_option("-f", "--freq", type="eng_float", default=107.2e6, help="set Tx frequency to FREQ [required]", metavar="FREQ") parser.add_option("--wavfile", type="string", default="", help="read input from FILE") (options, args) = parser.parse_args() if len(args) != 0: parser.print_help() sys.exit(1) self.usrp_interp = 200 self.u = usrp.sink_c (0, self.usrp_interp) print "USRP Serial: ", self.u.serial_number() self.dac_rate = self.u.dac_rate() # 128 MS/s self.usrp_rate = self.dac_rate / self.usrp_interp # 640 kS/s self.sw_interp = 5 self.audio_rate = self.usrp_rate / self.sw_interp # 128 kS/s # determine the daughterboard subdevice we're using if options.tx_subdev_spec is None: options.tx_subdev_spec = usrp.pick_tx_subdevice(self.u) self.u.set_mux(usrp.determine_tx_mux_value(self.u, options.tx_subdev_spec)) self.subdev = usrp.selected_subdev(self.u, options.tx_subdev_spec) print "Using d'board: ", self.subdev.side_and_name() # set max Tx gain, tune frequency and enable transmitter self.subdev.set_gain(self.subdev.gain_range()[1]) if self.u.tune(self.subdev.which(), self.subdev, options.freq): print "Tuned to", options.freq/1e6, "MHz" else: sys.exit(1) self.subdev.set_enable(True) # open wav file containing floats in the [-1, 1] range, repeat if options.wavfile is None: print "Please provide a wavfile to transmit! Exiting\n" sys.exit(1) self.src = gr.wavfile_source (options.wavfile, True) nchans = self.src.channels() sample_rate = self.src.sample_rate() bits_per_sample = self.src.bits_per_sample() print nchans, "channels,", sample_rate, "kS/s,", bits_per_sample, "bits/sample" # resample to 128kS/s if sample_rate == 44100: self.resample_left = blks2.rational_resampler_fff(32,11) self.resample_right = blks2.rational_resampler_fff(32,11) elif sample_rate == 48000: self.resample_left == blks2.rational_resampler_fff(8,3) self.resample_right == blks2.rational_resampler_fff(8,3) elif sample_rate == 8000: self.resample_left == blks2.rational_resampler_fff(16,1) self.resample_right == blks2.rational_resampler_fff(16,1) else: print sample_rate, "is an unsupported sample rate" sys.exit(1) self.connect ((self.src, 0), self.resample_left) self.connect ((self.src, 1), self.resample_right) # create L+R (mono) and L-R (stereo) self.audio_lpr = gr.add_ff() self.audio_lmr = gr.sub_ff() self.connect (self.resample_left, (self.audio_lpr, 0)) self.connect (self.resample_left, (self.audio_lmr, 0)) self.connect (self.resample_right, (self.audio_lpr, 1)) self.connect (self.resample_right, (self.audio_lmr, 1)) # low-pass filter for L+R audio_lpr_taps = gr.firdes.low_pass (0.3, # gain self.audio_rate, # sampling rate 15e3, # passband cutoff 2e3, # transition width gr.firdes.WIN_HANN) self.audio_lpr_filter = gr.fir_filter_fff (1, audio_lpr_taps) self.connect (self.audio_lpr, self.audio_lpr_filter) # create pilot tone at 19 kHz self.pilot = gr.sig_source_f(self.audio_rate, # sampling freq gr.GR_SIN_WAVE, # waveform 19e3, # frequency 3e-2) # amplitude # create the L-R signal carrier at 38 kHz, high-pass to remove 0Hz tone self.stereo_carrier = gr.multiply_ff() self.connect (self.pilot, (self.stereo_carrier, 0)) self.connect (self.pilot, (self.stereo_carrier, 1)) stereo_carrier_taps = gr.firdes.high_pass (1, # gain self.audio_rate, # sampling rate 1e4, # cutoff freq 2e3, # transition width gr.firdes.WIN_HANN) self.stereo_carrier_filter = gr.fir_filter_fff(1, stereo_carrier_taps) self.connect (self.stereo_carrier, self.stereo_carrier_filter) # upconvert L-R to 23-53 kHz and band-pass self.mix_stereo = gr.multiply_ff() audio_lmr_taps = gr.firdes.band_pass (3e3, # gain self.audio_rate, # sampling rate 23e3, # low cutoff 53e3, # high cuttof 2e3, # transition width gr.firdes.WIN_HANN) self.audio_lmr_filter = gr.fir_filter_fff (1, audio_lmr_taps) self.connect (self.audio_lmr, (self.mix_stereo, 0)) self.connect (self.stereo_carrier_filter, (self.mix_stereo, 1)) self.connect (self.mix_stereo, self.audio_lmr_filter) # mix L+R, pilot and L-R self.mixer = gr.add_ff() self.connect (self.audio_lpr_filter, (self.mixer, 0)) self.connect (self.pilot, (self.mixer, 1)) self.connect (self.audio_lmr_filter, (self.mixer, 2)) # interpolation & pre-emphasis interp_taps = gr.firdes.low_pass (self.sw_interp, # gain self.audio_rate, # Fs 60e3, # cutoff freq 5e3, # transition width gr.firdes.WIN_HAMMING) self.interpolator = gr.interp_fir_filter_fff (self.sw_interp, interp_taps) self.pre_emph = blks2.fm_preemph(self.usrp_rate, tau=50e-6) self.connect (self.mixer, self.interpolator, self.pre_emph) # fm modulation, gain & TX max_dev = 100e3 k = 2 * math.pi * max_dev / self.usrp_rate # modulator sensitivity self.modulator = gr.frequency_modulator_fc (k) self.gain = gr.multiply_const_cc (1e3) self.connect (self.pre_emph, self.modulator, self.gain, self.u) # plot an FFT to verify we are sending what we want pre_mod = fftsink2.fft_sink_f(panel, title="Before Interpolation", fft_size=512, sample_rate=self.audio_rate, y_per_div=20, ref_level=20) self.connect (self.mixer, pre_mod) vbox.Add (pre_mod.win, 1, wx.EXPAND)
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("-T", "--tx-subdev-spec", type="subdev", default=None, help="select USRP Tx side A or B") parser.add_option("-f", "--freq", type="eng_float", default=107.2e6, help="set Tx frequency to FREQ [required]", metavar="FREQ") parser.add_option("--wavfile", type="string", default=None, help="open .wav audio file FILE") parser.add_option("--xml", type="string", default="rds_data.xml", help="open .xml RDS data FILE") (options, args) = parser.parse_args() if len(args) != 0: parser.print_help() sys.exit(1) usrp_interp = 500 self.u = usrp.sink_c(0, usrp_interp) print "USRP Serial: ", self.u.serial_number() usrp_rate = self.u.dac_rate() / usrp_interp # 256 kS/s # determine the daughterboard subdevice we're using if options.tx_subdev_spec is None: options.tx_subdev_spec = usrp.pick_tx_subdevice(self.u) self.u.set_mux( usrp.determine_tx_mux_value(self.u, options.tx_subdev_spec)) self.subdev = usrp.selected_subdev(self.u, options.tx_subdev_spec) print "Using d'board", self.subdev.side_and_name() # set max Tx gain, tune frequency and enable transmitter gain = self.subdev.gain_range()[1] self.subdev.set_gain(gain) print "Gain set to", gain if self.u.tune(self.subdev.which(), self.subdev, options.freq): print "Tuned to", options.freq / 1e6, "MHz" else: sys.exit(1) self.subdev.set_enable(True) # open wav file containing floats in the [-1, 1] range, repeat if options.wavfile is None: print "Please provide a wavfile to transmit! Exiting\n" sys.exit(1) self.src = gr.wavfile_source(options.wavfile, True) nchans = self.src.channels() sample_rate = self.src.sample_rate() bits_per_sample = self.src.bits_per_sample() print nchans, "channels,", sample_rate, "samples/sec,", \ bits_per_sample, "bits/sample" # resample to usrp rate self.resample_left = blks2.rational_resampler_fff( usrp_rate, sample_rate) self.resample_right = blks2.rational_resampler_fff( usrp_rate, sample_rate) self.connect((self.src, 0), self.resample_left) self.connect((self.src, 1), self.resample_right) # create L+R (mono) and L-R (stereo) self.audio_lpr = gr.add_ff() self.audio_lmr = gr.sub_ff() self.connect(self.resample_left, (self.audio_lpr, 0)) self.connect(self.resample_left, (self.audio_lmr, 0)) self.connect(self.resample_right, (self.audio_lpr, 1)) self.connect(self.resample_right, (self.audio_lmr, 1)) # low-pass filter for L+R audio_lpr_taps = gr.firdes.low_pass( 0.5, # gain usrp_rate, # sampling rate 15e3, # passband cutoff 1e3, # transition width gr.firdes.WIN_HAMMING) self.audio_lpr_filter = gr.fir_filter_fff(1, audio_lpr_taps) self.connect(self.audio_lpr, self.audio_lpr_filter) # create pilot tone at 19 kHz self.pilot = gr.sig_source_f( usrp_rate, # sampling rate gr.GR_SIN_WAVE, # waveform 19e3, # frequency 5e-2) # amplitude # upconvert L-R to 38 kHz and band-pass self.mix_stereo = gr.multiply_ff() audio_lmr_taps = gr.firdes.band_pass( 80, # gain usrp_rate, # sampling rate 38e3 - 15e3, # low cutoff 38e3 + 15e3, # high cutoff 1e3, # transition width gr.firdes.WIN_HAMMING) self.audio_lmr_filter = gr.fir_filter_fff(1, audio_lmr_taps) self.connect(self.audio_lmr, (self.mix_stereo, 0)) self.connect(self.pilot, (self.mix_stereo, 1)) self.connect(self.pilot, (self.mix_stereo, 2)) self.connect(self.mix_stereo, self.audio_lmr_filter) # create RDS bitstream # diff-encode, manchester-emcode, NRZ # enforce the 1187.5bps rate # pulse shaping filter (matched with receiver) # mix with 57kHz carrier (equivalent to BPSK) self.rds_enc = rds.data_encoder('rds_data.xml') self.diff_enc = gr.diff_encoder_bb(2) self.manchester1 = gr.map_bb([1, 2]) self.manchester2 = gr.unpack_k_bits_bb(2) self.nrz = gr.map_bb([-1, 1]) self.c2f = gr.char_to_float() self.rate_enforcer = rds.rate_enforcer(usrp_rate) pulse_shaping_taps = gr.firdes.low_pass( 1, # gain usrp_rate, # sampling rate 1.5e3, # passband cutoff 2e3, # transition width gr.firdes.WIN_HAMMING) self.pulse_shaping = gr.fir_filter_fff(1, pulse_shaping_taps) self.bpsk_mod = gr.multiply_ff() self.connect (self.rds_enc, self.diff_enc, self.manchester1, \ self.manchester2, self.nrz, self.c2f) self.connect(self.c2f, (self.rate_enforcer, 0)) self.connect(self.pilot, (self.rate_enforcer, 1)) self.connect(self.rate_enforcer, (self.bpsk_mod, 0)) self.connect(self.pilot, (self.bpsk_mod, 1)) self.connect(self.pilot, (self.bpsk_mod, 2)) self.connect(self.pilot, (self.bpsk_mod, 3)) # RDS band-pass filter rds_filter_taps = gr.firdes.band_pass( 50, # gain usrp_rate, # sampling rate 57e3 - 3e3, # low cutoff 57e3 + 3e3, # high cutoff 1e3, # transition width gr.firdes.WIN_HAMMING) self.rds_filter = gr.fir_filter_fff(1, rds_filter_taps) self.connect(self.bpsk_mod, self.rds_filter) # mix L+R, pilot, L-R and RDS self.mixer = gr.add_ff() self.connect(self.audio_lpr_filter, (self.mixer, 0)) self.connect(self.pilot, (self.mixer, 1)) self.connect(self.audio_lmr_filter, (self.mixer, 2)) self.connect(self.rds_filter, (self.mixer, 3)) # fm modulation, gain & TX max_dev = 75e3 k = 2 * math.pi * max_dev / usrp_rate # modulator sensitivity self.modulator = gr.frequency_modulator_fc(k) self.gain = gr.multiply_const_cc(5e3) self.connect(self.mixer, self.modulator, self.gain, self.u) # plot an FFT to verify we are sending what we want if 1: self.fft = fftsink2.fft_sink_f(panel, title="Pre FM modulation", fft_size=512 * 4, sample_rate=usrp_rate, y_per_div=20, ref_level=-20) self.connect(self.mixer, self.fft) vbox.Add(self.fft.win, 1, wx.EXPAND) if 0: self.scope = scopesink2.scope_sink_f(panel, title="RDS encoder output", sample_rate=usrp_rate) self.connect(self.rds_enc, self.scope) vbox.Add(self.scope.win, 1, wx.EXPAND)
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("-T", "--tx-subdev-spec", type="subdev", default=None, help="select USRP Tx side A or B") parser.add_option("-f", "--freq", type="eng_float", default=107.2e6, help="set Tx frequency to FREQ [required]", metavar="FREQ") parser.add_option("-i", "--filename", type="string", default="", help="read input from FILE") (options, args) = parser.parse_args() if len(args) != 0: parser.print_help() sys.exit(1) self.u = usrp.sink_c () self.dac_rate = self.u.dac_rate() # 128 MS/s self.usrp_interp = 400 self.u.set_interp_rate(self.usrp_interp) self.usrp_rate = self.dac_rate / self.usrp_interp # 320 kS/s self.sw_interp = 10 self.audio_rate = self.usrp_rate / self.sw_interp # 32 kS/s # determine the daughterboard subdevice we're using if options.tx_subdev_spec is None: options.tx_subdev_spec = usrp.pick_tx_subdevice(self.u) self.u.set_mux(usrp.determine_tx_mux_value(self.u, options.tx_subdev_spec)) self.subdev = usrp.selected_subdev(self.u, options.tx_subdev_spec) print "Using TX d'board %s" % (self.subdev.side_and_name(),) # set max Tx gain, tune frequency and enable transmitter self.subdev.set_gain(self.subdev.gain_range()[1]) self.u.tune(self.subdev._which, self.subdev, options.freq) self.subdev.set_enable(True) # open file containing floats in the [-1, 1] range, repeat self.src = gr.wavfile_source (options.filename, True) nchans = self.src.channels() sample_rate = self.src.sample_rate() bits_per_sample = self.src.bits_per_sample() print nchans, "channels,", sample_rate, "kS/s,", bits_per_sample, "bits/sample" # resample to 32kS/s if sample_rate == 44100: self.resample = blks2.rational_resampler_fff(8,11) elif sample_rate == 48000: self.resample == blks2.rational_resampler_fff(2,3) else: print sample_rate, "is an unsupported sample rate" exit() # interpolation, preemphasis, fm modulation & gain self.fmtx = blks2.wfm_tx (self.audio_rate, self.usrp_rate, tau=75e-6, max_dev=15e3) self.gain = gr.multiply_const_cc (4e3) # connect it all self.connect (self.src, self.resample, self.fmtx, self.gain, self.u) # plot an FFT to verify we are sending what we want pre_mod = fftsink2.fft_sink_f(panel, title="Pre-Modulation", fft_size=512, sample_rate=self.usrp_rate, y_per_div=10, ref_level=0) self.connect (self.emph, pre_mod) vbox.Add (pre_mod.win, 1, wx.EXPAND)
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("-T", "--tx-subdev-spec", type="subdev", default=None, help="select USRP Tx side A or B") parser.add_option("-f", "--freq", type="eng_float", default=107.2e6, help="set Tx frequency to FREQ [required]", metavar="FREQ") parser.add_option("--wavfile", type="string", default="", help="read input from FILE") (options, args) = parser.parse_args() if len(args) != 0: parser.print_help() sys.exit(1) self.usrp_interp = 200 self.u = usrp.sink_c(0, self.usrp_interp) print "USRP Serial: ", self.u.serial_number() self.dac_rate = self.u.dac_rate() # 128 MS/s self.usrp_rate = self.dac_rate / self.usrp_interp # 640 kS/s self.sw_interp = 5 self.audio_rate = self.usrp_rate / self.sw_interp # 128 kS/s # determine the daughterboard subdevice we're using if options.tx_subdev_spec is None: options.tx_subdev_spec = usrp.pick_tx_subdevice(self.u) self.u.set_mux( usrp.determine_tx_mux_value(self.u, options.tx_subdev_spec)) self.subdev = usrp.selected_subdev(self.u, options.tx_subdev_spec) print "Using d'board: ", self.subdev.side_and_name() # set max Tx gain, tune frequency and enable transmitter self.subdev.set_gain(self.subdev.gain_range()[1]) if self.u.tune(self.subdev.which(), self.subdev, options.freq): print "Tuned to", options.freq / 1e6, "MHz" else: sys.exit(1) self.subdev.set_enable(True) # open wav file containing floats in the [-1, 1] range, repeat if options.wavfile is None: print "Please provide a wavfile to transmit! Exiting\n" sys.exit(1) self.src = gr.wavfile_source(options.wavfile, True) nchans = self.src.channels() sample_rate = self.src.sample_rate() bits_per_sample = self.src.bits_per_sample() print nchans, "channels,", sample_rate, "kS/s,", bits_per_sample, "bits/sample" # resample to 128kS/s if sample_rate == 44100: self.resample_left = blks2.rational_resampler_fff(32, 11) self.resample_right = blks2.rational_resampler_fff(32, 11) elif sample_rate == 48000: self.resample_left == blks2.rational_resampler_fff(8, 3) self.resample_right == blks2.rational_resampler_fff(8, 3) elif sample_rate == 8000: self.resample_left == blks2.rational_resampler_fff(16, 1) self.resample_right == blks2.rational_resampler_fff(16, 1) else: print sample_rate, "is an unsupported sample rate" sys.exit(1) self.connect((self.src, 0), self.resample_left) self.connect((self.src, 1), self.resample_right) # create L+R (mono) and L-R (stereo) self.audio_lpr = gr.add_ff() self.audio_lmr = gr.sub_ff() self.connect(self.resample_left, (self.audio_lpr, 0)) self.connect(self.resample_left, (self.audio_lmr, 0)) self.connect(self.resample_right, (self.audio_lpr, 1)) self.connect(self.resample_right, (self.audio_lmr, 1)) # low-pass filter for L+R audio_lpr_taps = gr.firdes.low_pass( 0.3, # gain self.audio_rate, # sampling rate 15e3, # passband cutoff 2e3, # transition width gr.firdes.WIN_HANN) self.audio_lpr_filter = gr.fir_filter_fff(1, audio_lpr_taps) self.connect(self.audio_lpr, self.audio_lpr_filter) # create pilot tone at 19 kHz self.pilot = gr.sig_source_f( self.audio_rate, # sampling freq gr.GR_SIN_WAVE, # waveform 19e3, # frequency 3e-2) # amplitude # create the L-R signal carrier at 38 kHz, high-pass to remove 0Hz tone self.stereo_carrier = gr.multiply_ff() self.connect(self.pilot, (self.stereo_carrier, 0)) self.connect(self.pilot, (self.stereo_carrier, 1)) stereo_carrier_taps = gr.firdes.high_pass( 1, # gain self.audio_rate, # sampling rate 1e4, # cutoff freq 2e3, # transition width gr.firdes.WIN_HANN) self.stereo_carrier_filter = gr.fir_filter_fff(1, stereo_carrier_taps) self.connect(self.stereo_carrier, self.stereo_carrier_filter) # upconvert L-R to 23-53 kHz and band-pass self.mix_stereo = gr.multiply_ff() audio_lmr_taps = gr.firdes.band_pass( 3e3, # gain self.audio_rate, # sampling rate 23e3, # low cutoff 53e3, # high cuttof 2e3, # transition width gr.firdes.WIN_HANN) self.audio_lmr_filter = gr.fir_filter_fff(1, audio_lmr_taps) self.connect(self.audio_lmr, (self.mix_stereo, 0)) self.connect(self.stereo_carrier_filter, (self.mix_stereo, 1)) self.connect(self.mix_stereo, self.audio_lmr_filter) # mix L+R, pilot and L-R self.mixer = gr.add_ff() self.connect(self.audio_lpr_filter, (self.mixer, 0)) self.connect(self.pilot, (self.mixer, 1)) self.connect(self.audio_lmr_filter, (self.mixer, 2)) # interpolation & pre-emphasis interp_taps = gr.firdes.low_pass( self.sw_interp, # gain self.audio_rate, # Fs 60e3, # cutoff freq 5e3, # transition width gr.firdes.WIN_HAMMING) self.interpolator = gr.interp_fir_filter_fff(self.sw_interp, interp_taps) self.pre_emph = blks2.fm_preemph(self.usrp_rate, tau=50e-6) self.connect(self.mixer, self.interpolator, self.pre_emph) # fm modulation, gain & TX max_dev = 100e3 k = 2 * math.pi * max_dev / self.usrp_rate # modulator sensitivity self.modulator = gr.frequency_modulator_fc(k) self.gain = gr.multiply_const_cc(1e3) self.connect(self.pre_emph, self.modulator, self.gain, self.u) # plot an FFT to verify we are sending what we want pre_mod = fftsink2.fft_sink_f(panel, title="Before Interpolation", fft_size=512, sample_rate=self.audio_rate, y_per_div=20, ref_level=20) self.connect(self.mixer, pre_mod) vbox.Add(pre_mod.win, 1, wx.EXPAND)
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Rds Tx") _icon_path = "/home/azimout/.local/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.usrp_interp = usrp_interp = 500 self.dac_rate = dac_rate = 128e6 self.wav_rate = wav_rate = 44100 self.usrp_rate = usrp_rate = int(dac_rate / usrp_interp) self.fm_max_dev = fm_max_dev = 120e3 ################################################## # Blocks ################################################## self.band_pass_filter_0 = gr.interp_fir_filter_fff( 1, firdes.band_pass(1, usrp_rate, 54e3, 60e3, 3e3, firdes.WIN_HAMMING, 6.76)) self.band_pass_filter_1 = gr.interp_fir_filter_fff( 1, firdes.band_pass(1, usrp_rate, 23e3, 53e3, 2e3, firdes.WIN_HAMMING, 6.76)) self.blks2_rational_resampler_xxx_1 = blks2.rational_resampler_fff( interpolation=usrp_rate, decimation=wav_rate, taps=None, fractional_bw=None, ) self.blks2_rational_resampler_xxx_1_0 = blks2.rational_resampler_fff( interpolation=usrp_rate, decimation=wav_rate, taps=None, fractional_bw=None, ) self.gr_add_xx_0 = gr.add_vff(1) self.gr_add_xx_1 = gr.add_vff(1) self.gr_char_to_float_0 = gr.char_to_float() self.gr_diff_encoder_bb_0 = gr.diff_encoder_bb(2) self.gr_frequency_modulator_fc_0 = gr.frequency_modulator_fc( 2 * math.pi * fm_max_dev / usrp_rate) self.gr_map_bb_0 = gr.map_bb(([-1, 1])) self.gr_map_bb_1 = gr.map_bb(([1, 2])) self.gr_multiply_xx_0 = gr.multiply_vff(1) self.gr_multiply_xx_1 = gr.multiply_vff(1) self.gr_rds_data_encoder_0 = rds.data_encoder( "/media/dimitris/mywork/gr/dimitris/rds/trunk/src/test/rds_data.xml" ) self.gr_rds_rate_enforcer_0 = rds.rate_enforcer(256000) self.gr_sig_source_x_0 = gr.sig_source_f(usrp_rate, gr.GR_COS_WAVE, 19e3, 0.3, 0) self.gr_sub_xx_0 = gr.sub_ff(1) self.gr_unpack_k_bits_bb_0 = gr.unpack_k_bits_bb(2) self.gr_wavfile_source_0 = gr.wavfile_source( "/media/dimitris/mywork/gr/dimitris/rds/trunk/src/python/limmenso_stereo.wav", True) self.low_pass_filter_0 = gr.interp_fir_filter_fff( 1, firdes.low_pass(1, usrp_rate, 1.5e3, 2e3, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_0_0 = gr.interp_fir_filter_fff( 1, firdes.low_pass(1, usrp_rate, 15e3, 2e3, firdes.WIN_HAMMING, 6.76)) self.usrp_simple_sink_x_0 = grc_usrp.simple_sink_c(which=0, side="A") self.usrp_simple_sink_x_0.set_interp_rate(500) self.usrp_simple_sink_x_0.set_frequency(107.2e6, verbose=True) self.usrp_simple_sink_x_0.set_gain(0) self.usrp_simple_sink_x_0.set_enable(True) self.usrp_simple_sink_x_0.set_auto_tr(True) self.wxgui_fftsink2_0 = fftsink2.fft_sink_f( self.GetWin(), baseband_freq=0, y_per_div=20, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=usrp_rate, fft_size=1024, fft_rate=30, average=False, avg_alpha=None, title="FFT Plot", peak_hold=False, ) self.Add(self.wxgui_fftsink2_0.win) ################################################## # Connections ################################################## self.connect((self.gr_sig_source_x_0, 0), (self.gr_rds_rate_enforcer_0, 1)) self.connect((self.gr_char_to_float_0, 0), (self.gr_rds_rate_enforcer_0, 0)) self.connect((self.gr_map_bb_0, 0), (self.gr_char_to_float_0, 0)) self.connect((self.gr_frequency_modulator_fc_0, 0), (self.usrp_simple_sink_x_0, 0)) self.connect((self.gr_add_xx_1, 0), (self.gr_frequency_modulator_fc_0, 0)) self.connect((self.gr_sig_source_x_0, 0), (self.gr_add_xx_1, 1)) self.connect((self.gr_sub_xx_0, 0), (self.gr_multiply_xx_1, 2)) self.connect((self.gr_sig_source_x_0, 0), (self.gr_multiply_xx_1, 1)) self.connect((self.gr_sig_source_x_0, 0), (self.gr_multiply_xx_1, 0)) self.connect((self.gr_sig_source_x_0, 0), (self.gr_multiply_xx_0, 3)) self.connect((self.gr_sig_source_x_0, 0), (self.gr_multiply_xx_0, 2)) self.connect((self.blks2_rational_resampler_xxx_1_0, 0), (self.gr_add_xx_0, 1)) self.connect((self.blks2_rational_resampler_xxx_1, 0), (self.gr_add_xx_0, 0)) self.connect((self.blks2_rational_resampler_xxx_1_0, 0), (self.gr_sub_xx_0, 1)) self.connect((self.blks2_rational_resampler_xxx_1, 0), (self.gr_sub_xx_0, 0)) self.connect((self.gr_wavfile_source_0, 1), (self.blks2_rational_resampler_xxx_1_0, 0)) self.connect((self.gr_wavfile_source_0, 0), (self.blks2_rational_resampler_xxx_1, 0)) self.connect((self.gr_rds_data_encoder_0, 0), (self.gr_diff_encoder_bb_0, 0)) self.connect((self.gr_diff_encoder_bb_0, 0), (self.gr_map_bb_1, 0)) self.connect((self.gr_map_bb_1, 0), (self.gr_unpack_k_bits_bb_0, 0)) self.connect((self.gr_unpack_k_bits_bb_0, 0), (self.gr_map_bb_0, 0)) self.connect((self.gr_rds_rate_enforcer_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.gr_multiply_xx_0, 0)) self.connect((self.gr_multiply_xx_0, 0), (self.band_pass_filter_0, 0)) self.connect((self.band_pass_filter_0, 0), (self.gr_add_xx_1, 0)) self.connect((self.gr_multiply_xx_1, 0), (self.band_pass_filter_1, 0)) self.connect((self.band_pass_filter_1, 0), (self.gr_add_xx_1, 3)) self.connect((self.gr_add_xx_1, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.gr_sig_source_x_0, 0), (self.gr_multiply_xx_0, 1)) self.connect((self.gr_add_xx_0, 0), (self.low_pass_filter_0_0, 0)) self.connect((self.low_pass_filter_0_0, 0), (self.gr_add_xx_1, 2))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Rds Tx") _icon_path = "/home/azimout/.local/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.usrp_interp = usrp_interp = 500 self.dac_rate = dac_rate = 128e6 self.wav_rate = wav_rate = 44100 self.usrp_rate = usrp_rate = int(dac_rate/usrp_interp) self.fm_max_dev = fm_max_dev = 120e3 ################################################## # Blocks ################################################## self.band_pass_filter_0 = gr.interp_fir_filter_fff(1, firdes.band_pass( 1, usrp_rate, 54e3, 60e3, 3e3, firdes.WIN_HAMMING, 6.76)) self.band_pass_filter_1 = gr.interp_fir_filter_fff(1, firdes.band_pass( 1, usrp_rate, 23e3, 53e3, 2e3, firdes.WIN_HAMMING, 6.76)) self.blks2_rational_resampler_xxx_1 = blks2.rational_resampler_fff( interpolation=usrp_rate, decimation=wav_rate, taps=None, fractional_bw=None, ) self.blks2_rational_resampler_xxx_1_0 = blks2.rational_resampler_fff( interpolation=usrp_rate, decimation=wav_rate, taps=None, fractional_bw=None, ) self.gr_add_xx_0 = gr.add_vff(1) self.gr_add_xx_1 = gr.add_vff(1) self.gr_char_to_float_0 = gr.char_to_float() self.gr_diff_encoder_bb_0 = gr.diff_encoder_bb(2) self.gr_frequency_modulator_fc_0 = gr.frequency_modulator_fc(2*math.pi*fm_max_dev/usrp_rate) self.gr_map_bb_0 = gr.map_bb(([-1,1])) self.gr_map_bb_1 = gr.map_bb(([1,2])) self.gr_multiply_xx_0 = gr.multiply_vff(1) self.gr_multiply_xx_1 = gr.multiply_vff(1) self.gr_rds_data_encoder_0 = rds.data_encoder("/media/dimitris/mywork/gr/dimitris/rds/trunk/src/test/rds_data.xml") self.gr_rds_rate_enforcer_0 = rds.rate_enforcer(256000) self.gr_sig_source_x_0 = gr.sig_source_f(usrp_rate, gr.GR_COS_WAVE, 19e3, 0.3, 0) self.gr_sub_xx_0 = gr.sub_ff(1) self.gr_unpack_k_bits_bb_0 = gr.unpack_k_bits_bb(2) self.gr_wavfile_source_0 = gr.wavfile_source("/media/dimitris/mywork/gr/dimitris/rds/trunk/src/python/limmenso_stereo.wav", True) self.low_pass_filter_0 = gr.interp_fir_filter_fff(1, firdes.low_pass( 1, usrp_rate, 1.5e3, 2e3, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_0_0 = gr.interp_fir_filter_fff(1, firdes.low_pass( 1, usrp_rate, 15e3, 2e3, firdes.WIN_HAMMING, 6.76)) self.usrp_simple_sink_x_0 = grc_usrp.simple_sink_c(which=0, side="A") self.usrp_simple_sink_x_0.set_interp_rate(500) self.usrp_simple_sink_x_0.set_frequency(107.2e6, verbose=True) self.usrp_simple_sink_x_0.set_gain(0) self.usrp_simple_sink_x_0.set_enable(True) self.usrp_simple_sink_x_0.set_auto_tr(True) self.wxgui_fftsink2_0 = fftsink2.fft_sink_f( self.GetWin(), baseband_freq=0, y_per_div=20, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=usrp_rate, fft_size=1024, fft_rate=30, average=False, avg_alpha=None, title="FFT Plot", peak_hold=False, ) self.Add(self.wxgui_fftsink2_0.win) ################################################## # Connections ################################################## self.connect((self.gr_sig_source_x_0, 0), (self.gr_rds_rate_enforcer_0, 1)) self.connect((self.gr_char_to_float_0, 0), (self.gr_rds_rate_enforcer_0, 0)) self.connect((self.gr_map_bb_0, 0), (self.gr_char_to_float_0, 0)) self.connect((self.gr_frequency_modulator_fc_0, 0), (self.usrp_simple_sink_x_0, 0)) self.connect((self.gr_add_xx_1, 0), (self.gr_frequency_modulator_fc_0, 0)) self.connect((self.gr_sig_source_x_0, 0), (self.gr_add_xx_1, 1)) self.connect((self.gr_sub_xx_0, 0), (self.gr_multiply_xx_1, 2)) self.connect((self.gr_sig_source_x_0, 0), (self.gr_multiply_xx_1, 1)) self.connect((self.gr_sig_source_x_0, 0), (self.gr_multiply_xx_1, 0)) self.connect((self.gr_sig_source_x_0, 0), (self.gr_multiply_xx_0, 3)) self.connect((self.gr_sig_source_x_0, 0), (self.gr_multiply_xx_0, 2)) self.connect((self.blks2_rational_resampler_xxx_1_0, 0), (self.gr_add_xx_0, 1)) self.connect((self.blks2_rational_resampler_xxx_1, 0), (self.gr_add_xx_0, 0)) self.connect((self.blks2_rational_resampler_xxx_1_0, 0), (self.gr_sub_xx_0, 1)) self.connect((self.blks2_rational_resampler_xxx_1, 0), (self.gr_sub_xx_0, 0)) self.connect((self.gr_wavfile_source_0, 1), (self.blks2_rational_resampler_xxx_1_0, 0)) self.connect((self.gr_wavfile_source_0, 0), (self.blks2_rational_resampler_xxx_1, 0)) self.connect((self.gr_rds_data_encoder_0, 0), (self.gr_diff_encoder_bb_0, 0)) self.connect((self.gr_diff_encoder_bb_0, 0), (self.gr_map_bb_1, 0)) self.connect((self.gr_map_bb_1, 0), (self.gr_unpack_k_bits_bb_0, 0)) self.connect((self.gr_unpack_k_bits_bb_0, 0), (self.gr_map_bb_0, 0)) self.connect((self.gr_rds_rate_enforcer_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.gr_multiply_xx_0, 0)) self.connect((self.gr_multiply_xx_0, 0), (self.band_pass_filter_0, 0)) self.connect((self.band_pass_filter_0, 0), (self.gr_add_xx_1, 0)) self.connect((self.gr_multiply_xx_1, 0), (self.band_pass_filter_1, 0)) self.connect((self.band_pass_filter_1, 0), (self.gr_add_xx_1, 3)) self.connect((self.gr_add_xx_1, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.gr_sig_source_x_0, 0), (self.gr_multiply_xx_0, 1)) self.connect((self.gr_add_xx_0, 0), (self.low_pass_filter_0_0, 0)) self.connect((self.low_pass_filter_0_0, 0), (self.gr_add_xx_1, 2))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="DVB Simulator (GMSK)") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.signal = signal = 1 self.samp_rate = samp_rate = 32000 self.noise = noise = 10 ################################################## # Blocks ################################################## _signal_sizer = wx.BoxSizer(wx.VERTICAL) self._signal_text_box = forms.text_box( parent=self.GetWin(), sizer=_signal_sizer, value=self.signal, callback=self.set_signal, label="Signal", converter=forms.float_converter(), proportion=0, ) self._signal_slider = forms.slider( parent=self.GetWin(), sizer=_signal_sizer, value=self.signal, callback=self.set_signal, minimum=0, maximum=1000, num_steps=1000, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_signal_sizer) _noise_sizer = wx.BoxSizer(wx.VERTICAL) self._noise_text_box = forms.text_box( parent=self.GetWin(), sizer=_noise_sizer, value=self.noise, callback=self.set_noise, label="Noise", converter=forms.float_converter(), proportion=0, ) self._noise_slider = forms.slider( parent=self.GetWin(), sizer=_noise_sizer, value=self.noise, callback=self.set_noise, minimum=0, maximum=1000, num_steps=1000, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_noise_sizer) self.gr_wavfile_source_0 = gr.wavfile_source( "/home/traviscollins/GNURADIO/tfc_models/test.wav", False) self.gr_throttle_0 = gr.throttle(gr.sizeof_float * 1, samp_rate) self.gr_noise_source_x_0 = gr.noise_source_c(gr.GR_GAUSSIAN, noise, 42) self.gr_multiply_const_vxx_0 = gr.multiply_const_vcc((signal, )) self.gr_file_sink_1_0 = gr.file_sink( gr.sizeof_float * 1, "/home/traviscollins/GNURADIO/tfc_models/output_txt.wav") self.gr_file_sink_1_0.set_unbuffered(False) self.gr_channel_model_0 = gr.channel_model( noise_voltage=20, frequency_offset=0.0, epsilon=1.0, taps=(1.0 + 1.0j, ), noise_seed=42, ) self.gr_add_xx_0 = gr.add_vcc(1) self.digital_gmsk_mod_0 = digital.gmsk_mod( samples_per_symbol=2, bt=0.35, verbose=False, log=False, ) self.digital_gmsk_demod_0 = digital.gmsk_demod( samples_per_symbol=2, gain_mu=0.175, mu=0.5, omega_relative_limit=0.005, freq_error=0.0, verbose=False, log=False, ) self.blks2_packet_encoder_0 = grc_blks2.packet_mod_f( grc_blks2.packet_encoder( samples_per_symbol=2, bits_per_symbol=1, access_code="", pad_for_usrp=True, ), payload_length=0, ) self.blks2_packet_decoder_0 = grc_blks2.packet_demod_f( grc_blks2.packet_decoder( access_code="", threshold=-1, callback=lambda ok, payload: self.blks2_packet_decoder_0. recv_pkt(ok, payload), ), ) self.audio_sink_0 = audio.sink(samp_rate, "", True) ################################################## # Connections ################################################## self.connect((self.gr_noise_source_x_0, 0), (self.gr_add_xx_0, 1)) self.connect((self.gr_add_xx_0, 0), (self.digital_gmsk_demod_0, 0)) self.connect((self.blks2_packet_encoder_0, 0), (self.digital_gmsk_mod_0, 0)) self.connect((self.digital_gmsk_mod_0, 0), (self.gr_multiply_const_vxx_0, 0)) self.connect((self.gr_throttle_0, 0), (self.blks2_packet_encoder_0, 0)) self.connect((self.gr_throttle_0, 0), (self.gr_file_sink_1_0, 0)) self.connect((self.digital_gmsk_demod_0, 0), (self.blks2_packet_decoder_0, 0)) self.connect((self.gr_multiply_const_vxx_0, 0), (self.gr_channel_model_0, 0)) self.connect((self.gr_channel_model_0, 0), (self.gr_add_xx_0, 0)) self.connect((self.gr_wavfile_source_0, 0), (self.gr_throttle_0, 0)) self.connect((self.blks2_packet_decoder_0, 0), (self.audio_sink_0, 0))