Beispiel #1
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_oc_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
Beispiel #2
0
 def __init__(self, host, port, pkt_size, sample_rate, eof):
     gr.top_block.__init__(self, "audio_sink")
     src = blocks.udp_source(gr.sizeof_float, host, port, pkt_size, eof=eof)
     dst = audio.sink(sample_rate)
     self.connect(src, dst)
Beispiel #3
0
 def __init__(self, host, port, pkt_size, sample_rate, eof):
     gr.top_block.__init__(self, "dial_tone_sink")
     udp = blocks.udp_source(gr.sizeof_float, host, port, pkt_size, eof=eof)
     sink = audio.sink(sample_rate)
     self.connect(udp, sink)