def __init__(self, parent, baseband_freq=0, y_per_div=10, ref_level=50, sample_rate=1, fac_size=512, fac_rate=default_fac_rate, average=False, avg_alpha=None, title='', size=default_facsink_size, peak_hold=False): fac_sink_base.__init__(self, input_is_real=True, baseband_freq=baseband_freq, y_per_div=y_per_div, ref_level=ref_level, sample_rate=sample_rate, fac_size=fac_size, fac_rate=fac_rate, average=average, avg_alpha=avg_alpha, title=title, peak_hold=peak_hold) s2p = blocks.stream_to_vector(gr.sizeof_float, self.fac_size) self.one_in_n = blocks.keep_one_in_n(gr.sizeof_float * self.fac_size, max(1, int(self.sample_rate/self.fac_size/self.fac_rate))) # windowing removed... #fac = gr.fft_vfc(self.fac_size, True, ()) fac = fft.fft_vfc(self.fac_size, True, ()) c2mag = blocks.complex_to_mag(self.fac_size) self.avg = filter.single_pole_iir_filter_ff_make(1.0, self.fac_size) fac_fac = fft.fft_vfc(self.fac_size, True, ()) fac_c2mag = blocks.complex_to_mag_make(fac_size) # FIXME We need to add 3dB to all bins but the DC bin log = blocks.nlog10_ff_make(20, self.fac_size, -20*math.log10(self.fac_size) ) sink = blocks.message_sink(gr.sizeof_float * self.fac_size, self.msgq, True) self.connect(s2p, self.one_in_n, fac, c2mag, fac_fac, fac_c2mag, self.avg, log, sink) # gr.hier_block.__init__(self, fg, s2p, sink) self.win = fac_window(self, parent, size=size) self.set_average(self.average) self.wxgui_connect(self, s2p)
def __init__(self, parent, baseband_freq=0, y_per_div=10, ref_level=50, sample_rate=1, fac_size=512, fac_rate=default_fac_rate, average=False, avg_alpha=None, title='', size=default_facsink_size, peak_hold=False): fac_sink_base.__init__(self, input_is_real=False, baseband_freq=baseband_freq, y_per_div=y_per_div, ref_level=ref_level, sample_rate=sample_rate, fac_size=fac_size, fac_rate=fac_rate, average=average, avg_alpha=avg_alpha, title=title, peak_hold=peak_hold) s2p = blocks.stream_to_vector(gr.sizeof_gr_complex, self.fac_size) self.one_in_n = blocks.keep_one_in_n(gr.sizeof_gr_complex * self.fac_size, max(1, int(self.sample_rate/self.fac_size/self.fac_rate))) # windowing removed ... fac = fft.fft_vcc(self.fac_size, True, ()) c2mag = blocks.complex_to_mag_make(fac_size) # Things go off into the weeds if we try for an inverse FFT so a forward FFT will have to do... fac_fac = fft.fft_vfc(self.fac_size, True, ()) fac_c2mag = blocks.complex_to_mag_make(fac_size) self.avg = filter.single_pole_iir_filter_ff_make(1.0, fac_size) log = blocks.nlog10_ff_make(20, self.fac_size, -20*math.log10(self.fac_size) ) # - 20*math.log10(norm) ) # - self.avg[0] ) sink = blocks.message_sink_make(gr.sizeof_float * fac_size, self.msgq, True) self.connect(s2p, self.one_in_n, fac, c2mag, fac_fac, fac_c2mag, self.avg, log, sink) # gr.hier_block2.__init__(self, fg, s2p, sink) self.win = fac_window(self, parent, size=size) self.set_average(self.average) self.wxgui_connect(self, s2p)
def __init__(self, sample_rate, fac_size, fac_decimation, useDB): gr.hier_block2.__init__( self, "AutoCorrelator", gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature gr.io_signature(1, 1, gr.sizeof_float * fac_size)) # Output signature self.fac_size = fac_size self.fac_decimation = fac_decimation self.sample_rate = sample_rate streamToVec = blocks.stream_to_vector(gr.sizeof_gr_complex, self.fac_size) # Make sure N is at least 1 decimation = int(self.sample_rate / self.fac_size / self.fac_decimation) self.one_in_n = blocks.keep_one_in_n( gr.sizeof_gr_complex * self.fac_size, max(1, decimation)) # FFT Note: No windowing. fac = fft.fft_vcc(self.fac_size, True, ()) complex2Mag = blocks.complex_to_mag(self.fac_size) self.avg = filter.single_pole_iir_filter_ff_make(1.0, self.fac_size) fac_fac = fft.fft_vfc(self.fac_size, True, ()) fac_c2mag = blocks.complex_to_mag_make(fac_size) # There's a note in Baz's block about needing to add 3 dB to each bin but the DC bin, however it was never implemented n = 20 k = -20 * math.log10(self.fac_size) log = blocks.nlog10_ff_make(n, self.fac_size, k) if useDB: self.connect(self, streamToVec, self.one_in_n, fac, complex2Mag, fac_fac, fac_c2mag, self.avg, log, self) else: self.connect(self, streamToVec, self.one_in_n, fac, complex2Mag, fac_fac, fac_c2mag, self.avg, self)