def __init__(self): gr.top_block.__init__(self, "FT8 and FT4 Decoder", catch_exceptions=True) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 48e3 ################################################## # Blocks ################################################## self.rotate = rotate.blk(tmp_path='/run/user/1000/gnuradio') self.rational_resampler_4 = filter.rational_resampler_fff( interpolation=1, decimation=4, taps=[], fractional_bw=0) self.ft8_sink = blocks.wavfile_sink('/dev/null', 1, 12000, blocks.FORMAT_WAV, blocks.FORMAT_PCM_16, False) self.ft4_sink = blocks.wavfile_sink('/dev/null', 1, 12000, blocks.FORMAT_WAV, blocks.FORMAT_PCM_16, False) self.cron = cron.blk() self.audio_source_rx2 = audio.source(48000, 'pulse:rx2.monitor', True) ################################################## # Connections ################################################## self.msg_connect((self.cron, 'cron_ft8'), (self.rotate, 'rotate_ft8')) self.msg_connect((self.cron, 'cron_ft4'), (self.rotate, 'rotate_ft4')) self.connect((self.audio_source_rx2, 0), (self.rational_resampler_4, 0)) self.connect((self.rational_resampler_4, 0), (self.ft4_sink, 0)) self.connect((self.rational_resampler_4, 0), (self.ft8_sink, 0))
def test_003_checkwav_append_non_existent_should_error(self): outfile = "no_file.wav" with self.assertRaisesRegex(RuntimeError, "Can't open WAV file."): blocks.wavfile_sink(outfile, 1, 44100, blocks.FORMAT_WAV, blocks.FORMAT_PCM_16, True) os.remove(outfile)
def test_003_checkwav_append_copy(self): infile = g_in_file_normal outfile = "test_out_append.wav" # 1. Copy input to output from shutil import copyfile copyfile(infile, outfile) # 2. append copy wf_in = blocks.wavfile_source(infile) wf_out = blocks.wavfile_sink(outfile, wf_in.channels(), wf_in.sample_rate(), blocks.FORMAT_WAV, blocks.FORMAT_PCM_16, True) self.tb.connect(wf_in, wf_out) self.tb.run() wf_out.close() # 3. append halved copy wf_in = blocks.wavfile_source(infile) halver = blocks.multiply_const_ff(0.5) wf_out = blocks.wavfile_sink(outfile, wf_in.channels(), wf_in.sample_rate(), blocks.FORMAT_WAV, blocks.FORMAT_PCM_16, True) self.tb.connect(wf_in, halver, wf_out) self.tb.run() wf_out.close() # Test file validity and read data. import wave try: # In with wave.open(infile, 'rb') as w_in: in_params = w_in.getparams() data_in = wav_read_frames(w_in) # Out with wave.open(outfile, 'rb') as w_out: out_params = w_out.getparams() data_out = wav_read_frames(w_out) except BaseException: raise AssertionError('Invalid WAV file') # Params must be equal except in size: expected_params = in_params._replace(nframes=3 * in_params.nframes) self.assertEqual(out_params, expected_params) # Part 1 self.assertEqual(data_in, data_out[:len(data_in)]) # Part 2 self.assertEqual(data_in, data_out[len(data_in):2 * len(data_in)]) # Part 3 data_in_halved = [int(round(d / 2)) for d in data_in] self.assertEqual(data_in_halved, data_out[2 * len(data_in):]) os.remove(outfile)
def __init__(self, interval, duration, listener, sample_rate, _callLater=reactor.callLater, _time=time.time, _deferToThread=threads.deferToThread): assert interval > duration gr.hier_block2.__init__( self, type(self).__name__, gr.io_signature(1, 1, gr.sizeof_float), gr.io_signature(0, 0, 0)) self._callLater = _callLater self._time = _time self._deferToThread = _deferToThread self.interval = interval self.listener = listener self.duration = duration self._sink = wavfile_sink( # There doesn't seem to be a way to create a sink without # immediately opening a file :( filename=b'/dev/null', n_channels=1, sample_rate=sample_rate, bits_per_sample=16) self.connect(self, self._sink)
def __init__(self): gr.top_block.__init__(self) parser = ArgumentParser() parser.add_argument("-r", "--sample-rate", type=eng_float, default=48000, help="set sample rate to RATE (%(default)r)") parser.add_argument("-N", "--samples", type=eng_float, required=True, help="number of samples to record") parser.add_argument('file_name', metavar='WAV-FILE', help='Output WAV file name', nargs=1) args = parser.parse_args() sample_rate = int(args.sample_rate) ampl = 0.1 src0 = analog.sig_source_f(sample_rate, analog.GR_SIN_WAVE, 350, ampl) src1 = analog.sig_source_f(sample_rate, analog.GR_SIN_WAVE, 440, ampl) head0 = blocks.head(gr.sizeof_float, int(args.samples)) head1 = blocks.head(gr.sizeof_float, int(args.samples)) dst = blocks.wavfile_sink(args.file_name[0], 2, int(args.sample_rate), blocks.FORMAT_WAV, blocks.FORMAT_PCM_16) self.connect(src0, head0, (dst, 0)) self.connect(src1, head1, (dst, 1))
def __init__(self, samp_rate=2e6, dst=None, freq=13.57e6, rx_gain=6.5): gr.hier_block2.__init__(self, "usrp_src", gr.io_signature(0, 0, 0), # Input signature gr.io_signature(1, 1, gr.sizeof_float)) # Output signature self._src = uhd.usrp_source( device_addr="", stream_args=uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self._src.set_samp_rate(samp_rate) self._src.set_center_freq(freq, 0) self._src.set_gain(rx_gain, 0) self._src.set_antenna("RX", 0) self._c2m2 = blocks.complex_to_mag_squared(1) self.connect(self._src, self._c2m2, self) if dst: self._wav = blocks.wavfile_sink(dst, 1, int(samp_rate), 16) self.connect(self._c2m2, self._wav)
def test_002_checkwavcopy(self): infile = g_in_file outfile = "test_out.wav" wf_in = blocks.wavfile_source(infile) wf_out = blocks.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() # we're losing all extra header chunks self.assertEqual( getsize(infile) - g_extra_header_len, getsize(outfile)) in_f = open(infile, 'rb') out_f = open(outfile, 'rb') in_data = in_f.read() out_data = out_f.read() out_f.close() os.remove(outfile) # cut extra header chunks input file self.assertEqual(in_data[:g_extra_header_offset] + \ in_data[g_extra_header_offset + g_extra_header_len:], out_data)
def __init__(self, interval, duration, listener, sample_rate, _callLater=reactor.callLater, _time=time.time, _deferToThread=threads.deferToThread): assert interval > duration gr.hier_block2.__init__(self, type(self).__name__, gr.io_signature(1, 1, gr.sizeof_float), gr.io_signature(0, 0, 0)) self._callLater = _callLater self._time = _time self._deferToThread = _deferToThread self.interval = interval self.listener = listener self.duration = duration self._sink = wavfile_sink( # There doesn't seem to be a way to create a sink without # immediately opening a file :( filename=b'/dev/null', n_channels=1, sample_rate=sample_rate, bits_per_sample=16) self.connect(self, self._sink)
def test_002_checkwavcopy(self): infile = g_in_file outfile = "test_out.wav" wf_in = blocks.wavfile_source(infile) wf_out = blocks.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() # we're loosing all extra header chunks self.assertEqual(getsize(infile) - g_extra_header_len, 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) # cut extra header chunks input file self.assertEqual(in_data[:g_extra_header_offset] + \ in_data[g_extra_header_offset + g_extra_header_len:], out_data)
def setTone(self,freq,amplitude): self.signal=freq self.amp=amplitude self.analog_sig_source_x_0 = analog.sig_source_c(self.samp_rate, analog.GR_COS_WAVE, self.signal, self.amp, 0) ################################################## # Variables ################################################## self.samp = samp = 192000 self.rational_samp = rational_samp = 48000 self.rational_resampler_xxx_0 = filter.rational_resampler_fff( interpolation=samp, decimation=rational_samp, taps=None, fractional_bw=None, ) self.blocks_wavfile_sink_0 = blocks.wavfile_sink(self.path, 1, rational_samp, 16) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp,True) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_complex_to_real_0 = blocks.complex_to_real(1) self.analog_sig_source_x_2 = analog.sig_source_c(samp, analog.GR_COS_WAVE, samp/2, 1, 0) ################################################## # Connections ################################################## self.connect((self.analog_sig_source_x_2, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_complex_to_real_0, 0)) self.connect((self.blocks_complex_to_real_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.blocks_wavfile_sink_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_throttle_0, 0))
def topblock(self, carrier=32000, samp_rate = 80000, bw=1000, amp=1): gr.top_block.__init__(self, "Top Block") ################################################## # Variables ################################################## self.samp_rate = samp_rate self.carrier = carrier self.bw = bw self.source = blocks.vector_source_b((0,0), False, 1, []) self.sink = blocks.multiply_vcc(1) analog_sig_source_x_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, carrier, amp, 0) blocks_complex_to_real_0 = blocks.complex_to_real(1) stereo = blocks.multiply_const_vff((-1, )) self.out = blocks.wavfile_sink("/tmp/outbits.wav", 2, samp_rate) ################################################## # Connections ################################################## self.connect((analog_sig_source_x_0, 0), (self.sink, 1)) self.connect((self.sink, 0), (blocks_complex_to_real_0, 0)) self.connect((blocks_complex_to_real_0, 0), (self.out, 0)) self.connect((blocks_complex_to_real_0, 0), (stereo, 0)) self.connect((stereo, 0), (self.out, 1))
def __init__(self): gr.top_block.__init__(self, "Lab 1 Task 2") Qt.QWidget.__init__(self) self.setWindowTitle("Lab 1 Task 2") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "lab1_task2") try: if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"): self.restoreGeometry(self.settings.value("geometry").toByteArray()) else: self.restoreGeometry(self.settings.value("geometry")) except: pass ################################################## # Variables ################################################## self.samp_rate = samp_rate = 32000 ################################################## # Blocks ################################################## self.rational_resampler_xxx_0 = filter.rational_resampler_fff( interpolation=441, decimation=320, taps=None, fractional_bw=0.4) self.blocks_wavfile_source_1 = blocks.wavfile_source('/home/ipsit/Documents/EE 340/Lab 1/background.wav', True) self.blocks_wavfile_source_0 = blocks.wavfile_source('/home/ipsit/Documents/EE 340/Lab 1/vocal.wav', True) self.blocks_wavfile_sink_0 = blocks.wavfile_sink('/home/ipsit/Documents/EE 340/Lab 1/voice_n_background.wav', 1, samp_rate, 8) self.blocks_add_xx_0 = blocks.add_vff(1) self.audio_sink_0 = audio.sink(samp_rate, '', True) ################################################## # Connections ################################################## self.connect((self.blocks_add_xx_0, 0), (self.audio_sink_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.blocks_wavfile_sink_0, 0)) self.connect((self.blocks_wavfile_source_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.blocks_wavfile_source_1, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.blocks_add_xx_0, 1))
def __init__(self): gr.top_block.__init__(self) usage = "%prog: [options] filename" parser = OptionParser(option_class=eng_option, usage=usage) parser.add_option("-r", "--sample-rate", type="eng_float", default=48000, help="set sample rate to RATE (48000)") parser.add_option("-N", "--samples", type="eng_float", default=None, help="number of samples to record") (options, args) = parser.parse_args() if len(args) != 1 or options.samples is None: parser.print_help() raise SystemExit, 1 sample_rate = int(options.sample_rate) ampl = 0.1 src0 = analog.sig_source_f(sample_rate, analog.GR_SIN_WAVE, 350, ampl) src1 = analog.sig_source_f(sample_rate, analog.GR_SIN_WAVE, 440, ampl) head0 = blocks.head(gr.sizeof_float, int(options.samples)) head1 = blocks.head(gr.sizeof_float, int(options.samples)) dst = blocks.wavfile_sink(args[0], 2, int(options.sample_rate), 16) self.connect(src0, head0, (dst, 0)) self.connect(src1, head1, (dst, 1))
def __init__(self): gr.top_block.__init__(self) usage="%prog: [options] output_filename" parser = OptionParser(option_class=eng_option, usage=usage) 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 (48000)") parser.add_option("-N", "--nsamples", type="eng_float", default=None, help="number of samples to collect [default=+inf]") (options, args) = parser.parse_args () if len(args) != 1: parser.print_help() raise( SystemExit, 1 ) filename = args[0] sample_rate = int(options.sample_rate) src = audio.source (sample_rate, options.audio_input) dst = blocks.wavfile_sink (filename, 1, sample_rate) if options.nsamples is None: self.connect((src, 0), dst) else: head = blocks.head(gr.sizeof_float, int(options.nsamples)) self.connect((src, 0), head, dst)
def __init__(self, samp_rate=2e6, dst=None, freq=13.57e6, rx_gain=6.5): gr.hier_block2.__init__( self, "usrp_src", gr.io_signature(0, 0, 0), # Input signature gr.io_signature(1, 1, gr.sizeof_float)) # Output signature self._src = uhd.usrp_source( device_addr="", stream_args=uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self._src.set_samp_rate(samp_rate) self._src.set_center_freq(freq, 0) self._src.set_gain(rx_gain, 0) self._src.set_antenna("RX", 0) self._c2m2 = blocks.complex_to_mag_squared(1) self.connect(self._src, self._c2m2, self) if dst and dst != "uhd": self._wav = blocks.wavfile_sink(dst, 1, int(samp_rate), 16) self.connect(self._c2m2, self._wav)
def __init__(self): gr.top_block.__init__(self) usage = "%prog: [options] filename" parser = OptionParser(option_class=eng_option, usage=usage) parser.add_option("-r", "--sample-rate", type="eng_float", default=48000, help="set sample rate to RATE (48000)") parser.add_option("-N", "--samples", type="eng_float", default=None, help="number of samples to record") (options, args) = parser.parse_args () if len(args) != 1 or options.samples is None: parser.print_help() raise SystemExit, 1 sample_rate = int(options.sample_rate) ampl = 0.1 src0 = analog.sig_source_f(sample_rate, analog.GR_SIN_WAVE, 350, ampl) src1 = analog.sig_source_f(sample_rate, analog.GR_SIN_WAVE, 440, ampl) head0 = blocks.head(gr.sizeof_float, int(options.samples)) head1 = blocks.head(gr.sizeof_float, int(options.samples)) dst = blocks.wavfile_sink(args[0], 2, int(options.sample_rate), 16) self.connect(src0, head0, (dst, 0)) self.connect(src1, head1, (dst, 1))
def __init__(self): gr.top_block.__init__(self, "Acpqheadphones") ################################################## # Variables ################################################## self.samp_rate = samp_rate = 48000 ################################################## # Blocks ################################################## self.blocks_wavfile_sink_0 = blocks.wavfile_sink('pq.wav', 2, samp_rate, 16) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((-1, )) self.blocks_delay_0 = blocks.delay(gr.sizeof_float*1, 800) self.blocks_add_xx_0 = blocks.add_vff(1) self.audio_source_0 = audio.source(samp_rate, 'hw:1', True) self.audio_sink_0 = audio.sink(samp_rate, 'hw:1', True) self.analog_rail_ff_0 = analog.rail_ff(-0.8, 0.8) self.analog_agc2_xx_0 = analog.agc2_ff(1e-1, 0.5, 0.01, 1.0) self.analog_agc2_xx_0.set_max_gain(65536) ################################################## # Connections ################################################## self.connect((self.analog_agc2_xx_0, 0), (self.analog_rail_ff_0, 0)) self.connect((self.analog_rail_ff_0, 0), (self.audio_sink_0, 0)) self.connect((self.audio_source_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.audio_source_0, 0), (self.blocks_delay_0, 0)) self.connect((self.audio_source_0, 0), (self.blocks_wavfile_sink_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.analog_agc2_xx_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.blocks_wavfile_sink_0, 1)) self.connect((self.blocks_delay_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_add_xx_0, 1))
def __init__ (self, sample_rate, frequency, freq_correction, rf_gain, if_gain, bb_gain, bandwidth, port, dst=None): gr.hier_block2.__init__(self, "usrp_src", gr.io_signature(0, 0, 0), gr.io_signature(1, 1, gr.sizeof_float)) self.sample_rate = sample_rate self.rf_gain = rf_gain self.port = port self.if_gain = if_gain self.frequency = frequency self.freq_correction = freq_correction self.bb_gain = bb_gain self.bandwidth = bandwidth self.osmosdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + 'hackrf' ) self.osmosdr_source_0.set_time_unknown_pps(osmosdr.time_spec_t()) self.osmosdr_source_0.set_sample_rate(sample_rate) self.osmosdr_source_0.set_center_freq(frequency, 0) self.osmosdr_source_0.set_freq_corr(freq_correction, 0) self.osmosdr_source_0.set_gain(rf_gain, 0) self.osmosdr_source_0.set_if_gain(if_gain, 0) self.osmosdr_source_0.set_bb_gain(bb_gain, 0) self.osmosdr_source_0.set_antenna('', 0) self.osmosdr_source_0.set_bandwidth(bandwidth, 0) self._c2m2 = blocks.complex_to_mag_squared(1) self.connect(self.osmosdr_source_0, self._c2m2, self) if dst and dst != "uhd": self._wav = blocks.wavfile_sink(dst, 1, int(samp_rate), 16) self.connect(self._c2m2, self._wav)
def topblock(self, carrier=32000, samp_rate=80000, bw=1000, amp=1): gr.top_block.__init__(self, "Top Block") ################################################## # Variables ################################################## self.samp_rate = samp_rate self.carrier = carrier self.bw = bw self.source = blocks.vector_source_b((0, 0), False, 1, []) self.sink = blocks.multiply_vcc(1) analog_sig_source_x_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, carrier, amp, 0) blocks_complex_to_real_0 = blocks.complex_to_real(1) stereo = blocks.multiply_const_vff((-1, )) self.out = blocks.wavfile_sink("/tmp/outbits.wav", 2, samp_rate) ################################################## # Connections ################################################## self.connect((analog_sig_source_x_0, 0), (self.sink, 1)) self.connect((self.sink, 0), (blocks_complex_to_real_0, 0)) self.connect((blocks_complex_to_real_0, 0), (self.out, 0)) self.connect((blocks_complex_to_real_0, 0), (stereo, 0)) self.connect((stereo, 0), (self.out, 1))
def __init__(self, samp_rate=16E3, name="unnamed", save_dir=None, postscript=None): gr.hier_block2.__init__(self, "Recorder", gr.io_signature(1, 1, gr.sizeof_float), gr.io_signature(1, 1, gr.sizeof_float)) self.timeout = 18000 self.save_dir = save_dir self.postscript = postscript self.record_squelch = analog.pwr_squelch_ff(-200, 0.1, 0, True) self.blocks_wavfile_sink = blocks.wavfile_sink("/dev/null", 1, samp_rate, 16) self.blocks_null_source = blocks.null_source(gr.sizeof_float * 1) self.connect(self, (self.record_squelch, 0)) self.connect((self.record_squelch, 0), (self.blocks_wavfile_sink, 0)) self.connect((self.blocks_null_source, 0), self) thread = threading.Thread(target=self.timer_thread, args=(name, self.save_dir, self.blocks_wavfile_sink, \ self.record_squelch, self.postscript, self.timeout)) thread.daemon = True thread.start()
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Top Block") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.freq = freq = 400 self.samp_rate = samp_rate = 32000 self.fname = fname = str(freq) + ".wav" ################################################## # Blocks ################################################## self.blocks_wavfile_sink_0 = blocks.wavfile_sink( fname, 1, samp_rate, 8) self.analog_sig_source_x_0 = analog.sig_source_f( samp_rate, analog.GR_COS_WAVE, freq, 1, 0) (self.analog_sig_source_x_0).set_min_output_buffer(1024) ################################################## # Connections ################################################## self.connect((self.analog_sig_source_x_0, 0), (self.blocks_wavfile_sink_0, 0))
def __init__(self, dst, samp_rate=2e6): gr.hier_block2.__init__(self, "record", gr.io_signature(1, 1, gr.sizeof_gr_complex), gr.io_signature(0, 0, 0)) self._sink = blocks.wavfile_sink(dst, 1, int(samp_rate)) self._c2 = blocks.complex_to_real(1) self.connect(self, self._c2, self._sink)
def __init__(self, dest = _def_dest, do_imbe = _def_do_imbe, num_ambe = _def_num_ambe, wireshark_host = _def_wireshark_host, udp_port = _def_udp_port, do_msgq = False, msgq = None, audio_output = _def_audio_output, debug = _def_debug): """ Hierarchical block for P25 decoding. @param debug: debug level @type debug: int """ gr.hier_block2.__init__(self, "p25_demod_c", gr.io_signature(1, 1, gr.sizeof_char), # Input signature gr.io_signature(0, 0, 0)) # Output signature assert 0 <= num_ambe <= _def_max_tdma_timeslots assert not (num_ambe > 1 and dest != 'wav') self.debug = debug self.dest = dest do_output = 1 do_audio_output = True if msgq is None: msgq = gr.msg_queue(1) self.p25_decoders = [] self.audio_s2f = [] self.scaler = [] self.audio_sink = [] self.xorhash = [] num_decoders = 1 if num_ambe > 1: num_decoders += num_ambe - 1 for slot in xrange(num_decoders): self.p25_decoders.append(op25_repeater.p25_frame_assembler(wireshark_host, udp_port, debug, do_imbe, do_output, do_msgq, msgq, do_audio_output, True)) self.p25_decoders[slot].set_slotid(slot) self.audio_s2f.append(blocks.short_to_float()) # another ridiculous conversion self.scaler.append(blocks.multiply_const_ff(1 / 32768.0)) self.xorhash.append('') if dest == 'wav': filename = 'default-%f-%d.wav' % (time.time(), slot) n_channels = 1 sample_rate = 8000 bits_per_sample = 16 self.audio_sink.append(blocks.wavfile_sink(filename, n_channels, sample_rate, bits_per_sample)) elif dest == 'audio': self.audio_sink.append(audio.sink(_def_audio_rate, audio_output, True)) self.connect(self, self.p25_decoders[slot], self.audio_s2f[slot], self.scaler[slot], self.audio_sink[slot])
def __init__(self): gr.top_block.__init__(self, "Top Block") Qt.QWidget.__init__(self) self.setWindowTitle("Top Block") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "top_block") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 32000 ################################################## # Blocks ################################################## self.rtlsdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " + '') self.rtlsdr_source_0.set_sample_rate(samp_rate) self.rtlsdr_source_0.set_center_freq(100e6, 0) self.rtlsdr_source_0.set_freq_corr(0, 0) self.rtlsdr_source_0.set_dc_offset_mode(0, 0) self.rtlsdr_source_0.set_iq_balance_mode(0, 0) self.rtlsdr_source_0.set_gain_mode(False, 0) self.rtlsdr_source_0.set_gain(10, 0) self.rtlsdr_source_0.set_if_gain(20, 0) self.rtlsdr_source_0.set_bb_gain(20, 0) self.rtlsdr_source_0.set_antenna('', 0) self.rtlsdr_source_0.set_bandwidth(0, 0) self.blocks_wavfile_sink_0 = blocks.wavfile_sink('', 2, samp_rate, 8) self.blocks_complex_to_float_0 = blocks.complex_to_float(1) ################################################## # Connections ################################################## self.connect((self.blocks_complex_to_float_0, 0), (self.blocks_wavfile_sink_0, 0)) self.connect((self.blocks_complex_to_float_0, 1), (self.blocks_wavfile_sink_0, 1)) self.connect((self.rtlsdr_source_0, 0), (self.blocks_complex_to_float_0, 0))
def __init__(self, cutoff_freq=12000, decimation=1, num_samples=10000000, samp_rate=2000000, save_file='', source_file='', trans_width=2000): gr.top_block.__init__(self, "Filter Sig") ################################################## # Parameters ################################################## self.cutoff_freq = cutoff_freq self.decimation = decimation self.num_samples = num_samples self.samp_rate = samp_rate self.save_file = save_file self.source_file = source_file self.trans_width = trans_width ################################################## # Blocks ################################################## self.low_pass_filter_0_1 = filter.fir_filter_ccf( decimation, firdes.low_pass(1, samp_rate, cutoff_freq, trans_width, firdes.WIN_HAMMING, 6.76)) self.blocks_wavfile_sink_0 = blocks.wavfile_sink( 'C:\\Users\\devri\\Documents\\RIT\\Sixth Semester\\MSD I\\GIT\\readInData\\filterDemodData\\pi_1_ref_sig_filter_demod_1.wav', 1, samp_rate, 8) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1, samp_rate, True) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((2, )) self.blocks_head_0 = blocks.head(gr.sizeof_float * 1, num_samples) self.blocks_file_source_0 = blocks.file_source( gr.sizeof_gr_complex * 1, 'C:\\Users\\devri\\Documents\\RIT\\Sixth Semester\\MSD I\\GIT\\readInData\\Data\\pi_1_ref_sig_1', True) self.blocks_file_source_0.set_begin_tag(pmt.PMT_NIL) self.analog_wfm_rcv_0 = analog.wfm_rcv( quad_rate=2e6, audio_decimation=1, ) ################################################## # Connections ################################################## self.connect((self.analog_wfm_rcv_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_file_source_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_head_0, 0), (self.blocks_wavfile_sink_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_head_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.low_pass_filter_0_1, 0)) self.connect((self.low_pass_filter_0_1, 0), (self.analog_wfm_rcv_0, 0))
def __init__(self, filename="0.dat", freq=90.1e6, samp_rate=1e6): gr.top_block.__init__(self, "Fm Receiver") ################################################## # Parameters ################################################## self.filename = filename self.freq = freq self.samp_rate = samp_rate ################################################## # Variables ################################################## self.gain = gain = 30 self.audio_rate = audio_rate = 48e3 self.audio_interp = audio_interp = 4 ################################################## # Blocks ################################################## self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=int(audio_rate * audio_interp), decimation=int(samp_rate), taps=None, fractional_bw=None, ) self.low_pass_filter_0 = filter.interp_fir_filter_fff( 1, firdes.low_pass(1, int(audio_rate), 800, 100, firdes.WIN_HAMMING, 6.76)) self.blocks_wavfile_sink_0 = blocks.wavfile_sink( "wav_out.wav", 1, int(audio_rate), 8) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1, samp_rate, True) self.blocks_interleaved_short_to_complex_0 = blocks.interleaved_short_to_complex( False, False) self.blocks_file_source_0_0 = blocks.file_source( gr.sizeof_short * 1, filename, False) self.analog_wfm_rcv_0 = analog.wfm_rcv( quad_rate=int(audio_rate * audio_interp), audio_decimation=int(audio_interp), ) ################################################## # Connections ################################################## self.connect((self.analog_wfm_rcv_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.blocks_file_source_0_0, 0), (self.blocks_interleaved_short_to_complex_0, 0)) self.connect((self.blocks_interleaved_short_to_complex_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.blocks_wavfile_sink_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.analog_wfm_rcv_0, 0))
def __init__(self): gr.top_block.__init__(self, "Lab 1 Task 1") Qt.QWidget.__init__(self) self.setWindowTitle("Lab 1 Task 1") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "lab1_task1") try: if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"): self.restoreGeometry(self.settings.value("geometry").toByteArray()) else: self.restoreGeometry(self.settings.value("geometry")) except: pass ################################################## # Variables ################################################## self.samp_rate = samp_rate = 32000 ################################################## # Blocks ################################################## self.blocks_wavfile_sink_0 = blocks.wavfile_sink('/home/ipsit/Documents/EE 340/Lab 1/hbd.wav', 1, samp_rate, 8) self.blocks_vector_source_x_0 = blocks.vector_source_f((262,262,294,262,349,330,262,294,262,392,349,262,262,523,440,349,330,294,466,466,440,349,392,349), True, 1, []) self.blocks_vco_f_0 = blocks.vco_f(samp_rate, 6.28, 1) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_float*1, samp_rate,True) self.blocks_repeat_0 = blocks.repeat(gr.sizeof_float*1, samp_rate//2) self.audio_sink_0 = audio.sink(samp_rate, '', True) ################################################## # Connections ################################################## self.connect((self.blocks_repeat_0, 0), (self.blocks_vco_f_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.audio_sink_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_wavfile_sink_0, 0)) self.connect((self.blocks_vco_f_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_vector_source_x_0, 0), (self.blocks_repeat_0, 0))
def __init__(self): gr.top_block.__init__(self, "Top Block") ################################################## # Variables ################################################## self.samp_rate = samp_rate = 2400000 self.resamp_rate = resamp_rate = 200000 self.audio_rate = audio_rate = 48000 self.audio_interp = audio_interp = 4 self.audio_gain_0 = audio_gain_0 = 5 ################################################## # Blocks ################################################## self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=resamp_rate, decimation=samp_rate, taps=None, fractional_bw=None, ) self.low_pass_filter_0 = filter.fir_filter_ccf( 1, firdes.low_pass(1, samp_rate, resamp_rate / 2, resamp_rate / 20, firdes.WIN_HAMMING, 6.76)) self.blocks_wavfile_source_0 = blocks.wavfile_source( sys.argv[1], False) self.blocks_wavfile_sink_0 = blocks.wavfile_sink( sys.argv[2], 1, audio_rate, 8) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff( (audio_gain_0, )) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.analog_wfm_rcv_0 = analog.wfm_rcv( quad_rate=audio_rate * audio_interp, audio_decimation=audio_interp, ) self.analog_fm_deemph_0 = analog.fm_deemph(fs=audio_rate, tau=50e-6) ################################################## # Connections ################################################## self.connect((self.analog_fm_deemph_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.analog_wfm_rcv_0, 0), (self.analog_fm_deemph_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_wavfile_sink_0, 0)) self.connect((self.blocks_wavfile_source_0, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.blocks_wavfile_source_0, 1), (self.blocks_float_to_complex_0, 1)) self.connect((self.low_pass_filter_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.analog_wfm_rcv_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Top Block") _icon_path = "C:\Program Files\GNURadio-3.7\share\icons\hicolor\scalable/apps\gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 1e6 self.center_freq = center_freq = 315e6 ################################################## # Blocks ################################################## self.wxgui_scopesink2_0 = scopesink2.scope_sink_f( self.GetWin(), title='Scope Plot', sample_rate=samp_rate, v_scale=1, v_offset=0, t_scale=0.002, ac_couple=False, xy_mode=False, num_inputs=1, trig_mode=wxgui.TRIG_MODE_AUTO, y_axis_label='Counts', ) self.Add(self.wxgui_scopesink2_0.win) self.osmosdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + '' ) self.osmosdr_source_0.set_sample_rate(samp_rate) self.osmosdr_source_0.set_center_freq(center_freq, 0) self.osmosdr_source_0.set_freq_corr(0, 0) self.osmosdr_source_0.set_dc_offset_mode(0, 0) self.osmosdr_source_0.set_iq_balance_mode(0, 0) self.osmosdr_source_0.set_gain_mode(False, 0) self.osmosdr_source_0.set_gain(10, 0) self.osmosdr_source_0.set_if_gain(20, 0) self.osmosdr_source_0.set_bb_gain(20, 0) self.osmosdr_source_0.set_antenna('', 0) self.osmosdr_source_0.set_bandwidth(0, 0) self.blocks_wavfile_sink_0 = blocks.wavfile_sink('S:\\SDROutput\\Screen\\stop.bin', 1, int(samp_rate), 8) self.blocks_threshold_ff_0 = blocks.threshold_ff(0.1, 0.11, 0) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((2, )) self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1) self.blocks_add_const_vxx_0 = blocks.add_const_vff((-0.5, )) ################################################## # Connections ################################################## self.connect((self.blocks_add_const_vxx_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.blocks_threshold_ff_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_wavfile_sink_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.wxgui_scopesink2_0, 0)) self.connect((self.blocks_threshold_ff_0, 0), (self.blocks_add_const_vxx_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.blocks_complex_to_mag_squared_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Audio Playback") ################################################## # Variables ################################################## self.samp_rate = samp_rate = 48e3 self.playback_rate = playback_rate = 1 ################################################## # Blocks ################################################## _playback_rate_sizer = wx.BoxSizer(wx.VERTICAL) self._playback_rate_text_box = forms.text_box( parent=self.GetWin(), sizer=_playback_rate_sizer, value=self.playback_rate, callback=self.set_playback_rate, label='playback_rate', converter=forms.float_converter(), proportion=0, ) self._playback_rate_slider = forms.slider( parent=self.GetWin(), sizer=_playback_rate_sizer, value=self.playback_rate, callback=self.set_playback_rate, minimum=.1, maximum=8, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_playback_rate_sizer) self.fractional_resampler_xx_0 = filter.fractional_resampler_ff( 0, playback_rate) self.blocks_wavfile_sink_0 = blocks.wavfile_sink( "radio_recording_2.wav", 1, int(samp_rate), 8) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_float * 1, samp_rate, True) self.blocks_file_source_0 = blocks.file_source(gr.sizeof_float * 1, "radio_samples", False) self.audio_sink_0 = audio.sink(48000, "", False) ################################################## # Connections ################################################## self.connect((self.blocks_file_source_0, 0), (self.fractional_resampler_xx_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.audio_sink_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_wavfile_sink_0, 0)) self.connect((self.fractional_resampler_xx_0, 0), (self.blocks_throttle_0, 0))
def __init__(self): gr.top_block.__init__(self, "SAME Decoder test") ################################################## # Variables ################################################## self.samp_rate = samp_rate = 8000 ################################################## # Blocks ################################################## self.rational_resampler_44k = filter.rational_resampler_fff( interpolation=80, decimation=441, ) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=100, decimation=96, taps=None, fractional_bw=None, ) self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_fcc(1, (firdes.low_pass(1, samp_rate, 600, 100)), 1822.916667, samp_rate) self.digital_gmsk_demod_0 = digital.gmsk_demod( samples_per_symbol=16, gain_mu=0.175, mu=0.5, omega_relative_limit=0.1, freq_error=0.0, verbose=True, log=False, ) #self.src = audio.source(samp_rate, "plughw:CARD=PCH,DEV=2", True) self.blocks_wavfile_source_0 = blocks.wavfile_source("eas-test-11-7-2013.wav", False) self.blocks_bitstream_sink = blocks.file_sink(1, "bitstream.bin") self.xlat_sink = blocks.wavfile_sink("xlat.wav", 1, 8333) self.xlat_complex_to_float = blocks.complex_to_float() self.analog_pwr_squelch_xx_0 = analog.pwr_squelch_ff(-50, 0.0001, 0) self.msg_queue = gr.msg_queue(10) self.same_dec_0 = same.same_dec(self.msg_queue) ################################################## # Connections ################################################## self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.xlat_complex_to_float, 0), (self.xlat_sink, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.digital_gmsk_demod_0, 0)) self.connect((self.digital_gmsk_demod_0, 0), (self.same_dec_0, 0)) self.connect((self.digital_gmsk_demod_0, 0), (self.blocks_bitstream_sink, 0)) #self.connect((self.src, 0), (self.rational_resampler_44k, 0)) #self.connect((self.rational_resampler_44k, 0), (self.analog_pwr_squelch_xx_0, 0)) self.connect((self.blocks_wavfile_source_0, 0), (self.analog_pwr_squelch_xx_0,0)) self.connect((self.analog_pwr_squelch_xx_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0)) self._watcher = _queue_watcher_thread(self.msg_queue)
def __init__(self): gr.top_block.__init__(self) frequency = 57000 sample_rate = 500000 ampl = 0.8 src0 = analog.sig_source_f (sample_rate, analog.GR_SIN_WAVE, frequency, ampl) dst = blocks.wavfile_sink ("sample_57k_sin.wav", 1, sample_rate) self.connect (src0, dst)
def __init__(self): gr.top_block.__init__(self, "Top Block") Qt.QWidget.__init__(self) self.setWindowTitle("Top Block") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "top_block") if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"): self.restoreGeometry(self.settings.value("geometry").toByteArray()) else: self.restoreGeometry( self.settings.value("geometry", type=QtCore.QByteArray)) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 32000 ################################################## # Blocks ################################################## self.blocks_wavfile_sink_0 = blocks.wavfile_sink( '/home/norwood/sdr-modrec/test-file.wav', 1, samp_rate, 8) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_float * 1, samp_rate, True) self.analog_sig_source_x_0 = analog.sig_source_f( samp_rate, analog.GR_SIN_WAVE, 1000, 1, 0) ################################################## # Connections ################################################## self.connect((self.analog_sig_source_x_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_wavfile_sink_0, 0))
def setup_blocks(self): ################################################## # Blocks ################################################## self.update_input() self.blocks_wavfile_sink_0 = blocks.wavfile_sink("/home/bward/Documents/Labhack 2016/Cleaned Audio/cleaned_audio.wav", 1, self.samp_rate, 16) self.band_pass_filter_0 = filter.fir_filter_fff(1, firdes.band_pass( 1, self.samp_rate, self.low_freq, self.high_freq, 10, firdes.WIN_HAMMING, 6.76)) ################################################## # Connections ################################################## self.connect((self.band_pass_filter_0, 0), (self.blocks_wavfile_sink_0, 0)) self.connect((self.blocks_wavfile_source_0, 0), (self.band_pass_filter_0, 0))
def __init__(self): gr.top_block.__init__(self, "Amrx") ################################################## # Variables ################################################## self.samp_rate = samp_rate = 2500000 ################################################## # Blocks ################################################## self.uhd_usrp_source_0 = uhd.usrp_source( ",".join(("", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_source_0.set_samp_rate(samp_rate) self.uhd_usrp_source_0.set_center_freq(435000000, 0) self.uhd_usrp_source_0.set_gain(80, 0) self.uhd_usrp_source_0.set_antenna('TX/RX', 0) self.uhd_usrp_source_0.set_bandwidth(100000, 0) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=44100, decimation=2500000, taps=None, fractional_bw=None, ) self.blocks_wavfile_sink_0 = blocks.wavfile_sink( sys.argv[1], 1, 44100, 8) self.analog_am_demod_cf_0 = analog.am_demod_cf( channel_rate=44100, audio_decim=1, audio_pass=20000, audio_stop=21000, ) self.analog_agc2_xx_0 = analog.agc2_cc(.1, 1e-6, 1.0, 0) self.analog_agc2_xx_0.set_max_gain(5) ################################################## # Connections ################################################## self.connect((self.analog_agc2_xx_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.analog_am_demod_cf_0, 0), (self.blocks_wavfile_sink_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.analog_am_demod_cf_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.analog_agc2_xx_0, 0))
def __init__(self): gr.top_block.__init__(self, "Motorola CQUAM v1.4") ################################################## # Blocks ################################################## self.low_pass_filter_0 = filter.interp_fir_filter_ccf( 1, firdes.low_pass(1, 44100, 11e3, 1e3, firdes.WIN_BLACKMAN, 6.76)) self.blocks_wavfile_sink_0 = blocks.wavfile_sink( '/mnt/mediay/SEND/output_4.wav', 2, 44100, 16) self.blocks_sub_xx_0 = blocks.sub_ff(1) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((0.3, )) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blocks_complex_to_float_0 = blocks.complex_to_float(1) self.blocks_add_xx_3 = blocks.add_vff(1) self.blocks_add_xx_1 = blocks.add_vff(1) self.blocks_add_xx_0 = blocks.add_vff(1) self.audio_source_0 = audio.source(44100, 'tx_source', True) self.analog_sig_source_x_2_0_0 = analog.sig_source_f( 44100, analog.GR_SIN_WAVE, 25, 0.08, 0) self.analog_sig_source_x_2_0 = analog.sig_source_f( 44100, analog.GR_COS_WAVE, 0, 1, 0) ################################################## # Connections ################################################## self.connect((self.analog_sig_source_x_2_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.analog_sig_source_x_2_0_0, 0), (self.blocks_add_xx_3, 0)) self.connect((self.audio_source_0, 0), (self.blocks_add_xx_1, 0)) self.connect((self.audio_source_0, 1), (self.blocks_add_xx_1, 1)) self.connect((self.audio_source_0, 0), (self.blocks_sub_xx_0, 0)) self.connect((self.audio_source_0, 1), (self.blocks_sub_xx_0, 1)) self.connect((self.blocks_add_xx_0, 0), (self.blocks_float_to_complex_0, 1)) self.connect((self.blocks_add_xx_1, 0), (self.blocks_add_xx_0, 0)) self.connect((self.blocks_add_xx_3, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.blocks_complex_to_float_0, 1), (self.blocks_wavfile_sink_0, 1)) self.connect((self.blocks_complex_to_float_0, 0), (self.blocks_wavfile_sink_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.blocks_sub_xx_0, 0), (self.blocks_add_xx_3, 1)) self.connect((self.low_pass_filter_0, 0), (self.blocks_complex_to_float_0, 0))
def __init__(self): gr.top_block.__init__(self, 'Top Block') # sample frequency = 44100 Hz # 44100 discrete samples per second to reconstruct the signal when playing it back self.samp_rate = samp_rate = 44100 # data to hide centered at (44100 / 2 - 1000) = 21050 Hz # human ear can't catch sounds below 20 Hz or above 20 kHz (however regular audio players won't reproduce sounds at 21050 Hz) self.freq_xlating_fir_filter_xxx_0 = gnufilter.freq_xlating_fir_filter_ccc(1, (1, ), samp_rate / 2 - 1000, samp_rate) # one encoded bit each (44100 / 100) samples of audio self.digital_gfsk_mod_0 = digital.gfsk_mod( samples_per_symbol = samp_rate / 100, sensitivity = 0.01, bt = 0.35, verbose = False, log = False, ) # block that defines the source audio file self.blocks_wavfile_source_0 = blocks.wavfile_source(tmp_audio_extracted, False) # block that defines the destination audio file self.blocks_wavfile_sink_0 = blocks.wavfile_sink(tmp_audio_modified, 1, samp_rate, 16) # block that defines the source data file to hide self.blocks_file_source_0 = blocks.file_source(gr.sizeof_char * 1, tmp_data_formatted, True) # block that defines sample rate when processing the audio self.blocks_throttle_0 = blocks.throttle(gr.sizeof_float * 1, samp_rate, True) # block that reduces the amplitude of both waves to half, avoiding any possible distorsion coming from wave overlapping self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((.5, )) # block that transforms the complex gmsk signal to a real one so that it can be embedded into a wav file self.blocks_complex_to_real_0 = blocks.complex_to_real(1) # block that adds the original audio wave and the forged one self.blocks_add_xx_0 = blocks.add_vff(1) # connections between blocks self.connect((self.blocks_add_xx_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_complex_to_real_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.blocks_file_source_0, 0), (self.digital_gfsk_mod_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_wavfile_sink_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.blocks_wavfile_source_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.digital_gfsk_mod_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.blocks_complex_to_real_0, 0))
def __init__(self): gr.top_block.__init__(self, "Wbfmrx") ################################################## # Variables ################################################## self.samp_rate = samp_rate = 2500000 ################################################## # Blocks ################################################## self.uhd_usrp_source_0 = uhd.usrp_source( ",".join(("", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_source_0.set_samp_rate(samp_rate) self.uhd_usrp_source_0.set_center_freq(435000000, 0) self.uhd_usrp_source_0.set_gain(40, 0) self.uhd_usrp_source_0.set_antenna('TX/RX', 0) self.uhd_usrp_source_0.set_bandwidth(100000, 0) self.rational_resampler_xxx_1 = filter.rational_resampler_ccc( interpolation=192000, decimation=250000, taps=None, fractional_bw=None, ) self.low_pass_filter_0 = filter.fir_filter_ccf( 10, firdes.low_pass(1, samp_rate, 42000, 2100, firdes.WIN_HAMMING, 6.76)) self.blocks_wavfile_sink_0 = blocks.wavfile_sink( sys.argv[1], 1, 48000, 8) self.analog_wfm_rcv_0 = analog.wfm_rcv( quad_rate=192000, audio_decimation=4, ) ################################################## # Connections ################################################## self.connect((self.analog_wfm_rcv_0, 0), (self.blocks_wavfile_sink_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.rational_resampler_xxx_1, 0)) self.connect((self.rational_resampler_xxx_1, 0), (self.analog_wfm_rcv_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.low_pass_filter_0, 0))
def __init__(self, samp_rate=16E3, name="unnamed"): gr.hier_block2.__init__(self, "Recorder", gr.io_signature(1, 1, gr.sizeof_float), gr.io_signature(1, 1, gr.sizeof_float)) self.record_squelch = analog.pwr_squelch_ff(-200, 0.1, 0, True) self.blocks_wavfile_sink = blocks.wavfile_sink("/dev/null", 1, samp_rate, 16) self.blocks_null_source = blocks.null_source(gr.sizeof_float*1) self.connect(self, (self.record_squelch, 0)) self.connect((self.record_squelch, 0), (self.blocks_wavfile_sink, 0)) self.connect((self.blocks_null_source, 0), self) thread = threading.Thread(target=self.timer_thread, args=(name, self.blocks_wavfile_sink, self.record_squelch)) thread.daemon = True thread.start()
def __init__(self, carrier_freq_hi=1750, carrier_freq_lo=1080, input_path_hi='/tmp/remote.bin', input_path_lo='/tmp/local.bin', lo_delay=180): gr.top_block.__init__(self, "Dual Fsk Modulation") ################################################## # Parameters ################################################## self.carrier_freq_hi = carrier_freq_hi self.carrier_freq_lo = carrier_freq_lo self.input_path_hi = input_path_hi self.input_path_lo = input_path_lo self.lo_delay = lo_delay ################################################## # Variables ################################################## self.oversample = oversample = 1 self.samp_rate = samp_rate = 44100 self.baud = baud = 300/oversample self.fsk_deviation_hz = fsk_deviation_hz = 100 self.SPS = SPS = samp_rate/baud ################################################## # Blocks ################################################## self.digital_chunks_to_symbols_xx_0_0_0 = digital.chunks_to_symbols_bf(((2*3.14*carrier_freq_lo-2*3.14*fsk_deviation_hz,2*3.14*carrier_freq_lo+2*3.14*fsk_deviation_hz)), 1) self.digital_chunks_to_symbols_xx_0_0 = digital.chunks_to_symbols_bf(((2*3.14*carrier_freq_hi-2*3.14*fsk_deviation_hz,2*3.14*carrier_freq_hi+2*3.14*fsk_deviation_hz)), 1) self.blocks_wavfile_sink_0 = blocks.wavfile_sink('/tmp/data.wav', 1, samp_rate, 16) self.blocks_vco_f_0_0 = blocks.vco_f(samp_rate*oversample, 1, 0.25) self.blocks_vco_f_0 = blocks.vco_f(samp_rate*oversample, 1, 0.25) self.blocks_repeat_0_0 = blocks.repeat(gr.sizeof_float*1, SPS) self.blocks_repeat_0 = blocks.repeat(gr.sizeof_float*1, SPS) self.blocks_file_source_0_0 = blocks.file_source(gr.sizeof_char*1, input_path_lo, False) self.blocks_file_source_0 = blocks.file_source(gr.sizeof_char*1, input_path_hi, False) self.blocks_delay_0 = blocks.delay(gr.sizeof_float*1, lo_delay * SPS) self.blocks_add_xx_0 = blocks.add_vff(1) ################################################## # Connections ################################################## self.connect((self.blocks_add_xx_0, 0), (self.blocks_wavfile_sink_0, 0)) self.connect((self.blocks_delay_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.blocks_file_source_0, 0), (self.digital_chunks_to_symbols_xx_0_0, 0)) self.connect((self.blocks_file_source_0_0, 0), (self.digital_chunks_to_symbols_xx_0_0_0, 0)) self.connect((self.blocks_repeat_0, 0), (self.blocks_vco_f_0, 0)) self.connect((self.blocks_repeat_0_0, 0), (self.blocks_vco_f_0_0, 0)) self.connect((self.blocks_vco_f_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.blocks_vco_f_0_0, 0), (self.blocks_delay_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_0_0, 0), (self.blocks_repeat_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_0_0_0, 0), (self.blocks_repeat_0_0, 0))
def __init__(self): gr.top_block.__init__(self, "Top Block") ################################################## # Variables ################################################## self.taps = taps = [1.0, 0.25 - 0.25j, 0.50 + 0.10j, -0.3 + 0.2j] self.sps = sps = 4 self.samp_rate = samp_rate = 44100 self.qpsk = qpsk = digital.constellation_rect(([ 0.707 + 0.707j, -0.707 + 0.707j, -0.707 - 0.707j, 0.707 - 0.707j ]), ([0, 1, 3, 2]), 4, 2, 2, 1, 1).base() self.excess_bw = excess_bw = 0.35 ################################################## # Blocks ################################################## self.blocks_wavfile_sink = blocks.wavfile_sink('/tmp/challenge.wav', 2, samp_rate, 16) self.blocks_file_source = blocks.file_source(gr.sizeof_char * 1, '/tmp/input.txt', False) self.blocks_complex_to_real_0 = blocks.complex_to_real(1) self.blocks_complex_to_imag_0 = blocks.complex_to_imag(1) self.digital_constellation_modulator_0 = digital.generic_mod( constellation=qpsk, differential=True, samples_per_symbol=sps, pre_diff_code=True, excess_bw=excess_bw, verbose=False, log=False, ) ################################################## # Connections ################################################## self.connect((self.blocks_file_source, 0), (self.digital_constellation_modulator_0, 0)) self.connect((self.digital_constellation_modulator_0, 0), (self.blocks_complex_to_imag_0, 0)) self.connect((self.digital_constellation_modulator_0, 0), (self.blocks_complex_to_real_0, 0)) self.connect((self.blocks_complex_to_real_0, 0), (self.blocks_wavfile_sink, 0)) self.connect((self.blocks_complex_to_imag_0, 0), (self.blocks_wavfile_sink, 1))
def __init__(self): gr.top_block.__init__(self, "Not titled yet") Qt.QWidget.__init__(self) self.setWindowTitle("Not titled yet") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "ec415_lab1_kremerme_cgeron") try: if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"): self.restoreGeometry(self.settings.value("geometry").toByteArray()) else: self.restoreGeometry(self.settings.value("geometry")) except: pass ################################################## # Variables ################################################## self.samp_rate = samp_rate = 32000 ################################################## # Blocks ################################################## self.blocks_wavfile_sink_1 = blocks.wavfile_sink('/ad/eng/users/k/r/kremerme/Desktop/ec415/output_Feb_11.wav', 1, samp_rate, 8) self.analog_sig_source_x_0 = analog.sig_source_f(samp_rate, analog.GR_SIN_WAVE, 196, 1, 0, 0) ################################################## # Connections ################################################## self.connect((self.analog_sig_source_x_0, 0), (self.blocks_wavfile_sink_1, 0))
def __init__(self, rate, filename, squelch): gr.hier_block2.__init__(self, "logging_receiver", gr.io_signature(nchans, nchans, gr.sizeof_gr_complex), gr.io_signature(0,0,0)) self._rate = rate self._filename = filename self._squelch = squelch self._audiorate = 8000 self._decim = float(self._rate) / self._audiorate self._demod = fm_demod(self._rate, #rate self._decim, #audio decimation True) #gate samples when closed? self._valve = blks2.valve(gr.sizeof_float, False) self._audiosink = blocks.wavfile_sink(self._filename, 1, self._audiorate, 8) self.connect(self, self._demod, self._valve, self._audiosink)
def __init__(self, Filename="/home/uone/gnuradio/gnuradioworkspace/MyGraph/LPF/raw_wav.wav"): gr.top_block.__init__(self, "Top Block") Qt.QWidget.__init__(self) self.setWindowTitle("Top Block") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "top_block") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Parameters ################################################## self.Filename = Filename ################################################## # Variables ################################################## self.samp_rate = samp_rate = 32000 ################################################## # Blocks ################################################## self.low_pass_filter_0 = filter.fir_filter_fff(1, firdes.low_pass( 1, samp_rate, 4000, 1000, firdes.WIN_HAMMING, 6.76)) self.blocks_wavfile_sink_0 = blocks.wavfile_sink(Filename, 1, samp_rate, 8) self.audio_source_0 = audio.source(samp_rate, "", True) ################################################## # Connections ################################################## self.connect((self.audio_source_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.blocks_wavfile_sink_0, 0))
def __init__(self, filename="0.dat", freq=90.1e6, samp_rate=1e6): gr.top_block.__init__(self, "Fm Receiver") ################################################## # Parameters ################################################## self.filename = filename self.freq = freq self.samp_rate = samp_rate ################################################## # Variables ################################################## self.gain = gain = 30 self.audio_rate = audio_rate = 48e3 self.audio_interp = audio_interp = 4 ################################################## # Blocks ################################################## self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=int(audio_rate*audio_interp), decimation=int(samp_rate), taps=None, fractional_bw=None, ) self.low_pass_filter_0 = filter.interp_fir_filter_fff(1, firdes.low_pass( 1, int(audio_rate), 800, 100, firdes.WIN_HAMMING, 6.76)) self.blocks_wavfile_sink_0 = blocks.wavfile_sink("wav_out.wav", 1, int(audio_rate), 8) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True) self.blocks_interleaved_short_to_complex_0 = blocks.interleaved_short_to_complex(False, False) self.blocks_file_source_0_0 = blocks.file_source(gr.sizeof_short*1, filename, False) self.analog_wfm_rcv_0 = analog.wfm_rcv( quad_rate=int(audio_rate*audio_interp), audio_decimation=int(audio_interp), ) ################################################## # Connections ################################################## self.connect((self.analog_wfm_rcv_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.blocks_file_source_0_0, 0), (self.blocks_interleaved_short_to_complex_0, 0)) self.connect((self.blocks_interleaved_short_to_complex_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.blocks_wavfile_sink_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.analog_wfm_rcv_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Top Block") ################################################## # Variables ################################################## self.samp_rate = samp_rate = 32000 ################################################## # Blocks ################################################## self.low_pass_filter_0 = filter.interp_fir_filter_fff(1, firdes.low_pass( 1, samp_rate, 4000, 1000, firdes.WIN_HAMMING, 6.76)) self.blocks_wavfile_sink_0 = blocks.wavfile_sink("/home/mike-netbook/LinuxProgramming/gnuradio/42", 1, samp_rate, 8) self.audio_source_0 = audio.source(samp_rate, "", True) ################################################## # Connections ################################################## self.connect((self.audio_source_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.blocks_wavfile_sink_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Play Wav File") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 48000 ################################################## # Blocks ################################################## self.blocks_wavfile_source_0 = blocks.wavfile_source("/home/pi/Media-Convert_test2_PCM_Mono_VBR_8SS_48000Hz.wav", False) (self.blocks_wavfile_source_0).set_max_output_buffer(1) self.blocks_wavfile_sink_0 = blocks.wavfile_sink("/home/pi/output.wav", 1, samp_rate, 8) ################################################## # Connections ################################################## self.connect((self.blocks_wavfile_source_0, 0), (self.blocks_wavfile_sink_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Top Block") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.freq = freq = 400 self.samp_rate = samp_rate = 32000 self.fname = fname = str(freq)+".wav" ################################################## # Blocks ################################################## self.blocks_wavfile_sink_0 = blocks.wavfile_sink(fname, 1, samp_rate, 8) self.analog_sig_source_x_0 = analog.sig_source_f(samp_rate, analog.GR_COS_WAVE, freq, 1, 0) (self.analog_sig_source_x_0).set_min_output_buffer(1024) ################################################## # Connections ################################################## self.connect((self.analog_sig_source_x_0, 0), (self.blocks_wavfile_sink_0, 0))
def __init__(self): gr.top_block.__init__(self) parser = ArgumentParser() parser.add_argument("-r", "--sample-rate", type=eng_float, default=48000, help="set sample rate to RATE (%(default)r)") parser.add_argument("-N", "--samples", type=eng_float, required=True, help="number of samples to record") parser.add_argument('file_name', metavar='WAV-FILE', help='Output WAV file name', nargs=1) args = parser.parse_args() sample_rate = int(args.sample_rate) ampl = 0.1 src0 = analog.sig_source_f(sample_rate, analog.GR_SIN_WAVE, 350, ampl) src1 = analog.sig_source_f(sample_rate, analog.GR_SIN_WAVE, 440, ampl) head0 = blocks.head(gr.sizeof_float, int(args.samples)) head1 = blocks.head(gr.sizeof_float, int(args.samples)) dst = blocks.wavfile_sink(args.file_name[0], 2, int(args.sample_rate), 16) self.connect(src0, head0, (dst, 0)) self.connect(src1, head1, (dst, 1))
def test_002_checkwavcopy(self): infile = g_in_file outfile = "test_out.wav" wf_in = blocks.wavfile_source(infile) wf_out = blocks.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): grc_wxgui.top_block_gui.__init__(self, title="Fmrx Without Echo") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 10e6 self.freq = freq = 97.9e6 self.channel_width = channel_width = 200e3 self.channel_freq = channel_freq = 96.5e6 self.center_freq = center_freq = 97.9e6 self.audio_gain = audio_gain = 1 ################################################## # Blocks ################################################## _freq_sizer = wx.BoxSizer(wx.VERTICAL) self._freq_text_box = forms.text_box( parent=self.GetWin(), sizer=_freq_sizer, value=self.freq, callback=self.set_freq, label="Frequency", converter=forms.float_converter(), proportion=0, ) self._freq_slider = forms.slider( parent=self.GetWin(), sizer=_freq_sizer, value=self.freq, callback=self.set_freq, minimum=80e6, maximum=120e6, num_steps=1000, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_freq_sizer) _audio_gain_sizer = wx.BoxSizer(wx.VERTICAL) self._audio_gain_text_box = forms.text_box( parent=self.GetWin(), sizer=_audio_gain_sizer, value=self.audio_gain, callback=self.set_audio_gain, label='audio_gain', converter=forms.float_converter(), proportion=0, ) self._audio_gain_slider = forms.slider( parent=self.GetWin(), sizer=_audio_gain_sizer, value=self.audio_gain, callback=self.set_audio_gain, minimum=0, maximum=10, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_audio_gain_sizer) self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.GetWin(), baseband_freq=freq, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=samp_rate, fft_size=1024, fft_rate=15, average=True, avg_alpha=None, title="FFT Plot", peak_hold=False, ) self.Add(self.wxgui_fftsink2_0.win) self.rational_resampler_xxx_0 = filter.rational_resampler_ccf( interpolation=12, decimation=5, taps=None, fractional_bw=None, ) self.osmosdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + "" ) self.osmosdr_source_0.set_sample_rate(samp_rate) self.osmosdr_source_0.set_center_freq(freq, 0) self.osmosdr_source_0.set_freq_corr(0, 0) self.osmosdr_source_0.set_dc_offset_mode(0, 0) self.osmosdr_source_0.set_iq_balance_mode(0, 0) self.osmosdr_source_0.set_gain_mode(False, 0) self.osmosdr_source_0.set_gain(50, 0) self.osmosdr_source_0.set_if_gain(20, 0) self.osmosdr_source_0.set_bb_gain(20, 0) self.osmosdr_source_0.set_antenna("", 0) self.osmosdr_source_0.set_bandwidth(0, 0) self.low_pass_filter_0 = filter.fir_filter_ccf(int(samp_rate/channel_width), firdes.low_pass( 1, samp_rate, 75e3, 25e3, firdes.WIN_HAMMING, 6.76)) self.blocks_wavfile_sink_0 = blocks.wavfile_sink("/home/ubuntu/audio", 1, int(48e3), 8) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((audio_gain, )) self.audio_sink_0 = audio.sink(48000, "", False) self.analog_wfm_rcv_0 = analog.wfm_rcv( quad_rate=480e3, audio_decimation=10, ) self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, freq - channel_freq, 1, 0) ################################################## # Connections ################################################## self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.analog_wfm_rcv_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.audio_sink_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_wavfile_sink_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.analog_wfm_rcv_0, 0))
def __init__(self): gr.top_block.__init__(self, "Ham2Mon NBFM Receiver Flow Example") Qt.QWidget.__init__(self) self.setWindowTitle("Ham2Mon NBFM Receiver Flow Example") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "nbfm_flow_example") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 1E6 self.initial_decim = initial_decim = 5 self.samp_ratio = samp_ratio = samp_rate/1E6 self.final_rate = final_rate = samp_rate/initial_decim**2/int(samp_rate/1E6) self.variable_low_pass_filter_taps_2 = variable_low_pass_filter_taps_2 = firdes.low_pass(1.0, final_rate, 3500, 500, firdes.WIN_HAMMING, 6.76) self.variable_low_pass_filter_taps_1 = variable_low_pass_filter_taps_1 = firdes.low_pass(1.0, samp_rate/25, 12.5E3, 1E3, firdes.WIN_HAMMING, 6.76) self.variable_low_pass_filter_taps_0 = variable_low_pass_filter_taps_0 = firdes.low_pass(1.0, 1, 0.090, 0.010, firdes.WIN_HAMMING, 6.76) self.squelch_dB = squelch_dB = -70 self.gain_db = gain_db = 30 self.final_decim = final_decim = int(samp_rate/1E6) self.file_name = file_name = "test.wav" self.fft_length = fft_length = 256 * int(pow(2, np.ceil(np.log(samp_ratio)/np.log(2)))) self.demod_bb_freq = demod_bb_freq = 390E3 self.center_freq = center_freq = 144E6 ################################################## # Blocks ################################################## self._squelch_dB_range = Range(-100, 0, 5, -70, 200) self._squelch_dB_win = RangeWidget(self._squelch_dB_range, self.set_squelch_dB, "Squelch (dB)", "counter_slider", float) self.top_grid_layout.addWidget(self._squelch_dB_win, 5,1,1,3) self._gain_db_range = Range(0, 70, 1, 30, 200) self._gain_db_win = RangeWidget(self._gain_db_range, self.set_gain_db, "HW Gain (dB)", "counter_slider", float) self.top_grid_layout.addWidget(self._gain_db_win, 4,1,1,3) self._demod_bb_freq_range = Range(-samp_rate/2, samp_rate/2, 5E3, 390E3, 200) self._demod_bb_freq_win = RangeWidget(self._demod_bb_freq_range, self.set_demod_bb_freq, "Demod BB Freq (Hz)", "counter_slider", float) self.top_grid_layout.addWidget(self._demod_bb_freq_win, 3,1,1,3) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( fft_length, #size samp_rate, #samp_rate "Averaged Spectrum", #name 1 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-60, 40) self.qtgui_time_sink_x_0.set_y_label("Power", "") self.qtgui_time_sink_x_0.enable_tags(-1, True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(False) self.qtgui_time_sink_x_0.enable_grid(False) self.qtgui_time_sink_x_0.enable_control_panel(False) if not True: self.qtgui_time_sink_x_0.disable_legend() labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_win, 0,1,3,1) self.qtgui_freq_sink_x_0_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc final_rate, #bw "Decimated Channel", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0_0.set_update_time(0.10) self.qtgui_freq_sink_x_0_0.set_y_axis(-200, -60) self.qtgui_freq_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0_0.enable_autoscale(False) self.qtgui_freq_sink_x_0_0.enable_grid(False) self.qtgui_freq_sink_x_0_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0_0.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_0_0.disable_legend() if complex == type(float()): self.qtgui_freq_sink_x_0_0.set_plot_pos_half(not True) labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue"] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_0_win, 3,0,3,1) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( fft_length, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 144E6, #fc samp_rate, #bw "Spectrum", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-120, -20) self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(False) self.qtgui_freq_sink_x_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_0.disable_legend() if complex == type(float()): self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue"] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win, 0,0,3,1) self.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_fff( 16E3/float(final_rate/5), taps=None, flt_size=32) self.pfb_arb_resampler_xxx_0.declare_sample_delay(0) self.osmosdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + "uhd" ) self.osmosdr_source_0.set_sample_rate(samp_rate) self.osmosdr_source_0.set_center_freq(center_freq, 0) self.osmosdr_source_0.set_freq_corr(0, 0) self.osmosdr_source_0.set_dc_offset_mode(0, 0) self.osmosdr_source_0.set_iq_balance_mode(0, 0) self.osmosdr_source_0.set_gain_mode(False, 0) self.osmosdr_source_0.set_gain(gain_db, 0) self.osmosdr_source_0.set_if_gain(20, 0) self.osmosdr_source_0.set_bb_gain(20, 0) self.osmosdr_source_0.set_antenna("", 0) self.osmosdr_source_0.set_bandwidth(samp_rate*0.8, 0) self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(initial_decim, (variable_low_pass_filter_taps_0), demod_bb_freq, samp_rate) self.fir_filter_xxx_0_1 = filter.fir_filter_fff(initial_decim, (variable_low_pass_filter_taps_0)) self.fir_filter_xxx_0_1.declare_sample_delay(0) self.fir_filter_xxx_0_0 = filter.fir_filter_ccc(int(samp_rate/1E6), (variable_low_pass_filter_taps_0)) self.fir_filter_xxx_0_0.declare_sample_delay(0) self.fir_filter_xxx_0 = filter.fir_filter_ccc(initial_decim, (variable_low_pass_filter_taps_0)) self.fir_filter_xxx_0.declare_sample_delay(0) self.fft_vxx_0 = fft.fft_vcc(fft_length, True, (window.blackmanharris(fft_length)), True, 1) self.blocks_wavfile_sink_0 = blocks.wavfile_sink(file_name, 1, 16000, 8) self.blocks_vector_to_stream_0 = blocks.vector_to_stream(gr.sizeof_float*1, fft_length) self.blocks_stream_to_vector_0 = blocks.stream_to_vector(gr.sizeof_gr_complex*1, fft_length) self.blocks_probe_signal_vx_0 = blocks.probe_signal_vf(fft_length) self.blocks_nlog10_ff_0 = blocks.nlog10_ff(10, fft_length, 0) self.blocks_keep_one_in_n_0 = blocks.keep_one_in_n(gr.sizeof_gr_complex*fft_length, int(round(samp_rate/fft_length/1000))) self.blocks_integrate_xx_0 = blocks.integrate_ff(100, fft_length) self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(fft_length) self.audio_sink_0 = audio.sink(16000, "", True) self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(0.050) self.analog_pwr_squelch_xx_0_0 = analog.pwr_squelch_ff(-200, 0.1, 0, True) self.analog_pwr_squelch_xx_0 = analog.pwr_squelch_cc(squelch_dB, 0.1, 0, False) ################################################## # Connections ################################################## self.connect((self.analog_pwr_squelch_xx_0, 0), (self.analog_quadrature_demod_cf_0, 0)) self.connect((self.analog_pwr_squelch_xx_0_0, 0), (self.blocks_wavfile_sink_0, 0)) self.connect((self.analog_quadrature_demod_cf_0, 0), (self.fir_filter_xxx_0_1, 0)) self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.blocks_integrate_xx_0, 0)) self.connect((self.blocks_integrate_xx_0, 0), (self.blocks_nlog10_ff_0, 0)) self.connect((self.blocks_keep_one_in_n_0, 0), (self.fft_vxx_0, 0)) self.connect((self.blocks_nlog10_ff_0, 0), (self.blocks_probe_signal_vx_0, 0)) self.connect((self.blocks_nlog10_ff_0, 0), (self.blocks_vector_to_stream_0, 0)) self.connect((self.blocks_stream_to_vector_0, 0), (self.blocks_keep_one_in_n_0, 0)) self.connect((self.blocks_vector_to_stream_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.fft_vxx_0, 0), (self.blocks_complex_to_mag_squared_0, 0)) self.connect((self.fir_filter_xxx_0, 0), (self.fir_filter_xxx_0_0, 0)) self.connect((self.fir_filter_xxx_0_0, 0), (self.analog_pwr_squelch_xx_0, 0)) self.connect((self.fir_filter_xxx_0_0, 0), (self.qtgui_freq_sink_x_0_0, 0)) self.connect((self.fir_filter_xxx_0_1, 0), (self.pfb_arb_resampler_xxx_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.fir_filter_xxx_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.blocks_stream_to_vector_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.analog_pwr_squelch_xx_0_0, 0)) self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.audio_sink_0, 0))
def __init__(self): gr.top_block.__init__(self) parser = ArgumentParser(description="Decode WFM signal into WAV file.") parser.add_argument("-V", "--volume", type=eng_float, help="Volume (dB) <%r, %r> (default is midpoint)" % \ self.volume_range()[:2]) parser.add_argument("input_file", help="Input file (complex samples)") parser.add_argument("output_file", help="Output WAV file") args = parser.parse_args() self.vol = 0 # build graph self.src = blocks.file_source(gr.sizeof_gr_complex, args.input_file, False) adc_rate = 64e6 # 64 MS/s usrp_decim = 200 usrp_rate = adc_rate / usrp_decim # 320 kS/s chanfilt_decim = 1 demod_rate = usrp_rate / chanfilt_decim audio_decimation = 10 audio_rate = demod_rate / audio_decimation # 32 kHz chan_filt_coeffs = filter.optfir.low_pass (1, # gain usrp_rate, # sampling rate 80e3, # passband cutoff 115e3, # stopband cutoff 0.1, # passband ripple 60) # stopband attenuation #print len(chan_filt_coeffs) chan_filt = filter.fir_filter_ccf (chanfilt_decim, chan_filt_coeffs) #self.guts = analog.wfm_rcv (demod_rate, audio_decimation) self.guts = analog.wfm_rcv_pll (demod_rate, audio_decimation) # FIXME rework {add,multiply}_const_* to handle multiple streams self.volume_control_l = blocks.multiply_const_ff(self.vol) self.volume_control_r = blocks.multiply_const_ff(self.vol) # wave file as final sink if 1: sink = blocks.wavfile_sink(args.output_file, 2, int(audio_rate), 16) else: sink = audio.sink (int (audio_rate), args.audio_output, False) # ok_to_block # now wire it all together self.connect (self.src, chan_filt, self.guts) self.connect ((self.guts, 0), self.volume_control_l, (sink, 0)) self.connect ((self.guts, 1), self.volume_control_r, (sink, 1)) if args.volume is None: g = self.volume_range() args.volume = float(g[0]+g[1]) / 2 # set initial values self.set_vol(args.volume)
def __init__(self, win, sat_name, audio_fname, pipe_fname = None, rec_gain = 50000, af_gain = 0.3): gr.hier_block2.__init__(self, "Channel "+str(sat_name)+" Audio", gr.io_signature(1, 1, gr.sizeof_gr_complex), gr.io_signature(0, 0, 0)) self.sample_rate = sample_rate = 32000 self.rec_gain = rec_gain self.af_gain = af_gain self.multiply_const_af_gain = blocks.multiply_const_vff((af_gain, )) self.float_to_short = blocks.float_to_short(1, rec_gain) self.file_sink_file = blocks.file_sink(gr.sizeof_short*1, str(audio_fname)) self.file_sink_file.set_unbuffered(False) self.multiply_const_wav_gain = blocks.multiply_const_vff((0.03, )) self.wavfile_sink = blocks.wavfile_sink(str(audio_fname)+'.wav', 1, 8000, 8) self.wavfile_11k_sink = blocks.wavfile_sink(str(audio_fname)+'.11025.wav', 1, 11025, 8) if pipe_fname is not None: self.file_sink_pipe = blocks.file_sink(gr.sizeof_short*1, str(pipe_fname)) self.file_sink_pipe.set_unbuffered(False) self.rational_resampler_48k = filter.rational_resampler_fff( interpolation=48, decimation=32, taps=None, fractional_bw=None, ) self.rational_resampler_22050 = filter.rational_resampler_fff( interpolation=2205, decimation=sample_rate/10, taps=None, fractional_bw=None, ) self.rational_resampler_8k = filter.rational_resampler_fff( interpolation=8, decimation=32, taps=None, fractional_bw=None, ) self.rational_resampler_11025 = filter.rational_resampler_fff( interpolation=11025, decimation=32000, taps=None, fractional_bw=None, ) self.audio_sink = audio.sink(sampling_rate=48000, ok_to_block=True) ################################################## # Connections ################################################## self.connect(self, (self.rational_resampler_22050, 0)) self.connect(self, (self.rational_resampler_48k, 0)) self.connect(self, (self.rational_resampler_8k, 0)) self.connect(self, (self.rational_resampler_11025, 0)) self.connect((self.rational_resampler_48k, 0), (self.multiply_const_af_gain, 0)) self.connect((self.multiply_const_af_gain, 0), (self.audio_sink, 0)) self.connect((self.rational_resampler_22050, 0), (self.float_to_short, 0)) self.connect((self.float_to_short, 0), (self.file_sink_file, 0)) if pipe_fname is not None: self.connect((self.float_to_short, 0), (self.file_sink_pipe, 0)) self.connect((self.rational_resampler_8k, 0), (self.multiply_const_wav_gain, 0)) self.connect((self.multiply_const_wav_gain, 0), (self.wavfile_sink, 0)) self.connect((self.rational_resampler_11025, 0), (self.wavfile_11k_sink, 0))
def __init__(self): gr.top_block.__init__(self) usage = "usage: %prog [options] input-samples-320kS.dat output.wav" parser = OptionParser(option_class=eng_option, usage=usage) parser.add_option("-V", "--volume", type="eng_float", default=None, help="set volume (default is midpoint)") (options, args) = parser.parse_args() if len(args) != 2: parser.print_help() sys.exit(1) input_filename = args[0] output_filename = args[1] self.vol = 0 # build graph self.src = blocks.file_source(gr.sizeof_gr_complex, input_filename, False) adc_rate = 64e6 # 64 MS/s usrp_decim = 200 usrp_rate = adc_rate / usrp_decim # 320 kS/s chanfilt_decim = 1 demod_rate = usrp_rate / chanfilt_decim audio_decimation = 10 audio_rate = demod_rate / audio_decimation # 32 kHz chan_filt_coeffs = optfir.low_pass( 1, # gain usrp_rate, # sampling rate 80e3, # passband cutoff 115e3, # stopband cutoff 0.1, # passband ripple 60, ) # stopband attenuation # print len(chan_filt_coeffs) chan_filt = filter.fir_filter_ccf(chanfilt_decim, chan_filt_coeffs) # self.guts = analog.wfm_rcv (demod_rate, audio_decimation) self.guts = analog.wfm_rcv_pll(demod_rate, audio_decimation) # FIXME rework {add,multiply}_const_* to handle multiple streams self.volume_control_l = blocks.multiply_const_ff(self.vol) self.volume_control_r = blocks.multiply_const_ff(self.vol) # wave file as final sink if 1: sink = blocks.wavfile_sink(output_filename, 2, int(audio_rate), 16) else: sink = audio.sink(int(audio_rate), options.audio_output, False) # ok_to_block # now wire it all together self.connect(self.src, chan_filt, self.guts) self.connect((self.guts, 0), self.volume_control_l, (sink, 0)) self.connect((self.guts, 1), self.volume_control_r, (sink, 1)) try: self.guts.stereo_carrier_pll_recovery.squelch_enable(True) except: pass # print "FYI: This implementation of the stereo_carrier_pll_recovery has no squelch implementation yet" if options.volume is None: g = self.volume_range() options.volume = float(g[0] + g[1]) / 2 # set initial values self.set_vol(options.volume) try: self.guts.stereo_carrier_pll_recovery.set_lock_threshold(options.squelch) except: pass
def update_wav_sink(self): self.blocks_wavfile_sink_0 = blocks.wavfile_sink(self.output_file, 1, self.samp_rate, 16)
def __init__(self,DRMParameters): gr.top_block.__init__(self, "DRM Transmitter 1") ################################################## # Variables ################################################## self.text_message = text_message = DRMParameters.text_msg self.station_label = station_label = DRMParameters.station_label self.msc_prot_level_2 = msc_prot_level_2 = 1 self.long_interl = long_interl = True self.audio_sample_rate = audio_sample_rate = DRMParameters.audio_samp*1000 self.SO = SO = DRMParameters.so self.RM = RM = DRMParameters.rm self.tp = tp = drm.transm_params(RM, SO, False, 0, DRMParameters.msc_mod, 0, msc_prot_level_2, DRMParameters.sdc_mod, 0, long_interl, audio_sample_rate, station_label, text_message) self.samp_rate = samp_rate = 48e3 self.usrp_addr = DRMParameters.usrp_id self.output_name = DRMParameters.output_name self.center_freq = DRMParameters.center_freq*1e6 self.audio_file = DRMParameters.audio_file ################################################## # Blocks ################################################## if DRMParameters.uhd_found: self.uhd_usrp_sink_0 = uhd.usrp_sink( ",".join((self.usrp_addr, "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink_0.set_samp_rate(samp_rate * 250 / 48) self.uhd_usrp_sink_0.set_center_freq(self.center_freq, 0) self.uhd_usrp_sink_0.set_gain(0, 0) self.uhd_usrp_sink_0.set_antenna("TXA", 0) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=250, decimation=48, taps=None, fractional_bw=None, ) self.fft_vxx_0 = fft.fft_vcc(tp.ofdm().nfft(), False, (), True, 1) self.drm_scrambler_bb_0_1 = drm.scrambler_bb(tp.sdc().L()) self.drm_scrambler_bb_0_0 = drm.scrambler_bb(tp.fac().L()) self.drm_scrambler_bb_0 = drm.scrambler_bb(tp.msc().L_MUX()) self.drm_mlc_fac_bc = drm.make_mlc( channel_type="FAC", tp=tp ) #SDC Configuration self.drm_mlc_sdc_bc= drm.make_mlc( channel_type="SDC", tp=tp ) #MSC Configuration self.drm_mlc_msc_bc = drm.make_mlc( channel_type="MSC", tp=tp ) self.drm_interleaver_cc_0 = drm.interleaver_cc((tp.msc().cell_interl_seq()), long_interl, drm.INTL_DEPTH_DRM) self.drm_generate_sdc_b_0 = drm.generate_sdc_b(tp) self.drm_generate_fac_b_0 = drm.generate_fac_b(tp) self.drm_audio_encoder_sb_0 = drm.audio_encoder_sb(tp) self.digital_ofdm_cyclic_prefixer_1 = digital.ofdm_cyclic_prefixer(tp.ofdm().nfft(), tp.ofdm().nfft()+tp.ofdm().nfft()*tp.ofdm().cp_ratio_enum()/tp.ofdm().cp_ratio_denom(), 0, "") self.cell_mapping_cc_0 = drm.cell_mapping_cc(tp, (tp.msc().N_MUX() * tp.ofdm().M_TF() * 8, tp.sdc().N() * 8, tp.fac().N() * tp.ofdm().M_TF() * 8)) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_float*1) if DRMParameters.pulse_audio: self.audio_source_1 = audio.source(audio_sample_rate, "", True) else: self.blocks_wavfile_source_0 = blocks.wavfile_source(self.audio_file, False) if DRMParameters.gen_output: self.blocks_wavfile_sink_0 = blocks.wavfile_sink(self.output_name, 1, 48000, 16) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vcc((7e-3, )) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((32768, )) self.blocks_complex_to_real_0 = blocks.complex_to_real(1) self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, 7000, 1, 0) ################################################## # Connections ################################################## self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) if DRMParameters.gen_output: self.connect((self.blocks_complex_to_real_0, 0), (self.blocks_wavfile_sink_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.drm_audio_encoder_sb_0, 0)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_complex_to_real_0, 0)) if DRMParameters.pulse_audio: self.connect((self.audio_source_1, 0), (self.blocks_multiply_const_vxx_0, 0)) else: self.connect((self.blocks_wavfile_source_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.cell_mapping_cc_0, 0), (self.fft_vxx_0, 0)) self.connect((self.digital_ofdm_cyclic_prefixer_1, 0), (self.blocks_multiply_const_vxx_1, 0)) self.connect((self.drm_audio_encoder_sb_0, 0), (self.drm_scrambler_bb_0, 0)) self.connect((self.drm_generate_fac_b_0, 0), (self.drm_scrambler_bb_0_0, 0)) self.connect((self.drm_generate_sdc_b_0, 0), (self.drm_scrambler_bb_0_1, 0)) self.connect((self.drm_interleaver_cc_0, 0), (self.cell_mapping_cc_0, 0)) self.connect((self.drm_mlc_msc_bc, 0), (self.drm_interleaver_cc_0, 0)) self.connect((self.drm_mlc_sdc_bc, 0), (self.cell_mapping_cc_0, 1)) self.connect((self.drm_mlc_fac_bc, 0), (self.cell_mapping_cc_0, 2)) self.connect((self.drm_scrambler_bb_0, 0), (self.drm_mlc_msc_bc, 0)) self.connect((self.drm_scrambler_bb_0_0, 0), (self.drm_mlc_fac_bc, 0)) self.connect((self.drm_scrambler_bb_0_1, 0), (self.drm_mlc_sdc_bc, 0)) self.connect((self.fft_vxx_0, 0), (self.digital_ofdm_cyclic_prefixer_1, 0)) if DRMParameters.uhd_found: self.connect((self.rational_resampler_xxx_0, 0), (self.uhd_usrp_sink_0, 0)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.blocks_complex_to_real_0, 0), (self.blocks_null_sink_0, 0))
def __init__(self, samp_rate=4E6, audio_rate=8000, record=True): gr.hier_block2.__init__(self, "TunerDemodNBFM", gr.io_signature(1, 1, gr.sizeof_gr_complex), gr.io_signature(1, 1, gr.sizeof_float)) # Default values self.center_freq = 0 squelch_db = -60 self.quad_demod_gain = 0.050 self.file_name = "/dev/null" self.record = record # Decimation values for four stages of decimation decims = (5, int(samp_rate/1E6)) # Low pass filter taps for decimation by 5 low_pass_filter_taps_0 = \ grfilter.firdes_low_pass(1, 1, 0.090, 0.010, grfilter.firdes.WIN_HAMMING) # Frequency translating FIR filter decimating by 5 self.freq_xlating_fir_filter_ccc = \ grfilter.freq_xlating_fir_filter_ccc(decims[0], low_pass_filter_taps_0, self.center_freq, samp_rate) # FIR filter decimating by 5 fir_filter_ccc_0 = grfilter.fir_filter_ccc(decims[0], low_pass_filter_taps_0) # Low pass filter taps for decimation from samp_rate/25 to 40-79.9 ksps # In other words, decimation by int(samp_rate/1E6) # 12.5 kHz cutoff for NBFM channel bandwidth low_pass_filter_taps_1 = grfilter.firdes_low_pass( 1, samp_rate/decims[0]**2, 12.5E3, 1E3, grfilter.firdes.WIN_HAMMING) # FIR filter decimation by int(samp_rate/1E6) fir_filter_ccc_1 = grfilter.fir_filter_ccc(decims[1], low_pass_filter_taps_1) # Non blocking power squelch self.analog_pwr_squelch_cc = analog.pwr_squelch_cc(squelch_db, 1e-1, 0, False) # Quadrature demod with gain set for decent audio # The gain will be later multiplied by the 0 dB normalized volume self.analog_quadrature_demod_cf = \ analog.quadrature_demod_cf(self.quad_demod_gain) # 3.5 kHz cutoff for audio bandwidth low_pass_filter_taps_2 = grfilter.firdes_low_pass(1,\ samp_rate/(decims[1] * decims[0]**2),\ 3.5E3, 500, grfilter.firdes.WIN_HAMMING) # FIR filter decimating by 5 from 40-79.9 ksps to 8-15.98 ksps fir_filter_fff_0 = grfilter.fir_filter_fff(decims[0], low_pass_filter_taps_2) # Polyphase resampler allows arbitary RF sample rates # Takes 8-15.98 ksps to a constant 8 ksps for audio pfb_resamp = audio_rate/float(samp_rate/(decims[1] * decims[0]**3)) pfb_arb_resampler_fff = pfb.arb_resampler_fff(pfb_resamp, taps=None, flt_size=32) # Connect the blocks for the demod self.connect(self, self.freq_xlating_fir_filter_ccc) self.connect(self.freq_xlating_fir_filter_ccc, fir_filter_ccc_0) self.connect(fir_filter_ccc_0, fir_filter_ccc_1) self.connect(fir_filter_ccc_1, self.analog_pwr_squelch_cc) self.connect(self.analog_pwr_squelch_cc, self.analog_quadrature_demod_cf) self.connect(self.analog_quadrature_demod_cf, fir_filter_fff_0) self.connect(fir_filter_fff_0, pfb_arb_resampler_fff) self.connect(pfb_arb_resampler_fff, self) # Need to set this to a very low value of -200 since it is after demod # Only want it to gate when the previuos squelch has gone to zero analog_pwr_squelch_ff = analog.pwr_squelch_ff(-200, 1e-1, 0, True) # File sink with single channel and 8 bits/sample self.blocks_wavfile_sink = blocks.wavfile_sink(self.file_name, 1, audio_rate, 8) # Connect the blocks for recording self.connect(pfb_arb_resampler_fff, analog_pwr_squelch_ff) self.connect(analog_pwr_squelch_ff, self.blocks_wavfile_sink)
def __init__(self, samp_rate=4E6, audio_rate=8000, record=True): gr.hier_block2.__init__(self, "TunerDemodAM", gr.io_signature(1, 1, gr.sizeof_gr_complex), gr.io_signature(1, 1, gr.sizeof_float)) # Default values self.center_freq = 0 squelch_db = -60 self.agc_ref = 0.1 self.file_name = "/dev/null" self.record = record # Decimation values for four stages of decimation decims = (5, int(samp_rate/1E6)) # Low pass filter taps for decimation by 5 low_pass_filter_taps_0 = \ grfilter.firdes_low_pass(1, 1, 0.090, 0.010, grfilter.firdes.WIN_HAMMING) # Frequency translating FIR filter decimating by 5 self.freq_xlating_fir_filter_ccc = \ grfilter.freq_xlating_fir_filter_ccc(decims[0], low_pass_filter_taps_0, self.center_freq, samp_rate) # FIR filter decimating by 5 fir_filter_ccc_0 = grfilter.fir_filter_ccc(decims[0], low_pass_filter_taps_0) # Low pass filter taps for decimation from samp_rate/25 to 40-79.9 ksps # In other words, decimation by int(samp_rate/1E6) # 12.5 kHz cutoff for NBFM channel bandwidth low_pass_filter_taps_1 = grfilter.firdes_low_pass( 1, samp_rate/decims[0]**2, 12.5E3, 1E3, grfilter.firdes.WIN_HAMMING) # FIR filter decimation by int(samp_rate/1E6) fir_filter_ccc_1 = grfilter.fir_filter_ccc(decims[1], low_pass_filter_taps_1) # Non blocking power squelch # Squelch level needs to be lower than NBFM or else choppy AM demod self.analog_pwr_squelch_cc = analog.pwr_squelch_cc(squelch_db, 1e-1, 0, False) # AGC with reference set for nomninal 0 dB volume # Paramaters tweaked to prevent impulse during squelching self.agc3_cc = analog.agc3_cc(1.0, 1E-4, self.agc_ref, 10, 1) self.agc3_cc.set_max_gain(65536) # AM demod with complex_to_mag() # Can't use analog.am_demod_cf() since it won't work with N>2 demods am_demod_cf = blocks.complex_to_mag(1) # 3.5 kHz cutoff for audio bandwidth low_pass_filter_taps_2 = grfilter.firdes_low_pass(1,\ samp_rate/(decims[1] * decims[0]**2),\ 3.5E3, 500, grfilter.firdes.WIN_HAMMING) # FIR filter decimating by 5 from 40-79.9 ksps to 8-15.98 ksps fir_filter_fff_0 = grfilter.fir_filter_fff(decims[0], low_pass_filter_taps_2) # Polyphase resampler allows arbitary RF sample rates # Takes 8-15.98 ksps to a constant 8 ksps for audio pfb_resamp = audio_rate/float(samp_rate/(decims[1] * decims[0]**3)) pfb_arb_resampler_fff = pfb.arb_resampler_fff(pfb_resamp, taps=None, flt_size=32) # Connect the blocks for the demod self.connect(self, self.freq_xlating_fir_filter_ccc) self.connect(self.freq_xlating_fir_filter_ccc, fir_filter_ccc_0) self.connect(fir_filter_ccc_0, fir_filter_ccc_1) self.connect(fir_filter_ccc_1, self.analog_pwr_squelch_cc) self.connect(self.analog_pwr_squelch_cc, self.agc3_cc) self.connect(self.agc3_cc, am_demod_cf) self.connect(am_demod_cf, fir_filter_fff_0) self.connect(fir_filter_fff_0, pfb_arb_resampler_fff) self.connect(pfb_arb_resampler_fff, self) # Need to set this to a very low value of -200 since it is after demod # Only want it to gate when the previuos squelch has gone to zero analog_pwr_squelch_ff = analog.pwr_squelch_ff(-200, 1e-1, 0, True) # File sink with single channel and 8 bits/sample self.blocks_wavfile_sink = blocks.wavfile_sink(self.file_name, 1, audio_rate, 8) # Connect the blocks for recording self.connect(pfb_arb_resampler_fff, analog_pwr_squelch_ff) self.connect(analog_pwr_squelch_ff, self.blocks_wavfile_sink)