def __init__(self, destination='localhost', device='', port=7355):
        gr.top_block.__init__(self, "Audio source streamer")

        ##################################################
        # Parameters
        ##################################################
        self.destination = destination
        self.device = device
        self.port = port

        ##################################################
        # Blocks
        ##################################################
        self.blocks_udp_sink_0 = blocks.udp_sink(gr.sizeof_short * 1,
                                                 destination, port, 1472, True)
        self.blocks_float_to_short_0 = blocks.float_to_short(1, 32767)
        self.audio_source_0 = audio.source(48000, device, True)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.audio_source_0, 0),
                     (self.blocks_float_to_short_0, 0))
        self.connect((self.blocks_float_to_short_0, 0),
                     (self.blocks_udp_sink_0, 0))
    def __init__(self, options, queue):
        gr.top_block.__init__(self, "mhp")

        self.audio_amps = []
        self.converters = []
        self.vocoders = []
        self.output_files = []

        input_audio_rate = 8000
        self.audio_input = audio.source(input_audio_rate, options.audio_input)

        for i in range(options.nchannels):
            udp_port = options.udp_port + i
            if options.output_files:
                t = gr.file_sink(gr.sizeof_char, "baseband-%d.dat" % i)
                self.output_files.append(t)
                udp_port = 0
            t = gr.multiply_const_ff(32767 * options.audio_gain)
            self.audio_amps.append(t)
            t = gr.float_to_short()
            self.converters.append(t)
            t = repeater.vocoder(
                True,  # 0=Decode,True=Encode
                options.verbose,  # Verbose flag
                options.stretch,  # flex amount
                options.udp_addr,  # udp ip address
                udp_port,  # udp port or zero
                False)  # dump raw u vectors
            self.vocoders.append(t)

        for i in range(options.nchannels):
            self.connect((self.audio_input, i), self.audio_amps[i],
                         self.converters[i], self.vocoders[i])
            if options.output_files:
                self.connect(self.vocoders[i], self.output_files[i])
Beispiel #3
0
    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 = gr.file_sink (gr.sizeof_float, filename)

        if options.nsamples is None:
            self.connect((src, 0), dst)
        else:
            head = gr.head(gr.sizeof_float, int(options.nsamples))
            self.connect((src, 0), head, dst)
Beispiel #4
0
    def __init__(self):
        gr.top_block.__init__(self)

        parser = OptionParser(option_class=eng_option)
        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("-O", "--audio-output", type="string", default="",
                          help="pcm output 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)")
        (options, args) = parser.parse_args ()
        if len(args) != 0:
            parser.print_help()
            raise SystemExit, 1

        sample_rate = int(options.sample_rate)
        src = audio.source (sample_rate, options.audio_input)
        dst = audio.sink (sample_rate, options.audio_output)

        # Determine the maximum number of outputs on the source and
        # maximum number of inputs on the sink, then connect together
        # the most channels we can without overlap
        nchan = min (src.output_signature().max_streams(),
                     dst.input_signature().max_streams())

        for i in range (nchan):
            self.connect ((src, i), (dst, i))
Beispiel #5
0
 def __init__(self, controller, muted=True):
 #   ------------------------------------------------------------------------
     super(AudioSourceAdapter, self).__init__()
     self.controller = controller
     self.samprate = controller.samprate
     self.source = audio.source(self.samprate, "", True)
     self.mute = gr.mute_ff(muted)
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Lab 3 1")
        _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.wxgui_waterfallsink2_0 = waterfallsink2.waterfall_sink_f(
        	self.GetWin(),
        	baseband_freq=0,
        	dynamic_range=100,
        	ref_level=0,
        	ref_scale=2.0,
        	sample_rate=samp_rate,
        	fft_size=512,
        	fft_rate=15,
        	average=False,
        	avg_alpha=None,
        	title='Waterfall Plot',
        )
        self.Add(self.wxgui_waterfallsink2_0.win)
        self.audio_source_0 = audio.source(samp_rate, '', True)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.audio_source_0, 0), (self.wxgui_waterfallsink2_0, 0))
Beispiel #7
0
    def __init__(self):
        gr.top_block.__init__(self)

        parser = OptionParser(option_class=eng_option)
        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(
            "-O",
            "--audio-output",
            type="string",
            default="",
            help="pcm output device name.  E.g., hw:0,0 or /dev/dsp")
        (options, args) = parser.parse_args()
        if len(args) != 0:
            parser.print_help()
            raise SystemExit, 1

        sample_rate = 8000
        src = audio.source(sample_rate, options.audio_input)
        tx = blks2.digital_voice_tx(self)
        if_gain = gr.multiply_const_cc(10000)
        # channel simulator here...
        rx = blks2.digital_voice_rx(self)
        dst = audio.sink(sample_rate, options.audio_output)

        self.connect(src, tx, if_gain, rx, dst)
Beispiel #8
0
def main():
    parser = OptionParser(option_class=eng_option)
    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("-O", "--audio-output", type="string", default="",
                      help="pcm output device name.  E.g., hw:0,0 or /dev/dsp")
    parser.add_option("-r", "--sample-rate", type="eng_float", default="32000",
                      help="Audio sampling rate [defaul=%default]")
    parser.add_option("-S", "--resample-rate", type="int", default="8",
                      help="Resampling rate in CVSD [default=%default]")
    (options, args) = parser.parse_args ()

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

    tb = gr.top_block()

    src = audio.source(int(options.sample_rate), options.audio_input)
    tx = blks2.cvsd_encode(options.resample_rate)

    # todo: add noise

    rx = blks2.cvsd_decode(options.resample_rate)
    dst = audio.sink(int(options.sample_rate), options.audio_output)
    
    tb.connect(src, tx, rx, dst)    
    tb.run()
def build_graph():
    sample_rate = 8000
    scale_factor = 32000

    tb = gr.top_block()
    src = audio.source(sample_rate, "plughw:0,0")
    src_scale = blocks.multiply_const_ff(scale_factor)

    interp = filter.rational_resampler_fff(8, 1)
    f2s = blocks.float_to_short()

    enc = vocoder.cvsd_encode_sb()
    dec = vocoder.cvsd_decode_bs()

    s2f = blocks.short_to_float()
    decim = filter.rational_resampler_fff(1, 8)

    sink_scale = blocks.multiply_const_ff(1.0/scale_factor)
    sink = audio.sink(sample_rate, "plughw:0,0")

    tb.connect(src, src_scale, interp, f2s, enc)
    tb.connect(enc, dec, s2f, decim, sink_scale, sink)

    if 0: # debug
        tb.conect(src, blocks.file_sink(gr.sizeof_float, "source.dat"))
        tb.conect(src_scale, blocks.file_sink(gr.sizeof_float, "src_scale.dat"))
        tb.conect(interp, blocks.file_sink(gr.sizeof_float, "interp.dat"))
        tb.conect(f2s, blocks.file_sink(gr.sizeof_short, "f2s.dat"))
        tb.conect(enc, blocks.file_sink(gr.sizeof_char,  "enc.dat"))
        tb.conect(dec, blocks.file_sink(gr.sizeof_short, "dec.dat"))
        tb.conect(s2f, blocks.file_sink(gr.sizeof_float, "s2f.dat"))
        tb.conect(decim, blocks.file_sink(gr.sizeof_float, "decim.dat"))
        tb.conect(sink_scale, blocks.file_sink(gr.sizeof_float, "sink_scale.dat"))

    return tb
Beispiel #10
0
    def __init__(self):
        gr.top_block.__init__(self)

        parser = ArgumentParser()
        parser.add_argument(
            "-I",
            "--audio-input",
            default="",
            help="pcm input device name.  E.g., hw:0,0 or /dev/dsp")
        parser.add_argument(
            "-O",
            "--audio-output",
            default="",
            help="pcm output device name.  E.g., hw:0,0 or /dev/dsp")
        parser.add_argument("-r",
                            "--sample-rate",
                            type=eng_float,
                            default=8000,
                            help="set sample rate to RATE (%(default)r)")
        args = parser.parse_args()
        sample_rate = int(args.sample_rate)
        src = audio.source(sample_rate, args.audio_input)
        dst = audio.sink(sample_rate, args.audio_output)

        vec1 = [1, -1]
        vsource = blocks.vector_source_f(vec1, True)
        multiply = blocks.multiply_ff()

        self.connect(src, (multiply, 0))
        self.connect(vsource, (multiply, 1))
        self.connect(multiply, dst)
Beispiel #11
0
    def __init__(self):
        gr.top_block.__init__(self)

        parser = OptionParser(option_class=eng_option)
        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("-O", "--audio-output", type="string", default="",
                          help="pcm output device name")
        parser.add_option("-r", "--sample-rate", type="eng_float", default=192000,
                          help="set sample rate to RATE (192000)")
        parser.add_option("-f", "--frequency", type="eng_float", default=45000)
        parser.add_option("-a", "--amplitude", type="eng_float", default=0.5)

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

        sample_rate = int(options.sample_rate)
        ampl = float(options.amplitude)
        if ampl > 1.0: ampl = 1.0

       # osc = analog.sig_source_f (sample_rate, analog.GR_SIN_WAVE, options.frequency, ampl)
        src = audio.source (sample_rate, options.audio_input)
       # mixer = blocks.multiply_ff ()
       # self.connect (osc, (mixer, 0))
       # self.connect (src, (mixer, 1))
        dst = audio.sink (sample_rate, options.audio_output, True)
        self.connect (src, dst)
Beispiel #12
0
    def __init__(self):
        gr.top_block.__init__(self)

        parser = OptionParser(option_class=eng_option)
        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("-O", "--audio-output", type="string", default="",
                          help="pcm output device name.  E.g., hw:0,0 or /dev/dsp")
        parser.add_option("-r", "--sample-rate", type="eng_float", default=8000,
                          help="set sample rate to RATE (8000)")
        (options, args) = parser.parse_args ()
        if len(args) != 0:
            parser.print_help()
            raise SystemExit, 1

        sample_rate = int(options.sample_rate)
        src = audio.source (sample_rate, options.audio_input)
        dst = audio.sink (sample_rate, options.audio_output)

	vec1 = [1, -1]
	vsource = gr.vector_source_f(vec1, True)
	multiply = gr.multiply_ff()

	self.connect(src, (multiply, 0))
	self.connect(vsource, (multiply, 1))
	self.connect(multiply, dst)
Beispiel #13
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Lab 3 1")
        _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.wxgui_waterfallsink2_0 = waterfallsink2.waterfall_sink_f(
            self.GetWin(),
            baseband_freq=0,
            dynamic_range=100,
            ref_level=0,
            ref_scale=2.0,
            sample_rate=samp_rate,
            fft_size=512,
            fft_rate=15,
            average=False,
            avg_alpha=None,
            title='Waterfall Plot',
        )
        self.Add(self.wxgui_waterfallsink2_0.win)
        self.audio_source_0 = audio.source(samp_rate, '', True)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.audio_source_0, 0),
                     (self.wxgui_waterfallsink2_0, 0))
Beispiel #14
0
    def __init__(self):
        gr.top_block.__init__(self, "Dttsptx")

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 8000000
        self.output_rate = output_rate = 8000000

        ##################################################
        # Blocks
        ##################################################
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
                interpolation=output_rate,
                decimation=48000,
                taps=None,
                fractional_bw=None,
        )
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char*1, "/tmp/txiq", False)
        self.blocks_file_sink_0.set_unbuffered(False)
        self.blocks_complex_to_interleaved_char_0 = blocks.complex_to_interleaved_char(False)
        self.audio_source_0 = audio.source(48000, "", True)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.audio_source_0, 0), (self.blocks_float_to_complex_0, 0))    
        self.connect((self.audio_source_0, 1), (self.blocks_float_to_complex_0, 1))    
        self.connect((self.blocks_complex_to_interleaved_char_0, 0), (self.blocks_file_sink_0, 0))    
        self.connect((self.blocks_float_to_complex_0, 0), (self.rational_resampler_xxx_0, 0))    
        self.connect((self.rational_resampler_xxx_0, 0), (self.blocks_complex_to_interleaved_char_0, 0))    
    def __init__(self):
        gr.top_block.__init__(self)

        parser = ArgumentParser()
        parser.add_argument(
            "-I",
            "--audio-input",
            default="",
            help="pcm input device name.  E.g., hw:0,0 or /dev/dsp")
        parser.add_argument(
            "-O",
            "--audio-output",
            default="",
            help="pcm output device name.  E.g., hw:0,0 or /dev/dsp")
        parser.add_argument("-r",
                            "--sample-rate",
                            type=eng_float,
                            default=48000,
                            help="set sample rate, default=%(default)s")
        args = parser.parse_args()

        sample_rate = int(args.sample_rate)
        src = audio.source(sample_rate, args.audio_input)
        dst = audio.sink(sample_rate, args.audio_output)

        # Determine the maximum number of outputs on the source and
        # maximum number of inputs on the sink, then connect together
        # the most channels we can without overlap
        nchan = min(src.output_signature().max_streams(),
                    dst.input_signature().max_streams())

        for i in range(nchan):
            self.connect((src, i), (dst, i))
Beispiel #16
0
    def __init__(self):
        gr.top_block.__init__(self, "Acoust In")

        ##################################################
        # Variables
        ##################################################
        self.transistion = transistion = 100
        self.sps = sps = 2
        self.sideband_rx = sideband_rx = 1000
        self.sideband = sideband = 1000
        self.samp_rate = samp_rate = 48000
        self.payload = payload = 20
        self.interpolation = interpolation = 200
        self.fd = fd = 1
        self.carrier = carrier = 23000

        ##################################################
        # Blocks
        ##################################################
        self.rational_resampler_xxx_0_0_0 = filter.rational_resampler_ccc(
                interpolation=1,
                decimation=interpolation,
                taps=None,
                fractional_bw=None,
        )
        self.freq_xlating_fir_filter_xxx_0_0 = filter.freq_xlating_fir_filter_ccc(1, (filter.firdes.low_pass(1, samp_rate, sideband_rx,100)), carrier, samp_rate)
        self.digital_gfsk_demod_0 = digital.gfsk_demod(
        	samples_per_symbol=sps,
        	sensitivity=1.0,
        	gain_mu=0.175,
        	mu=0.5,
        	omega_relative_limit=0.005,
        	freq_error=0.0,
        	verbose=False,
        	log=False,
        )
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        self.blks2_tcp_sink_0 = grc_blks2.tcp_sink(
        	itemsize=gr.sizeof_char*1,
        	addr="127.0.0.1",
        	port=11000,
        	server=False,
        )
        self.blks2_packet_decoder_0 = grc_blks2.packet_demod_b(grc_blks2.packet_decoder(
        		access_code="",
        		threshold=-1,
        		callback=lambda ok, payload: self.blks2_packet_decoder_0.recv_pkt(ok, payload),
        	),
        )
        self.audio_source_0 = audio.source(48000, "", True)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_float_to_complex_0, 0), (self.freq_xlating_fir_filter_xxx_0_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0_0, 0), (self.rational_resampler_xxx_0_0_0, 0))
        self.connect((self.audio_source_0, 0), (self.blocks_float_to_complex_0, 0))
        self.connect((self.rational_resampler_xxx_0_0_0, 0), (self.digital_gfsk_demod_0, 0))
        self.connect((self.digital_gfsk_demod_0, 0), (self.blks2_packet_decoder_0, 0))
        self.connect((self.blks2_packet_decoder_0, 0), (self.blks2_tcp_sink_0, 0))
Beispiel #17
0
def build_graph():
    sample_rate = 8000
    scale_factor = 32000

    tb = gr.top_block()
    src = audio.source(sample_rate, "plughw:0,0")
    src_scale = gr.multiply_const_ff(scale_factor)

    interp = blks2.rational_resampler_fff(8, 1)
    f2s = gr.float_to_short()

    enc = cvsd_vocoder.encode_sb()
    dec = cvsd_vocoder.decode_bs()

    s2f = gr.short_to_float()
    decim = blks2.rational_resampler_fff(1, 8)

    sink_scale = gr.multiply_const_ff(1.0 / scale_factor)
    sink = audio.sink(sample_rate, "plughw:0,0")

    tb.connect(src, src_scale, interp, f2s, enc)
    tb.connect(enc, dec, s2f, decim, sink_scale, sink)

    if 0:  # debug
        tb.conect(src, gr.file_sink(gr.sizeof_float, "source.dat"))
        tb.conect(src_scale, gr.file_sink(gr.sizeof_float, "src_scale.dat"))
        tb.conect(interp, gr.file_sink(gr.sizeof_float, "interp.dat"))
        tb.conect(f2s, gr.file_sink(gr.sizeof_short, "f2s.dat"))
        tb.conect(enc, gr.file_sink(gr.sizeof_char, "enc.dat"))
        tb.conect(dec, gr.file_sink(gr.sizeof_short, "dec.dat"))
        tb.conect(s2f, gr.file_sink(gr.sizeof_float, "s2f.dat"))
        tb.conect(decim, gr.file_sink(gr.sizeof_float, "decim.dat"))
        tb.conect(sink_scale, gr.file_sink(gr.sizeof_float, "sink_scale.dat"))

    return tb
Beispiel #18
0
 def init_audio(self, config):
     filename = config['args'].replace('audio:', '')
     if filename.startswith('file:'):
         filename = filename.replace('file:', '')
         repeat = False
         s2f = blocks.short_to_float()
         K = 1 / 32767.0
         src = blocks.multiply_const_ff(K)
         throttle = blocks.throttle(
             gr.sizeof_short,
             self.sample_rate)  # may be redundant in stdin case ?
         if filename == '-':
             fd = 0  # stdin
             fsrc = blocks.file_descriptor_source(gr.sizeof_short, fd,
                                                  repeat)
         else:
             fsrc = blocks.file_source(gr.sizeof_short, filename, repeat)
         self.tb.connect(fsrc, throttle, s2f, src)
     else:
         src = audio.source(self.sample_rate, filename)
     gain = 1.0
     if config['gains'].startswith('audio:'):
         gain = float(config['gains'].replace('audio:', ''))
     self.src = blocks.multiply_const_ff(gain)
     self.tb.connect(src, self.src)
Beispiel #19
0
    def __init__(self, device_name, sample_rate, channel_mapping):
        self.__device_name = device_name
        self.__sample_rate = sample_rate

        if len(channel_mapping) == 2:
            self.__signal_type = SignalType(kind='IQ',
                                            sample_rate=self.__sample_rate)
            # TODO should be configurable
            self.__usable_bandwidth = RangeT([(-self.__sample_rate / 2,
                                               self.__sample_rate / 2)])
        else:
            self.__signal_type = SignalType(
                kind=
                'USB',  # TODO obtain correct type from config (or say hamlib)
                sample_rate=self.__sample_rate)
            self.__usable_bandwidth = RangeT([(500, 2500)])

        gr.hier_block2.__init__(
            self,
            type(self).__name__,
            gr.io_signature(0, 0, 0),
            gr.io_signature(1, 1, gr.sizeof_gr_complex * 1),
        )

        self.__source = audio.source(self.__sample_rate,
                                     device_name=self.__device_name,
                                     ok_to_block=True)

        channel_matrix = blocks.multiply_matrix_ff(channel_mapping)
        combine = blocks.float_to_complex(1)
        for i in xrange(0, len(channel_mapping[0])):
            self.connect((self.__source, i), (channel_matrix, i))
        for i in xrange(0, len(channel_mapping)):
            self.connect((channel_matrix, i), (combine, i))
        self.connect(combine, self)
Beispiel #20
0
    def __init__(self):
        gr.top_block.__init__(self)

        ################################################
        ###   EL FLUJOGRAMA                          ###
        ################################################

        # Las variables usadas en el flujograma
        samp_rate = 32000
        #f=1000
        N = 1024
        # Los bloques
        audio_in = audio.source(samp_rate, "")
        audio_out = audio.sink(samp_rate, "")
        str2vec = blocks.stream_to_vector(gr.sizeof_float * 1, N)
        e_fft = bloques.e_vector_fft_ff(N)
        average = bloques.vector_average_hob(N, 20)
        vsnk = qtgui.vector_sink_f(
            N,
            -samp_rate / 2.,
            samp_rate / N,
            "frecuencia",
            "Magnitud",
            "FT en Magnitud",
            2  # Number of inputs
        )
        vsnk.enable_autoscale(True)
        # Las conexiones
        self.connect(audio_in, str2vec, e_fft, (vsnk, 0))
        self.connect(e_fft, average, (vsnk, 1))
        self.connect(audio_in, audio_out)

        # La configuracion para graficar
        pyobj = sip.wrapinstance(vsnk.pyqwidget(), Qt.QWidget)
        pyobj.show()
    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))
Beispiel #22
0
    def __init__(self):
        gr.top_block.__init__(self)

        parser = OptionParser(option_class=eng_option)
        parser.add_option("-O", "--audio-output",
			  type="string",
			  default="",
                          help="audio output device name. E.g., hw:0,0 or /dev/dsp")
        parser.add_option("-I", "--audio-input",
			  type="string",
			  default="",
                          help="audio 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)")
        (options, args) = parser.parse_args ()
        if len(args) != 0:
            parser.print_help()
            raise SystemExit, 1

        sample_rate = int(options.sample_rate)
        src = audio.source (sample_rate, options.audio_output)
        dst = audio.sink (sample_rate, options.audio_output)

        max_chan = max (src.output_signature().max_streams(),
			dst.output_signature().max_streams())

	for i in range (max_chan):
		self.connect ((src, i), (dst, i))
Beispiel #23
0
    def __init__(self):
        gr.top_block.__init__(self)

        parser = OptionParser(option_class=eng_option)
        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("-O", "--audio-output", type="string", default="",
                          help="pcm output device name.  E.g., hw:0,0 or /dev/dsp")
        parser.add_option("-r", "--sample-rate", type="eng_float", default=8000,
                          help="set sample rate to RATE (8000)")
        (options, args) = parser.parse_args ()
        if len(args) != 0:
            parser.print_help()
            raise SystemExit, 1

        sample_rate = int(options.sample_rate)
        src = audio.source (sample_rate, options.audio_input)
        dst = audio.sink (sample_rate, options.audio_output)

	vec1 = [1, -1]
	vsource = blocks.vector_source_f(vec1, True)
	multiply = blocks.multiply_ff()

	self.connect(src, (multiply, 0))
	self.connect(vsource, (multiply, 1))
	self.connect(multiply, dst)
Beispiel #24
0
	def __init__(self):
		grc_wxgui.top_block_gui.__init__(self, title="Joystick 101")

		##################################################
		# Variables
		##################################################
		self.samp_rate = samp_rate = 48000

		##################################################
		# Blocks
		##################################################
		self.openavionics_joystick_interface_0 = openavionics.joystick_interface()
		self.openavionics_audio_ptt_0 = openavionics.audio_ptt()
		self.blocks_tag_debug_0 = blocks.tag_debug(gr.sizeof_float*1, "")
		self.blocks_message_debug_0 = blocks.message_debug()
		self.audio_source_0 = audio.source(samp_rate, "", True)

		##################################################
		# Connections
		##################################################
		self.connect((self.openavionics_audio_ptt_0, 0), (self.blocks_tag_debug_0, 0))
		self.connect((self.audio_source_0, 0), (self.openavionics_audio_ptt_0, 0))

		##################################################
		# Asynch Message Connections
		##################################################
		self.msg_connect(self.openavionics_joystick_interface_0, "out", self.openavionics_audio_ptt_0, "in2")
		self.msg_connect(self.openavionics_joystick_interface_0, "out", self.blocks_message_debug_0, "print")
Beispiel #25
0
	def __init__(self,
			device_name,
			sample_rate,
			quadrature_as_stereo):
		self.__device_name = device_name
		self.__sample_rate = sample_rate
		self.__quadrature_as_stereo = quadrature_as_stereo
		
		if self.__quadrature_as_stereo:
			self.__signal_type = SignalType(
				kind='IQ',
				sample_rate=self.__sample_rate)
		else:
			self.__signal_type = SignalType(
				kind='USB',  # TODO obtain correct type from config (or say hamlib)
				sample_rate=self.__sample_rate)
		
		gr.hier_block2.__init__(
			self, type(self).__name__,
			gr.io_signature(0, 0, 0),
			gr.io_signature(1, 1, gr.sizeof_gr_complex * 1),
		)
		
		self.__source = audio.source(
			self.__sample_rate,
			device_name=self.__device_name,
			ok_to_block=True)
		
		combine = blocks.float_to_complex(1)
		self.connect(self.__source, combine, self)
		if self.__quadrature_as_stereo:
			# if we don't do this, the imaginary component is 0 and the spectrum is symmetric
			self.connect((self.__source, 1), (combine, 1))
Beispiel #26
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Joystick 101")

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 48000

        ##################################################
        # Blocks
        ##################################################
        self.openavionics_joystick_interface_0 = openavionics.joystick_interface(
        )
        self.openavionics_audio_ptt_0 = openavionics.audio_ptt()
        self.blocks_tag_debug_0 = blocks.tag_debug(gr.sizeof_float * 1, "")
        self.blocks_message_debug_0 = blocks.message_debug()
        self.audio_source_0 = audio.source(samp_rate, "", True)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.openavionics_audio_ptt_0, 0),
                     (self.blocks_tag_debug_0, 0))
        self.connect((self.audio_source_0, 0),
                     (self.openavionics_audio_ptt_0, 0))

        ##################################################
        # Asynch Message Connections
        ##################################################
        self.msg_connect(self.openavionics_joystick_interface_0, "out",
                         self.openavionics_audio_ptt_0, "in2")
        self.msg_connect(self.openavionics_joystick_interface_0, "out",
                         self.blocks_message_debug_0, "print")
Beispiel #27
0
    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))
Beispiel #28
0
    def __init__(self, device_name, sample_rate, quadrature_as_stereo):
        self.__device_name = device_name
        self.__sample_rate = sample_rate
        self.__quadrature_as_stereo = quadrature_as_stereo

        if self.__quadrature_as_stereo:
            self.__signal_type = SignalType(kind='IQ',
                                            sample_rate=self.__sample_rate)
            # TODO should be configurable
            self.__usable_bandwidth = Range([(-self.__sample_rate / 2,
                                              self.__sample_rate / 2)])
        else:
            self.__signal_type = SignalType(
                kind=
                'USB',  # TODO obtain correct type from config (or say hamlib)
                sample_rate=self.__sample_rate)
            self.__usable_bandwidth = Range([(500, 2500)])

        gr.hier_block2.__init__(
            self,
            type(self).__name__,
            gr.io_signature(0, 0, 0),
            gr.io_signature(1, 1, gr.sizeof_gr_complex * 1),
        )

        self.__source = audio.source(self.__sample_rate,
                                     device_name=self.__device_name,
                                     ok_to_block=True)

        combine = blocks.float_to_complex(1)
        self.connect(self.__source, combine, self)
        if self.__quadrature_as_stereo:
            # if we don't do this, the imaginary component is 0 and the spectrum is symmetric
            self.connect((self.__source, 1), (combine, 1))
Beispiel #29
0
    def __init__(self):
        gr.top_block.__init__(self)

        parser = OptionParser(option_class=eng_option)
        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("-O", "--audio-output", type="string", default="",
                          help="pcm output 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)")
        (options, args) = parser.parse_args ()
        if len(args) != 0:
            parser.print_help()
            raise SystemExit, 1

        sample_rate = int(options.sample_rate)
        src = audio.source (sample_rate, options.audio_input)
        dst = audio.sink (sample_rate, options.audio_output)

        # Determine the maximum number of outputs on the source and
        # maximum number of inputs on the sink, then connect together
        # the most channels we can without overlap
        nchan = min (src.output_signature().max_streams(),
                     dst.input_signature().max_streams())

        for i in range (nchan):
            self.connect ((src, i), (dst, i))
    def __init__(self):
        gr.top_block.__init__(self)

        parser = OptionParser(option_class=eng_option)
        parser.add_option(
            "-O",
            "--audio-output",
            type="string",
            default="",
            help="audio output device name. E.g., hw:0,0 or /dev/dsp")
        parser.add_option(
            "-I",
            "--audio-input",
            type="string",
            default="",
            help="audio 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)")
        (options, args) = parser.parse_args()
        if len(args) != 0:
            parser.print_help()
            raise SystemExit, 1

        sample_rate = int(options.sample_rate)
        src = audio.source(sample_rate, options.audio_output)
        dst = audio.sink(sample_rate, options.audio_output)

        max_chan = max(src.output_signature().max_streams(),
                       dst.output_signature().max_streams())

        for i in range(max_chan):
            self.connect((src, i), (dst, i))
Beispiel #31
0
    def __init__(self):
        gr.top_block.__init__(self)

        parser = ArgumentParser()
        parser.add_argument(
            "-I",
            "--audio-input",
            default="",
            help="pcm input device name.  E.g., hw:0,0 or /dev/dsp")
        parser.add_argument("-r",
                            "--sample-rate",
                            type=eng_float,
                            default=48000,
                            help="set sample rate to RATE (%(default)r)")
        parser.add_argument("-N",
                            "--nsamples",
                            type=eng_float,
                            help="number of samples to collect [default=+inf]")
        parser.add_argument('file_name',
                            metavar='FILE-NAME',
                            help="Output file path")

        args = parser.parse_args()

        sample_rate = int(args.sample_rate)
        src = audio.source(sample_rate, args.audio_input)
        dst = blocks.file_sink(gr.sizeof_float, args.file_name)

        if args.nsamples is None:
            self.connect((src, 0), dst)
        else:
            head = blocks.head(gr.sizeof_float, int(args.nsamples))
            self.connect((src, 0), head, dst)
Beispiel #32
0
    def __init__(self):
        gr.top_block.__init__(self)
        parser = OptionParser(option_class=eng_option)
        parser.add_option("-a", "--audio-input", type="string", default="")
        parser.add_option("-A", "--audio-output", type="string", default="")
        parser.add_option("-f", "--factor", type="eng_float", default=1)
        parser.add_option("-i", "--do-interp", action="store_true", default=False, help="enable output interpolator")
        parser.add_option("-s", "--sample-rate", type="int", default=48000, help="input sample rate")
        parser.add_option("-S", "--stretch", type="int", default=0, help="flex amt")
        parser.add_option("-y", "--symbol-rate", type="int", default=4800, help="input symbol rate")
        parser.add_option("-v", "--verbose", action="store_true", default=False, help="dump demodulation data")
        (options, args) = parser.parse_args()
 
        sample_rate = options.sample_rate
        symbol_rate = options.symbol_rate

        IN = audio.source(sample_rate, options.audio_input)
        audio_output_rate = 8000
        if options.do_interp:
            audio_output_rate = 48000
        OUT = audio.sink(audio_output_rate, options.audio_output)

        symbol_decim = 1
        symbol_coeffs = gr.firdes.root_raised_cosine(1.0,	# gain
                                          sample_rate ,	# sampling rate
                                          symbol_rate,  # symbol rate
                                          0.2,     	# width of trans. band
                                          500) 		# filter type 
        SYMBOL_FILTER = gr.fir_filter_fff (symbol_decim, symbol_coeffs)
        AMP = gr.multiply_const_ff(options.factor)
        msgq = gr.msg_queue(2)
        FSK4 = op25.fsk4_demod_ff(msgq, sample_rate, symbol_rate)
        levels = levels = [-2.0, 0.0, 2.0, 4.0]
        SLICER = repeater.fsk4_slicer_fb(levels)
        framer_msgq = gr.msg_queue(2)
        DECODE = repeater.p25_frame_assembler('',	# udp hostname
                                              0,	# udp port no.
                                              options.verbose,	#debug
                                              True,	# do_imbe
                                              True,	# do_output
                                              False,	# do_msgq
                                              framer_msgq)
        IMBE = repeater.vocoder(False,                 # 0=Decode,True=Encode
                                  options.verbose,      # Verbose flag
                                  options.stretch,      # flex amount
                                  "",                   # udp ip address
                                  0,                    # udp port
                                  False)                # dump raw u vectors

        CVT = gr.short_to_float()
        if options.do_interp:
            interp_taps = gr.firdes.low_pass(1.0, 48000, 4000, 4000 * 0.1, gr.firdes.WIN_HANN)
            INTERP = gr.interp_fir_filter_fff(48000 // 8000, interp_taps)
        AMP2 = gr.multiply_const_ff(1.0 / 32767.0)

        self.connect(IN, AMP, SYMBOL_FILTER, FSK4, SLICER, DECODE, IMBE, CVT, AMP2)
        if options.do_interp:
            self.connect(AMP2, INTERP, OUT)
        else:
            self.connect(AMP2, OUT)
Beispiel #33
0
    def __init__(self):
        gr.top_block.__init__(self)

        parser = OptionParser(option_class=eng_option)
        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("-O", "--audio-output", type="string", default="",
                          help="pcm output device name")
        parser.add_option("-r", "--sample-rate", type="eng_float", default=192000,
                          help="set sample rate to RATE (192000)")
        parser.add_option("-f", "--frequency", type="eng_float", default=45000)
        parser.add_option("-a", "--amplitude", type="eng_float", default=0.5)

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

        sample_rate = int(options.sample_rate)
        ampl = float(options.amplitude)
        if ampl > 1.0: ampl = 1.0

        to_real = blocks.complex_to_real()
        to_imag = blocks.complex_to_imag()

        src = audio.source (sample_rate, options.audio_input)
        firdes_taps = filter.firdes.low_pass_2(1, 1, 0.2, 0.1, 60)
        converter = filter.freq_xlating_fir_filter_fcf ( 1, firdes_taps, 0, sample_rate )
        converter.set_center_freq(0 - options.frequency)
        dst = audio.sink (sample_rate, options.audio_output, True)

        #self.connect(src, converter, to_real, dst)
        self.connect(src, converter)
        self.connect(converter, to_real, (dst,0))
        self.connect(converter, to_imag, (dst,1))
Beispiel #34
0
    def __init__(self, options, queue):
        gr.top_block.__init__(self, "mhp")

        self.audio_amps = []
        self.converters = []
        self.vocoders = []
        self.output_files = []

        input_audio_rate = 8000
        self.audio_input = audio.source(input_audio_rate, options.audio_input)

        for i in range (options.nchannels):
            udp_port = options.udp_port + i
            if options.output_files:
                t = gr.file_sink(gr.sizeof_char, "baseband-%d.dat" % i)
                self.output_files.append(t)
                udp_port = 0
            t = gr.multiply_const_ff(32767 * options.audio_gain)
            self.audio_amps.append(t)
            t = gr.float_to_short()
            self.converters.append(t)
            t = repeater.vocoder(True,                 # 0=Decode,True=Encode
                                  options.verbose,      # Verbose flag
                                  options.stretch,      # flex amount
                                  options.udp_addr,     # udp ip address
                                  udp_port,             # udp port or zero
                                  False)                # dump raw u vectors
            self.vocoders.append(t)

        for i in range (options.nchannels):
            self.connect((self.audio_input, i), self.audio_amps[i], self.converters[i], self.vocoders[i])
            if options.output_files:
                self.connect(self.vocoders[i], self.output_files[i])
Beispiel #35
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Transmisor")
        _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 = 44100
        self.fcmod = fcmod = 0
        self.fc = fc = 0

        ##################################################
        # Blocks
        ##################################################
        self.uhd_usrp_sink_0 = uhd.usrp_sink(
        	device_addr="",
        	stream_args=uhd.stream_args(
        		cpu_format="fc32",
        		channels=range(1),
        	),
        )
        self.uhd_usrp_sink_0.set_time_source("gpsdo", 0)
        self.uhd_usrp_sink_0.set_samp_rate(samp_rate)
        self.uhd_usrp_sink_0.set_center_freq(fc, 0)
        self.uhd_usrp_sink_0.set_gain(0, 0)
        self.digital_psk_mod_0 = digital.psk.psk_mod(
          constellation_points=4,
          mod_code="gray",
          differential=True,
          samples_per_symbol=2,
          excess_bw=0.35,
          verbose=False,
          log=False,
          )
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vff((127, ))
        self.blocks_float_to_char_0 = blocks.float_to_char(1, 1)
        self.blks2_packet_encoder_0 = grc_blks2.packet_mod_b(grc_blks2.packet_encoder(
        		samples_per_symbol=2,
        		bits_per_symbol=1,
        		access_code="",
        		pad_for_usrp=False,
        	),
        	payload_length=0,
        )
        self.audio_source_0 = audio.source(samp_rate, "", True)
        self.analog_sig_source_x_0_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, fcmod, 1, 0)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.blocks_float_to_char_0, 0))
        self.connect((self.blocks_float_to_char_0, 0), (self.blks2_packet_encoder_0, 0))
        self.connect((self.analog_sig_source_x_0_0, 0), (self.blocks_multiply_xx_0, 1))
        self.connect((self.blks2_packet_encoder_0, 0), (self.digital_psk_mod_0, 0))
        self.connect((self.digital_psk_mod_0, 0), (self.blocks_multiply_xx_0, 0))
        self.connect((self.audio_source_0, 0), (self.blocks_multiply_const_vxx_0_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0), (self.uhd_usrp_sink_0, 0))
Beispiel #36
0
    def __init__(self, frame, panel, vbox, argv):
        stdgui2.std_top_block.__init__(self, frame, panel, vbox, argv)

        self.frame = frame
        self.panel = panel

        parser = OptionParser(option_class=eng_option)
        parser.add_option("-W",
                          "--waterfall",
                          action="store_true",
                          default=False,
                          help="Enable waterfall display")
        parser.add_option("-S",
                          "--oscilloscope",
                          action="store_true",
                          default=False,
                          help="Enable oscilloscope display")
        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)")

        (options, args) = parser.parse_args()
        sample_rate = int(options.sample_rate)

        if len(args) != 0:
            parser.print_help()
            sys.exit(1)

        self.show_debug_info = True

        # build the graph
        if options.waterfall:
            self.scope = \
              waterfallsink2.waterfall_sink_f (panel, fft_size=1024, sample_rate=sample_rate)
        elif options.oscilloscope:
            self.scope = scopesink2.scope_sink_f(panel,
                                                 sample_rate=sample_rate)
        else:
            self.scope = fftsink2.fft_sink_f(panel,
                                             fft_size=1024,
                                             sample_rate=sample_rate,
                                             fft_rate=30,
                                             ref_scale=1.0,
                                             ref_level=0,
                                             y_divs=12)

        self.src = audio.source(sample_rate, options.audio_input)

        self.connect(self.src, self.scope)

        self._build_gui(vbox)
Beispiel #37
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.samp_rate = samp_rate = 44100

        ##################################################
        # Blocks
        ##################################################
        self.wxgui_numbersink2_0 = numbersink2.number_sink_f(
            self.GetWin(),
            unit="Hz",
            minval=50,
            maxval=280,
            factor=1,
            decimal_places=2,
            ref_level=0,
            sample_rate=samp_rate,
            number_rate=15,
            average=False,
            avg_alpha=None,
            label="Number Plot",
            peak_hold=False,
            show_gauge=True,
        )
        self.Add(self.wxgui_numbersink2_0.win)
        self.blocks_moving_average_xx_0 = blocks.moving_average_ff(
            samp_rate / 50, 25 / pi, 200)
        self.blocks_keep_one_in_n_0 = blocks.keep_one_in_n(
            gr.sizeof_float * 1, 10)
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        self.band_pass_filter_0 = filter.fir_filter_ccc(
            1,
            firdes.complex_band_pass(1, samp_rate, 60, 255, 100,
                                     firdes.WIN_BLACKMAN, 6.76))
        self.audio_source_0 = audio.source(samp_rate, "default", True)
        self.analog_pll_freqdet_cf_0 = analog.pll_freqdet_cf(
            200 * 2.0 * pi / samp_rate, 260 * 2.0 * pi / samp_rate,
            60 * 2.0 * pi / samp_rate)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_moving_average_xx_0, 0),
                     (self.wxgui_numbersink2_0, 0))
        self.connect((self.blocks_float_to_complex_0, 0),
                     (self.band_pass_filter_0, 0))
        self.connect((self.band_pass_filter_0, 0),
                     (self.analog_pll_freqdet_cf_0, 0))
        self.connect((self.audio_source_0, 0),
                     (self.blocks_float_to_complex_0, 0))
        self.connect((self.analog_pll_freqdet_cf_0, 0),
                     (self.blocks_keep_one_in_n_0, 0))
        self.connect((self.blocks_keep_one_in_n_0, 0),
                     (self.blocks_moving_average_xx_0, 0))
Beispiel #38
0
 def init_audio(self, config):
     filename = config['args'].replace('audio:', '')
     src = audio.source(self.sample_rate, filename)
     gain = 1.0
     if config['gains'].startswith('audio:'):
         gain = float(config['gains'].replace('audio:', ''))
     self.src = blocks.multiply_const_ff(gain)
     self.tb.connect(src, self.src)
Beispiel #39
0
    def __init__(self, subdev_spec, audio_input):
        gr.hier_block2.__init__(
            self,
            "transmit_path",
            gr.io_signature(0, 0, 0),  # Input signature
            gr.io_signature(0, 0, 0))  # Output signature

        self.u = usrp.sink_c()

        dac_rate = self.u.dac_rate()
        self.if_rate = 320e3  # 320 kS/s
        self.usrp_interp = int(dac_rate // self.if_rate)
        self.u.set_interp_rate(self.usrp_interp)
        self.sw_interp = 10
        self.audio_rate = self.if_rate // self.sw_interp  #  32 kS/s

        self.audio_gain = 10
        self.normal_gain = 32000

        self.audio = audio.source(int(self.audio_rate), audio_input)
        self.audio_amp = gr.multiply_const_ff(self.audio_gain)

        lpf = gr.firdes.low_pass(
            1,  # gain
            self.audio_rate,  # sampling rate
            3800,  # low pass cutoff freq
            300,  # width of trans. band
            gr.firdes.WIN_HANN)  # filter type

        hpf = gr.firdes.high_pass(
            1,  # gain
            self.audio_rate,  # sampling rate
            325,  # low pass cutoff freq
            50,  # width of trans. band
            gr.firdes.WIN_HANN)  # filter type

        audio_taps = convolve(array(lpf), array(hpf))
        self.audio_filt = gr.fir_filter_fff(1, audio_taps)

        self.pl = blks2.ctcss_gen_f(self.audio_rate, 123.0)
        self.add_pl = gr.add_ff()
        self.connect(self.pl, (self.add_pl, 1))

        self.fmtx = blks2.nbfm_tx(self.audio_rate, self.if_rate)
        self.amp = gr.multiply_const_cc(self.normal_gain)

        # determine the daughterboard subdevice we're using
        if subdev_spec is None:
            subdev_spec = usrp.pick_tx_subdevice(self.u)
        self.u.set_mux(usrp.determine_tx_mux_value(self.u, subdev_spec))
        self.subdev = usrp.selected_subdev(self.u, subdev_spec)
        print "TX using", self.subdev.name()

        self.connect(self.audio, self.audio_amp, self.audio_filt,
                     (self.add_pl, 0), self.fmtx, self.amp, self.u)

        self.set_gain(self.subdev.gain_range()[1])  # set max Tx gain
Beispiel #40
0
    def __init__(self):
        gr.top_block.__init__(self, "Transmitter")

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = int(1e6)
        self.freq = freq = 875e5

        ##################################################
        # Blocks
        ##################################################
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
            interpolation=100,
            decimation=1,
            taps=None,
            fractional_bw=None,
        )
        self.osmosdr_sink_0 = osmosdr.sink(
            args="numchan=" + str(1) + " " +
            'hackrf=000000000000000087c867dc2d0c6c5f')
        self.osmosdr_sink_0.set_sample_rate(samp_rate)
        self.osmosdr_sink_0.set_center_freq(freq, 0)
        self.osmosdr_sink_0.set_freq_corr(0, 0)
        self.osmosdr_sink_0.set_gain(10, 0)
        self.osmosdr_sink_0.set_if_gain(20, 0)
        self.osmosdr_sink_0.set_bb_gain(20, 0)
        self.osmosdr_sink_0.set_antenna('', 0)
        self.osmosdr_sink_0.set_bandwidth(0, 0)

        self.blocks_wavfile_source_0 = blocks.wavfile_source(
            '/home/pwntoo/GRC/assets/morse.wav', True)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((0, ))
        self.blocks_add_xx_0 = blocks.add_vff(1)
        self.audio_source_0 = audio.source(44100, '', True)
        self.analog_wfm_tx_0 = analog.wfm_tx(
            audio_rate=samp_rate,
            quad_rate=samp_rate,
            tau=75e-6,
            max_dev=5e3,
            fh=-1.0,
        )

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_wfm_tx_0, 0),
                     (self.rational_resampler_xxx_0, 0))
        self.connect((self.audio_source_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.blocks_add_xx_0, 0), (self.analog_wfm_tx_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.blocks_add_xx_0, 1))
        self.connect((self.blocks_wavfile_source_0, 0),
                     (self.blocks_add_xx_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.osmosdr_sink_0, 0))
Beispiel #41
0
 def __init__(self, host, port, pkt_size, sample_rate, eof):
     gr.top_block.__init__(self, "audio_source")
     self.audio = audio.source(sample_rate)
     self.sink = blocks.udp_sink(gr.sizeof_float,
                                 host,
                                 port,
                                 pkt_size,
                                 eof=eof)
     self.connect(self.audio, self.sink)
    def __init__(self):
        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())

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 44100
        self.center1 = center1 = 0

        ##################################################
        # Blocks
        ##################################################
        self._center1_range = Range(-20000, 20000, 100, 0, 200)
        self._center1_win = RangeWidget(self._center1_range, self.set_center1, "center1", "counter_slider", float)
        self.top_layout.addWidget(self._center1_win)
        self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_fcf(1, (1, ), center1, samp_rate)
        self.freq_xlating_fft_filter_ccc_0 = filter.freq_xlating_fft_filter_ccc(1, (1, ), center1, samp_rate)
        self.freq_xlating_fft_filter_ccc_0.set_nthreads(1)
        self.freq_xlating_fft_filter_ccc_0.declare_sample_delay(0)
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        self.blocks_complex_to_float_0_0 = blocks.complex_to_float(1)
        self.blocks_complex_to_float_0 = blocks.complex_to_float(1)
        self.audio_source_0 = audio.source(samp_rate, "", True)
        self.audio_sink_0 = audio.sink(samp_rate, "", True)
        self.analog_const_source_x_0 = analog.sig_source_f(0, analog.GR_CONST_WAVE, 0, 0, 0)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_const_source_x_0, 0), (self.blocks_float_to_complex_0, 1))    
        self.connect((self.audio_source_0, 0), (self.blocks_float_to_complex_0, 0))    
        self.connect((self.audio_source_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0))    
        self.connect((self.blocks_complex_to_float_0, 0), (self.audio_sink_0, 0))    
        self.connect((self.blocks_complex_to_float_0_0, 0), (self.audio_sink_0, 1))    
        self.connect((self.blocks_float_to_complex_0, 0), (self.freq_xlating_fft_filter_ccc_0, 0))    
        self.connect((self.freq_xlating_fft_filter_ccc_0, 0), (self.blocks_complex_to_float_0_0, 0))    
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.blocks_complex_to_float_0, 0))    
Beispiel #43
0
    def __init__(self, subdev_spec, audio_input):
        gr.hier_block2.__init__(
            self, "transmit_path", gr.io_signature(0, 0, 0), gr.io_signature(0, 0, 0)  # Input signature
        )  # Output signature

        self.u = usrp.sink_c()

        dac_rate = self.u.dac_rate()
        self.if_rate = 320e3  # 320 kS/s
        self.usrp_interp = int(dac_rate // self.if_rate)
        self.u.set_interp_rate(self.usrp_interp)
        self.sw_interp = 10
        self.audio_rate = self.if_rate // self.sw_interp  #  32 kS/s

        self.audio_gain = 10
        self.normal_gain = 32000

        self.audio = audio.source(int(self.audio_rate), audio_input)
        self.audio_amp = gr.multiply_const_ff(self.audio_gain)

        lpf = gr.firdes.low_pass(
            1,  # gain
            self.audio_rate,  # sampling rate
            3800,  # low pass cutoff freq
            300,  # width of trans. band
            gr.firdes.WIN_HANN,
        )  # filter type

        hpf = gr.firdes.high_pass(
            1,  # gain
            self.audio_rate,  # sampling rate
            325,  # low pass cutoff freq
            50,  # width of trans. band
            gr.firdes.WIN_HANN,
        )  # filter type

        audio_taps = convolve(array(lpf), array(hpf))
        self.audio_filt = gr.fir_filter_fff(1, audio_taps)

        self.pl = blks2.ctcss_gen_f(self.audio_rate, 123.0)
        self.add_pl = gr.add_ff()
        self.connect(self.pl, (self.add_pl, 1))

        self.fmtx = blks2.nbfm_tx(self.audio_rate, self.if_rate)
        self.amp = gr.multiply_const_cc(self.normal_gain)

        # determine the daughterboard subdevice we're using
        if subdev_spec is None:
            subdev_spec = usrp.pick_tx_subdevice(self.u)
        self.u.set_mux(usrp.determine_tx_mux_value(self.u, subdev_spec))
        self.subdev = usrp.selected_subdev(self.u, subdev_spec)
        print "TX using", self.subdev.name()

        self.connect(self.audio, self.audio_amp, self.audio_filt, (self.add_pl, 0), self.fmtx, self.amp, self.u)

        self.set_gain(self.subdev.gain_range()[1])  # set max Tx gain
Beispiel #44
0
    def __init__(self,
                 tapdev,
                 samp_rate=44100,
                 carrier_freq=3000,
                 samples_per_symbol=None):
        gr.top_block.__init__(self, 'demod_top_block')
        ##################################################
        # Variables
        ##################################################
        self.transition_bw = transition_bw = 500
        self.samp_rate = samp_rate
        self.carrier_freq = carrier_freq
        if samples_per_symbol is None:
            #this will result in a bandwidth that touches 200 Hz on the lower side
            #this way we don't make aliases and don't use frequiencies under 200 Hz,
            #because transmission characteristics can be bad with cheap speakers.
            self.samples_per_symbol = 1 + samp_rate // (carrier_freq - 200)
        else:
            self.samples_per_symbol = samples_per_symbol
        self.bandwidth = samp_rate / self.samples_per_symbol * 2

        ##################################################
        # Blocks
        ##################################################
        self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(
            1, (firdes.low_pass(1, samp_rate, self.bandwidth, transition_bw)),
            carrier_freq, samp_rate)
        self.digital_psk_demod_0 = digital.psk.psk_demod(
            constellation_points=8,
            differential=True,
            samples_per_symbol=2,
            excess_bw=0.35,
            phase_bw=6.28 / 100.0,
            timing_bw=6.28 / 100.0,
            mod_code="gray",
            verbose=False,
            log=False,
        )
        self.tap_sink = tap_sink(tapdev)
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        self.audio_source_0 = audio.source(samp_rate, "", True)
        self.analog_const_source_x_0 = analog.sig_source_f(
            0, analog.GR_CONST_WAVE, 0, 0, 0)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_const_source_x_0, 0),
                     (self.blocks_float_to_complex_0, 1))
        self.connect((self.audio_source_0, 0),
                     (self.blocks_float_to_complex_0, 0))
        self.connect((self.blocks_float_to_complex_0, 0),
                     (self.freq_xlating_fir_filter_xxx_0, 0))
        self.connect((self.digital_psk_demod_0, 0), (self.tap_sink, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0),
                     (self.digital_psk_demod_0, 0))
Beispiel #45
0
 def init_audio_if(self, config):
     filename = config['args'].replace('audio-if:', '')
     self.audio_source = audio.source(config['rate'], filename)
     self.null_source = blocks.null_source(gr.sizeof_float)
     self.audio_cvt = blocks.float_to_complex()
     self.tb.connect(self.audio_source, (self.audio_cvt, 0))
     self.tb.connect(self.null_source, (self.audio_cvt, 1))
     self.src = self.audio_cvt
     self.frequency = config['frequency']
     self.offset = config['offset']
Beispiel #46
0
 def open_audio(self, capture_rate, gain, audio_input_filename):
         self.info = {
             "capture-rate": capture_rate,
             "center-freq": 0,
             "source-dev": "AUDIO",
             "source-decim": 1 }
         self.audio_source = audio.source(capture_rate, audio_input_filename)
         self.source = blocks.multiply_const_ff(gain)
         self.connect(self.audio_source, self.source)
         self.__set_rx_from_audio(capture_rate)
   def __init__(self):
      gr.top_block.__init__(self)

      # Create an audio source (a software abstraction of the sound card, assumed
      # to be the default audion input source), sample rate is 48000 sps
      source = audio.source(48000, "")
      # Create a file sink (sample data format is 32-bit float)
      sink = blocks.file_sink(gr.sizeof_float, "mysamples.dat")
      # Connect source and sink
      self.connect(source, sink)
    def __init__(self, frame, panel, vbox, argv):
        stdgui2.std_top_block.__init__(self, frame, panel, vbox, argv)

	self.frame = frame
	self.panel = panel

	options = get_options()

	sample_rate = int(options.sample_rate)	

	self.asrc = audio.source(sample_rate, options.audio_device, True)

	self.f2c = gr.float_to_complex(1)

	self.connect((self.asrc, 1), (self.f2c, 1))
	self.connect((self.asrc, 0), (self.f2c, 0))

        symbol_rate = 18000
        sps = 2
        # output rate will be 36,000
        ntaps = 11 * sps
        new_sample_rate = symbol_rate * sps

        channel_taps = gr.firdes.low_pass(1.0, sample_rate, options.low_pass, options.low_pass * 0.1, gr.firdes.WIN_HANN)

        FILTER = gr.freq_xlating_fir_filter_ccf(1, channel_taps, options.calibration, sample_rate)

        sys.stderr.write("sample rate: %d\n" %(sample_rate))

        DEMOD = cqpsk.cqpsk_demod( samples_per_symbol = sps,
                                 excess_bw=0.35,
                                 costas_alpha=0.03,
                                 gain_mu=0.05,
                                 mu=0.05,
                                 omega_relative_limit=0.05,
                                 log=options.log,
                                 verbose=options.verbose)

        OUT = gr.file_sink(gr.sizeof_float, options.output_file)

        r = float(sample_rate) / float(new_sample_rate)

        INTERPOLATOR = gr.fractional_interpolator_cc(0, r)

        self.connect(self.f2c, FILTER, INTERPOLATOR, DEMOD, OUT)

	self.scope = fftsink2.fft_sink_c(panel, fft_size=512,
					 sample_rate=sample_rate,
					 ref_scale=2.0,
					 ref_level=-30, y_divs=10,
					 fft_rate=10,
					 average=True,
					 avg_alpha=0.2)
	self.connect(self.f2c, self.scope)
    def __init__(self, frame, panel, vbox, argv):
        stdgui2.std_top_block.__init__(self, frame, panel, vbox, argv)

	self.frame = frame
	self.panel = panel

	options = get_options()

	sample_rate = int(options.sample_rate)	

	self.asrc = audio.source(sample_rate, options.audio_device, True)

	self.f2c = blocks.float_to_complex(1)

	self.connect((self.asrc, 1), (self.f2c, 1))
	self.connect((self.asrc, 0), (self.f2c, 0))

        symbol_rate = 18000
        sps = 2
        # output rate will be 36,000
        ntaps = 11 * sps
        new_sample_rate = symbol_rate * sps

        channel_taps = filter.firdes.low_pass(1.0, sample_rate, options.low_pass, options.low_pass * 0.1, filter.firdes.WIN_HANN)

        FILTER = filter.freq_xlating_fir_filter_ccf(1, channel_taps, options.calibration, sample_rate)

        sys.stderr.write("sample rate: %d\n" %(sample_rate))

        DEMOD = cqpsk.cqpsk_demod( samples_per_symbol = sps,
                                 excess_bw=0.35,
                                 costas_alpha=0.03,
                                 gain_mu=0.05,
                                 mu=0.05,
                                 omega_relative_limit=0.05,
                                 log=options.log,
                                 verbose=options.verbose)

        OUT = blocks.file_sink(gr.sizeof_float, options.output_file)

        r = float(sample_rate) / float(new_sample_rate)

        INTERPOLATOR = filter.fractional_interpolator_cc(0, r)

        self.connect(self.f2c, FILTER, INTERPOLATOR, DEMOD, OUT)

	self.scope = fftsink2.fft_sink_c(panel, fft_size=512,
					 sample_rate=sample_rate,
					 ref_scale=2.0,
					 ref_level=-30, y_divs=10,
					 fft_rate=10,
					 average=True,
					 avg_alpha=0.2)
	self.connect(self.f2c, self.scope)
Beispiel #50
0
    def __init__(self):
        gr.top_block.__init__(self, "final_africube.py")

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 2205000

        ##################################################
        # Blocks
        ##################################################
        self.sdrplay_rsp1_source_0 = sdrplay.rsp1_source(435.100e6, 5000, True, 0, False, False,
                False, 0, 1, samp_rate, True, '0')
            
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
                interpolation=1,
                decimation=25,
                taps=None,
                fractional_bw=None,
        )
        self.blocks_multiply_xx_1 = blocks.multiply_vcc(1)
        self.blocks_multiply_const_vxx_2_0 = blocks.multiply_const_vff((1, ))
        self.blocks_multiply_const_vxx_2 = blocks.multiply_const_vcc((1, ))
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((2, ))
        self.blocks_add_xx_1 = blocks.add_vcc(1)
        self.blks2_tcp_sink_1 = grc_blks2.tcp_sink(
        	itemsize=gr.sizeof_gr_complex*1,
        	addr='127.0.0.1',
        	port=8011,
        	server=False,
        )
        self.audio_source_0 = audio.source(44100, 'plughw:0,1', True)
        self.analog_sig_source_x_0 = analog.sig_source_c(88200, analog.GR_COS_WAVE, 35000, 1, 0)
        self.analog_nbfm_tx_0 = analog.nbfm_tx(
        	audio_rate=44100,
        	quad_rate=88200,
        	tau=75e-6,
        	max_dev=2000,
        	fh=-1.0,
                )

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_nbfm_tx_0, 0), (self.blocks_multiply_xx_1, 1))    
        self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_1, 0))    
        self.connect((self.audio_source_0, 0), (self.blocks_multiply_const_vxx_2_0, 0))    
        self.connect((self.blocks_add_xx_1, 0), (self.blks2_tcp_sink_1, 0))    
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_add_xx_1, 1))    
        self.connect((self.blocks_multiply_const_vxx_2, 0), (self.blocks_add_xx_1, 0))    
        self.connect((self.blocks_multiply_const_vxx_2_0, 0), (self.analog_nbfm_tx_0, 0))    
        self.connect((self.blocks_multiply_xx_1, 0), (self.blocks_multiply_const_vxx_2, 0))    
        self.connect((self.rational_resampler_xxx_0, 0), (self.blocks_multiply_const_vxx_0, 0))    
        self.connect((self.sdrplay_rsp1_source_0, 0), (self.rational_resampler_xxx_0, 0))    
def build_graph():
    tb = gr.top_block()
    src = audio.source(8000)
    src_scale = blocks.multiply_const_ff(32767)
    f2s = blocks.float_to_short()
    enc = vocoder.gsm_fr_encode_sp()
    dec = vocoder.gsm_fr_decode_ps()
    s2f = blocks.short_to_float()
    sink_scale = blocks.multiply_const_ff(1.0/32767.)
    sink = audio.sink(8000)
    tb.connect(src, src_scale, f2s, enc, dec, s2f, sink_scale, sink)
    return tb
def build_graph():
    tb = gr.top_block()
    src = audio.source(8000)
    src_scale = blocks.multiply_const_ff(32767)
    f2s = blocks.float_to_short()
    enc = vocoder.g721_encode_sb()
    dec = vocoder.g721_decode_bs()
    s2f = blocks.short_to_float()
    sink_scale = blocks.multiply_const_ff(1.0 / 32767.0)
    sink = audio.sink(8000)
    tb.connect(src, src_scale, f2s, enc, dec, s2f, sink_scale, sink)
    return tb
def build_graph():
    fg = gr.flow_graph()
    src = audio.source(8000)
    src_scale = gr.multiply_const_ff(32767)
    f2s = gr.float_to_short ()
    enc = gsm_full_rate.encode_sp()
    dec = gsm_full_rate.decode_ps()
    s2f = gr.short_to_float ()
    sink_scale = gr.multiply_const_ff(1.0/32767.)
    sink = audio.sink(8000)
    fg.connect(src, src_scale, f2s, enc, dec, s2f, sink_scale, sink)
    return fg
Beispiel #54
0
    def __init__(self, audio_input_dev):
	gr.hier_block2.__init__(self, "audio_rx",
				gr.io_signature(0, 0, 0), # Input signature
				gr.io_signature(0, 0, 0)) # Output signature
        self.sample_rate = sample_rate = 8000
        src = audio.source(sample_rate, audio_input_dev)
        src_scale = blocks.multiply_const_ff(32767)
        f2s = blocks.float_to_short()
        voice_coder = vocoder.gsm_fr_encode_sp()
        self.packets_from_encoder = gr.msg_queue()
        packet_sink = blocks.message_sink(33, self.packets_from_encoder, False)
        self.connect(src, src_scale, f2s, voice_coder, packet_sink)
Beispiel #55
0
    def __init__(self):
        gr.top_block.__init__(self)

        ##################################################
        # Variables
        ##################################################
        self.signal_freq = signal_freq = 5000
        self.samp_rate = samp_rate = 48000
        self.bw = bw = 200

        ##################################################
        # Blocks
        ##################################################
        self.gr_probe_ref = gr.probe_signal_f()
        self.gr_probe_mag = gr.probe_signal_f()
        self.gr_probe_arg = gr.probe_signal_f()
        self.gr_nlog10_ff_ref = gr.nlog10_ff(1, 1, 0)
        self.gr_nlog10_ff_0 = gr.nlog10_ff(1, 1, 0)
        self.gr_divide_xx_0 = gr.divide_cc(1)
        self.gr_complex_to_mag_ref = gr.complex_to_mag(1)
        self.gr_complex_to_mag_0 = gr.complex_to_mag(1)
        self.gr_complex_to_arg_0 = gr.complex_to_arg(1)
        self.band_pass_filter_0_0 = gr.fir_filter_fcc(
            1,
            firdes.complex_band_pass(
                1, samp_rate, signal_freq - bw / 2, signal_freq + bw / 2, 100, firdes.WIN_BLACKMAN, 6.76
            ),
        )
        self.band_pass_filter_0 = gr.fir_filter_fcc(
            1,
            firdes.complex_band_pass(
                1, samp_rate, signal_freq - bw / 2, signal_freq + bw / 2, 100, firdes.WIN_BLACKMAN, 6.76
            ),
        )
        self.audio_source_0 = audio.source(samp_rate, "", True)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.band_pass_filter_0_0, 0), (self.gr_complex_to_mag_0, 0))
        self.connect((self.gr_complex_to_mag_0, 0), (self.gr_nlog10_ff_0, 0))
        self.connect((self.gr_divide_xx_0, 0), (self.gr_complex_to_arg_0, 0))
        self.connect((self.band_pass_filter_0_0, 0), (self.gr_divide_xx_0, 0))
        self.connect((self.band_pass_filter_0, 0), (self.gr_divide_xx_0, 1))
        self.connect((self.audio_source_0, 1), (self.band_pass_filter_0_0, 0))
        self.connect((self.audio_source_0, 0), (self.band_pass_filter_0, 0))
        self.connect((self.gr_nlog10_ff_0, 0), (self.gr_probe_mag, 0))
        self.connect((self.gr_complex_to_arg_0, 0), (self.gr_probe_arg, 0))

        self.connect((self.band_pass_filter_0, 0), (self.gr_complex_to_mag_ref, 0))
        self.connect((self.gr_complex_to_mag_ref, 0), (self.gr_nlog10_ff_ref, 0))
        self.connect((self.gr_nlog10_ff_ref, 0), (self.gr_probe_ref, 0))
Beispiel #56
0
	def __do_connect(self):
		self.disconnect_all()
		
		# work around OSX audio source bug; does not work across flowgraph restarts
		self.__source = audio.source(
			self.__sample_rate,
			device_name=self.__device_name,
			ok_to_block=True)
		
		self.connect(self.__source, self.__complex, self)
		if self.__quadrature_as_stereo:
			# if we don't do this, the imaginary component is 0 and the spectrum is symmetric
			self.connect((self.__source, 1), (self.__complex, 1))
Beispiel #57
0
 def __init__(self,pkt_size):
        gr.top_block.__init__(self)   
        sample_rate=48000
        vlen=(pkt_size-2)/4
        print "in sound init" 
        print "vlen=",vlen
        self.sound_src=audio.source (sample_rate,"hw:0,0")
        #self.conv=gr.float_to_uchar()
        #self.msgq = gr.msg_queue(100)
        self.stream_to_vec=gr.stream_to_vector(gr.sizeof_float,vlen)
        self.vec_sink=gr.vector_sink_f(vlen)
        #self.msg_sink=gr.message_sink(gr.sizeof_float,self.msgq,1)
        self.connect(self.sound_src,self.stream_to_vec,self.vec_sink)
Beispiel #58
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.samp_rate = samp_rate = 44100

        ##################################################
        # Blocks
        ##################################################
        self.wxgui_numbersink2_0 = numbersink2.number_sink_f(
            self.GetWin(),
            unit="Hz",
            minval=50,
            maxval=280,
            factor=1,
            decimal_places=2,
            ref_level=0,
            sample_rate=samp_rate,
            number_rate=15,
            average=False,
            avg_alpha=None,
            label="Number Plot",
            peak_hold=False,
            show_gauge=True,
        )
        self.Add(self.wxgui_numbersink2_0.win)
        self.blocks_moving_average_xx_0 = blocks.moving_average_ff(samp_rate / 50, 25 / pi, 200)
        self.blocks_keep_one_in_n_0 = blocks.keep_one_in_n(gr.sizeof_float * 1, 10)
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        self.band_pass_filter_0 = filter.fir_filter_ccc(
            1, firdes.complex_band_pass(1, samp_rate, 60, 255, 100, firdes.WIN_BLACKMAN, 6.76)
        )
        self.audio_source_0 = audio.source(samp_rate, "default", True)
        self.analog_pll_freqdet_cf_0 = analog.pll_freqdet_cf(
            200 * 2.0 * pi / samp_rate, 260 * 2.0 * pi / samp_rate, 60 * 2.0 * pi / samp_rate
        )

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_moving_average_xx_0, 0), (self.wxgui_numbersink2_0, 0))
        self.connect((self.blocks_float_to_complex_0, 0), (self.band_pass_filter_0, 0))
        self.connect((self.band_pass_filter_0, 0), (self.analog_pll_freqdet_cf_0, 0))
        self.connect((self.audio_source_0, 0), (self.blocks_float_to_complex_0, 0))
        self.connect((self.analog_pll_freqdet_cf_0, 0), (self.blocks_keep_one_in_n_0, 0))
        self.connect((self.blocks_keep_one_in_n_0, 0), (self.blocks_moving_average_xx_0, 0))
    def __init__(self, inputfile, callback, options):
        gr.top_block.__init__(self)

        # settings for the demodulator: /usr/local/lib/python2.5/site-packages/gnuradio/blks2impl/gmsk.py
        # settings for the demodulator: /usr/local/lib/python2.5/site-packages/gnuradio/blks2impl/pkt.py

        if options.dsp:
            self.src = audio.source(options.dsp_sample_rate, "", True)
        else:
            self.src = gr.wavfile_source( inputfile, False )

        self.iq_to_c = gr.float_to_complex()
        if options.dsp and options.wait:
            samples = options.dsp_sample_rate * options.wait
            self._head0 = gr.head(gr.sizeof_float, samples)
            self._head1 = gr.head(gr.sizeof_float, samples)
            self.connect( (self.src, 0), self._head0, (self.iq_to_c, 0) )
            self.connect( (self.src, 1), self._head1, (self.iq_to_c, 1) )
            if verbose: print "installed %d second head filter on dsp (%d samples at %d sps)" % (options.wait, samples, options.dsp_sample_rate)
        else:
            self.connect( (self.src, 0), (self.iq_to_c, 0) )
            self.connect( (self.src, 1), (self.iq_to_c, 1) )

        self.demodulator = blks2.gmsk_demod(samples_per_symbol=options.samples_per_symbol)
        self.pkt_queue   = blks2.demod_pkts( demodulator=self.demodulator, callback=callback, threshold=options.threshold )

        if options.carrier_frequency == 0:
            self.mixer = self.iq_to_c
        else:
            self.carrier  = gr.sig_source_c( options.carrier_sample_rate, gr.GR_SIN_WAVE, - options.carrier_frequency, 1.0 )
            self.mixer    = gr.multiply_vcc(1)
            self.connect(self.iq_to_c, (self.mixer, 0) )
            self.connect(self.carrier, (self.mixer, 1) )

        self.amp = gr.multiply_const_cc(1); self.amp.set_k(options.amp_amplitude)
        self.connect(self.mixer, self.amp, self.pkt_queue)

        if options.debug_wavs:
            from myblks import debugwav
            self._dpass = debugwav("rx_passband", options)
            self._dbase = debugwav("rx_baseband", options)
            self.connect(self.iq_to_c, self._dpass)
            self.connect(self.mixer,   self._dbase)

        if options.debug_files:
            self._dpassf = gr.file_sink(gr.sizeof_gr_complex*1, "debug_rx_passband.d_c")
            self._dbasef = gr.file_sink(gr.sizeof_gr_complex*1, "debug_rx_baseband.d_c")
            self.connect(self.iq_to_c, self._dpassf)
            self.connect(self.mixer,   self._dbasef)
Beispiel #60
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("Monthly_Test_WUAL_DEC-2013.wav", False)
        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.digital_gmsk_demod_0, 0))
        self.connect((self.digital_gmsk_demod_0, 0), (self.same_dec_0, 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.analog_pwr_squelch_xx_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0))

        self._watcher = _queue_watcher_thread(self.msg_queue)