Beispiel #1
0
    def __init__(self, delay_num, delay_denom):
        gr.hier_block2.__init__(self, "moms",
                                gr.io_signature(1, 1, gr.sizeof_gr_complex),
                                gr.io_signature(1, 1, gr.sizeof_gr_complex))

        cmplx_to_real = blocks.complex_to_real()
        cmplx_to_img = blocks.complex_to_imag()

        iirf_real = filter.iir_filter_ffd([1.5], [1, -0.5])
        self.moms_real = moms_ff()
        self.moms_real.set_init_ip_fraction(delay_num, delay_denom)

        iirf_imag = filter.iir_filter_ffd([1.5], [1, -0.5])
        self.moms_imag = moms_ff()
        self.moms_imag.set_init_ip_fraction(delay_num, delay_denom)

        float_to_cmplx = blocks.float_to_complex()

        self.connect((self, 0), (cmplx_to_real, 0))
        self.connect((self, 0), (cmplx_to_img, 0))
        self.connect((cmplx_to_real, 0), (iirf_real, 0))
        self.connect((cmplx_to_img, 0), (iirf_imag, 0))
        self.connect((iirf_real, 0), (self.moms_real, 0))
        self.connect((iirf_imag, 0), (self.moms_imag, 0))
        self.connect((self.moms_real, 0), (float_to_cmplx, 0))
        self.connect((self.moms_imag, 0), (float_to_cmplx, 1))
        self.connect((float_to_cmplx, 0), (self, 0))
Beispiel #2
0
  def __init__(self,delay_num,delay_denom):
    gr.hier_block2.__init__(self,"moms",
      gr.io_signature(1,1,gr.sizeof_gr_complex),
      gr.io_signature(1,1,gr.sizeof_gr_complex))

    cmplx_to_real  = blocks.complex_to_real()
    cmplx_to_img   = blocks.complex_to_imag()

    iirf_real = filter.iir_filter_ffd([1.5],[1, -0.5])
    self.moms_real = moms_ff()
    self.moms_real.set_init_ip_fraction(delay_num,delay_denom)

    iirf_imag = filter.iir_filter_ffd([1.5],[1, -0.5])
    self.moms_imag = moms_ff()
    self.moms_imag.set_init_ip_fraction(delay_num,delay_denom)

    float_to_cmplx = blocks.float_to_complex()

    self.connect((self,0),            (cmplx_to_real,0))
    self.connect((self,0),            (cmplx_to_img,0))
    self.connect((cmplx_to_real,0),   (iirf_real,0))
    self.connect((cmplx_to_img,0),    (iirf_imag,0))
    self.connect((iirf_real,0),       (self.moms_real,0))
    self.connect((iirf_imag,0),       (self.moms_imag,0))
    self.connect((self.moms_real,0),  (float_to_cmplx,0))
    self.connect((self.moms_imag,0),  (float_to_cmplx,1))
    self.connect((float_to_cmplx,0),  (self,0))
    def __init__(self, alpha=0.0001, threshold_db=-10, gate=False):
        gr.hier_block2.__init__(
            self,
            "standard_squelch",
            gr.io_signature(1, 1, gr.sizeof_float),  # Input signature
            gr.io_signature(1, 1, gr.sizeof_float))  # Output signature

        #fixed coeffs, Chebyshev type 2 LPF=[0, 0.4, 0.7], HPF=[0.4, 0.7, 1]
        self.low_iir = iir_filter_ffd([
            0.12260106307699403, -0.22058023529806434, 0.22058023529806436,
            -0.12260106307699434
        ], [
            1.00000000000000000, 0.7589332900264623, 0.5162740252200005,
            0.07097813844342238
        ], False)
        self.low_square = blocks.multiply_ff()
        self.low_smooth = single_pole_iir_filter_ff(alpha)

        self.hi_iir = iir_filter_ffd([
            0.1913118666668073, 0.4406071020350289, 0.4406071020350288,
            0.19131186666680736
        ], [
            1.000000000000000000, -0.11503633296078866, 0.3769676347066441,
            0.0019066356578167866
        ], False)
        self.hi_square = blocks.multiply_ff()
        self.hi_smooth = single_pole_iir_filter_ff(alpha)

        #inverted thresholds because we reversed the division block inputs
        #to make the threshold output 1 when open and 0 when closed
        self.gate = blocks.threshold_ff(0, 0, 0)
        self.set_threshold(threshold_db)
        self.squelch_lpf = single_pole_iir_filter_ff(alpha)
        self.squelch_mult = blocks.multiply_ff()
        self.div = blocks.divide_ff()

        #This is horrible, but there's no better way to gate samples.
        #the block is fast, so realistically there's little overhead
        #TODO: implement a valve block that gates based on an input value
        self.valve = analog.pwr_squelch_ff(-100, 1, 0, gate)

        #sample path
        self.connect(self, (self.squelch_mult, 0))

        #filter path (LPF)
        self.connect(self, self.low_iir)
        self.connect(self.low_iir, (self.low_square, 0))
        self.connect(self.low_iir, (self.low_square, 1))
        self.connect(self.low_square, self.low_smooth, (self.div, 0))

        #filter path (HPF)
        self.connect(self, self.hi_iir)
        self.connect(self.hi_iir, (self.hi_square, 0))
        self.connect(self.hi_iir, (self.hi_square, 1))
        self.connect(self.hi_square, self.hi_smooth, (self.div, 1))

        #control path
        self.connect(self.div, self.gate, self.squelch_lpf,
                     (self.squelch_mult, 1))
        self.connect(self.squelch_mult, self)
Beispiel #4
0
    def __init__(self):
        gr.hier_block2.__init__(
            self,
            "BER Computation",
            gr.io_signaturev(
                2, 2, [gr.sizeof_gr_complex * 1, gr.sizeof_gr_complex * 1]),
            gr.io_signaturev(2, 2, [gr.sizeof_float * 1, gr.sizeof_float * 1]),
        )

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 32000

        ##################################################
        # Blocks
        ##################################################
        self.iir_filter_xxx_0_0 = filter.iir_filter_ffd([1], [1, 1], True)
        self.iir_filter_xxx_0 = filter.iir_filter_ffd([1], [1, 1], True)
        self.blocks_tag_gate_0 = blocks.tag_gate(gr.sizeof_gr_complex * 1,
                                                 False)
        self.blocks_tag_gate_0.set_single_key("")
        self.blocks_sub_xx_0 = blocks.sub_cc(1)
        self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_cc(0)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_cc(0.5)
        self.blocks_max_xx_0_0 = blocks.max_ff(1, 1)
        self.blocks_max_xx_0 = blocks.max_ff(1, 1)
        self.blocks_divide_xx_0 = blocks.divide_ff(1)
        self.blocks_complex_to_mag_0_0 = blocks.complex_to_mag(1)
        self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1)
        self.blocks_add_const_vxx_0 = blocks.add_const_cc(1)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_add_const_vxx_0, 0),
                     (self.blocks_complex_to_mag_0_0, 0))
        self.connect((self.blocks_complex_to_mag_0, 0),
                     (self.iir_filter_xxx_0, 0))
        self.connect((self.blocks_complex_to_mag_0_0, 0),
                     (self.iir_filter_xxx_0_0, 0))
        self.connect((self.blocks_divide_xx_0, 0), (self, 0))
        self.connect((self.blocks_max_xx_0, 0), (self.blocks_divide_xx_0, 1))
        self.connect((self.blocks_max_xx_0_0, 0), (self.blocks_divide_xx_0, 0))
        self.connect((self.blocks_max_xx_0_0, 0), (self, 1))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.blocks_complex_to_mag_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0_0, 0),
                     (self.blocks_add_const_vxx_0, 0))
        self.connect((self.blocks_sub_xx_0, 0), (self.blocks_tag_gate_0, 0))
        self.connect((self.blocks_tag_gate_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.blocks_tag_gate_0, 0),
                     (self.blocks_multiply_const_vxx_0_0, 0))
        self.connect((self.iir_filter_xxx_0, 0), (self.blocks_max_xx_0_0, 0))
        self.connect((self.iir_filter_xxx_0_0, 0), (self.blocks_max_xx_0, 0))
        self.connect((self, 0), (self.blocks_sub_xx_0, 0))
        self.connect((self, 1), (self.blocks_sub_xx_0, 1))
Beispiel #5
0
    def __init__(self, audio_rate):
        gr.hier_block2.__init__(
            self,
            "standard_squelch",
            # Input signature
            gr.io_signature(1, 1, gr.sizeof_float),
            gr.io_signature(1, 1, gr.sizeof_float))  # Output signature

        self.input_node = blocks.add_const_ff(0)  # FIXME kludge

        self.low_iir = filter.iir_filter_ffd((0.0193, 0, -0.0193),
                                             (1, 1.9524, -0.9615))
        self.low_square = blocks.multiply_ff()
        self.low_smooth = filter.single_pole_iir_filter_ff(
            1 / (0.01 * audio_rate))  # 100ms time constant

        self.hi_iir = filter.iir_filter_ffd((0.0193, 0, -0.0193),
                                            (1, 1.3597, -0.9615))
        self.hi_square = blocks.multiply_ff()
        self.hi_smooth = filter.single_pole_iir_filter_ff(1 /
                                                          (0.01 * audio_rate))

        self.sub = blocks.sub_ff()
        self.add = blocks.add_ff()
        self.gate = blocks.threshold_ff(0.3, 0.43, 0)
        self.squelch_lpf = filter.single_pole_iir_filter_ff(
            1 / (0.01 * audio_rate))

        self.div = blocks.divide_ff()
        self.squelch_mult = blocks.multiply_ff()

        self.connect(self, self.input_node)
        self.connect(self.input_node, (self.squelch_mult, 0))

        self.connect(self.input_node, self.low_iir)
        self.connect(self.low_iir, (self.low_square, 0))
        self.connect(self.low_iir, (self.low_square, 1))
        self.connect(self.low_square, self.low_smooth, (self.sub, 0))
        self.connect(self.low_smooth, (self.add, 0))

        self.connect(self.input_node, self.hi_iir)
        self.connect(self.hi_iir, (self.hi_square, 0))
        self.connect(self.hi_iir, (self.hi_square, 1))
        self.connect(self.hi_square, self.hi_smooth, (self.sub, 1))
        self.connect(self.hi_smooth, (self.add, 1))

        self.connect(self.sub, (self.div, 0))
        self.connect(self.add, (self.div, 1))
        self.connect(self.div, self.gate, self.squelch_lpf,
                     (self.squelch_mult, 1))
        self.connect(self.squelch_mult, self)
    def __init__(self, alpha=0.0001, threshold_db=-10, gate=False):
        gr.hier_block2.__init__(self, "standard_squelch",
                                gr.io_signature(1, 1, gr.sizeof_float), # Input signature
                                gr.io_signature(1, 1, gr.sizeof_float)) # Output signature


        #fixed coeffs, Chebyshev type 2 LPF=[0, 0.4, 0.7], HPF=[0.4, 0.7, 1]
        self.low_iir = iir_filter_ffd([0.12260106307699403, -0.22058023529806434, 0.22058023529806436, -0.12260106307699434],
                                             [1.00000000000000000, 0.7589332900264623, 0.5162740252200005, 0.07097813844342238],
                                             False)
        self.low_square = blocks.multiply_ff()
        self.low_smooth = single_pole_iir_filter_ff(alpha)

        self.hi_iir = iir_filter_ffd([0.1913118666668073, 0.4406071020350289, 0.4406071020350288, 0.19131186666680736],
                                            [1.000000000000000000, -0.11503633296078866, 0.3769676347066441, 0.0019066356578167866], 
                                             False)
        self.hi_square = blocks.multiply_ff()
        self.hi_smooth = single_pole_iir_filter_ff(alpha)

        #inverted thresholds because we reversed the division block inputs
        #to make the threshold output 1 when open and 0 when closed
        self.gate = blocks.threshold_ff(0,0,0)
        self.set_threshold(threshold_db)
        self.squelch_lpf = single_pole_iir_filter_ff(alpha)
        self.squelch_mult = blocks.multiply_ff()
        self.div = blocks.divide_ff()

        #This is horrible, but there's no better way to gate samples.
        #the block is fast, so realistically there's little overhead
        #TODO: implement a valve block that gates based on an input value
        self.valve = analog.pwr_squelch_ff(-100, 1, 0, gate)

        #sample path
        self.connect(self, (self.squelch_mult, 0))

        #filter path (LPF)
        self.connect(self,self.low_iir)
        self.connect(self.low_iir,(self.low_square,0))
        self.connect(self.low_iir,(self.low_square,1))
        self.connect(self.low_square,self.low_smooth,(self.div,0))

        #filter path (HPF)
        self.connect(self,self.hi_iir)
        self.connect(self.hi_iir,(self.hi_square,0))
        self.connect(self.hi_iir,(self.hi_square,1))
        self.connect(self.hi_square,self.hi_smooth,(self.div,1))

        #control path
        self.connect(self.div, self.gate, self.squelch_lpf, (self.squelch_mult,1))
        self.connect(self.squelch_mult, self)
Beispiel #7
0
    def __init__(self, fs, tau=75e-6):
        """
        
        Args:
            fs: sampling frequency in Hz (float)
            tau: Time constant in seconds (75us in US, 50us in EUR) (float)
        """
        gr.hier_block2.__init__(self, "fm_deemph",
				gr.io_signature(1, 1, gr.sizeof_float), # Input signature
				gr.io_signature(1, 1, gr.sizeof_float)) # Output signature

        w_p = 1/tau
        w_pp = math.tan (w_p / (fs * 2)) # prewarped analog freq

        a1 = (w_pp - 1)/(w_pp + 1)
        b0 = w_pp/(1 + w_pp)
        b1 = b0

        btaps = [b0, b1]
        ataps = [1, a1]

        if 0:
            print "btaps =", btaps
            print "ataps =", ataps
            global plot1
            plot1 = gru.gnuplot_freqz (gru.freqz (btaps, ataps), fs, True)

        deemph = filter.iir_filter_ffd(btaps, ataps)
	self.connect(self, deemph, self)
Beispiel #8
0
    def __init__(self, fs, tau=75e-6):
        """
        
        Args:
            fs: sampling frequency in Hz (float)
            tau: Time constant in seconds (75us in US, 50us in EUR) (float)
        """

	gr.hier_block2.__init__(self, "fm_deemph",
				gr.io_signature(1, 1, gr.sizeof_float), # Input signature
				gr.io_signature(1, 1, gr.sizeof_float)) # Output signature

        # FIXME make this compute the right answer

        btaps = [1]
        ataps = [1]

        if 0:
            print "btaps =", btaps
            print "ataps =", ataps
            global plot2
            plot2 = gru.gnuplot_freqz (gru.freqz (btaps, ataps), fs, True)

        preemph = filter.iir_filter_ffd(btaps, ataps)
	self.connect(self, preemph, self)
Beispiel #9
0
    def __init__(self, fs, tau=75e-6):
        """
        
        Args:
            fs: sampling frequency in Hz (float)
            tau: Time constant in seconds (75us in US, 50us in EUR) (float)
        """

	gr.hier_block2.__init__(self, "fm_deemph",
				gr.io_signature(1, 1, gr.sizeof_float), # Input signature
				gr.io_signature(1, 1, gr.sizeof_float)) # Output signature

        # FIXME make this compute the right answer

        btaps = [1]
        ataps = [1]

        if 0:
            print "btaps =", btaps
            print "ataps =", ataps
            global plot2
            plot2 = gru.gnuplot_freqz(gru.freqz(btaps, ataps), fs, True)

        preemph = filter.iir_filter_ffd(btaps, ataps)
	self.connect(self, preemph, self)
Beispiel #10
0
    def __init__(self, fs, tau=75e-6):
        gr.hier_block2.__init__(
            self,
            "fm_deemph",
            gr.io_signature(1, 1, gr.sizeof_float),  # Input signature
            gr.io_signature(1, 1, gr.sizeof_float))  # Output signature

        # Digital corner frequency
        w_c = 1.0 / tau

        # Prewarped analog corner frequency
        w_ca = 2.0 * fs * math.tan(w_c / (2.0 * fs))

        # Resulting digital pole, zero, and gain term from the bilinear
        # transformation of H(s) = w_ca / (s + w_ca) to
        # H(z) = b0 (1 - z1 z^-1)/(1 - p1 z^-1)
        k = -w_ca / (2.0 * fs)
        z1 = -1.0
        p1 = (1.0 + k) / (1.0 - k)
        b0 = -k / (1.0 - k)

        btaps = [b0 * 1.0, b0 * -z1]
        ataps = [1.0, -p1]

        # Since H(s = 0) = 1.0, then H(z = 1) = 1.0 and has 0 dB gain at DC

        if 0:
            print("btaps =", btaps)
            print("ataps =", ataps)
            global plot1
            plot1 = gru.gnuplot_freqz(gru.freqz(btaps, ataps), fs, True)

        deemph = filter.iir_filter_ffd(btaps, ataps, False)
        self.connect(self, deemph, self)
Beispiel #11
0
    def __init__(self, fs, tau=75e-6):
        gr.hier_block2.__init__(self, "fm_deemph",
                                gr.io_signature(1, 1, gr.sizeof_float),  # Input signature
                                gr.io_signature(1, 1, gr.sizeof_float))  # Output signature

        # Digital corner frequency
        w_c = 1.0 / tau

        # Prewarped analog corner frequency
        w_ca = 2.0 * fs * math.tan(w_c / (2.0 * fs))

        # Resulting digital pole, zero, and gain term from the bilinear
        # transformation of H(s) = w_ca / (s + w_ca) to
        # H(z) = b0 (1 - z1 z^-1)/(1 - p1 z^-1)
        k = -w_ca / (2.0 * fs)
        z1 = -1.0
        p1 = (1.0 + k) / (1.0 - k)
        b0 = -k / (1.0 - k)

        btaps = [ b0 * 1.0, b0 * -z1 ]
        ataps = [      1.0,      -p1 ]

        # Since H(s = 0) = 1.0, then H(z = 1) = 1.0 and has 0 dB gain at DC

        if 0:
            print("btaps =", btaps)
            print("ataps =", ataps)
            global plot1
            plot1 = gru.gnuplot_freqz(gru.freqz(btaps, ataps), fs, True)

        deemph = filter.iir_filter_ffd(btaps, ataps, False)
        self.connect(self, deemph, self)
Beispiel #12
0
    def __init__(self, fs, tau=75e-6):
        """
        
        Args:
            fs: sampling frequency in Hz (float)
            tau: Time constant in seconds (75us in US, 50us in EUR) (float)
        """
        gr.hier_block2.__init__(self, "fm_deemph",
				gr.io_signature(1, 1, gr.sizeof_float), # Input signature
				gr.io_signature(1, 1, gr.sizeof_float)) # Output signature

        w_p = 1/tau
        w_pp = math.tan(w_p / (fs * 2)) # prewarped analog freq

        a1 = (w_pp - 1)/(w_pp + 1)
        b0 = w_pp/(1 + w_pp)
        b1 = b0

        btaps = [b0, b1]
        ataps = [1, a1]

        if 0:
            print "btaps =", btaps
            print "ataps =", ataps
            global plot1
            plot1 = gru.gnuplot_freqz(gru.freqz(btaps, ataps), fs, True)

        deemph = filter.iir_filter_ffd(btaps, ataps)
	self.connect(self, deemph, self)
Beispiel #13
0
    def __init__(self, fs, tau=75e-6, fh=-1.0):
        """

        Args:
            fs: sampling frequency in Hz (float)
            tau: Time constant in seconds (75us in US, 50us in EUR) (float)
            fh: High frequency at which to flatten out (< 0 means default of 0.925*fs/2.0) (float)
        """
        gr.hier_block2.__init__(
            self,
            "fm_preemph",
            gr.io_signature(1, 1, gr.sizeof_float),  # Input signature
            gr.io_signature(1, 1, gr.sizeof_float))  # Output signature

        # Set fh to something sensible, if needed.
        # N.B. fh == fs/2.0 or fh == 0.0 results in a pole on the unit circle
        # at z = -1.0 or z = 1.0 respectively.  That makes the filter unstable
        # and useless.
        if fh <= 0.0 or fh >= fs / 2.0:
            fh = 0.925 * fs / 2.0

# Digital corner frequencies
        w_cl = 1.0 / tau
        w_ch = 2.0 * math.pi * fh

        # Prewarped analog corner frequencies
        w_cla = 2.0 * fs * math.tan(w_cl / (2.0 * fs))
        w_cha = 2.0 * fs * math.tan(w_ch / (2.0 * fs))

        # Resulting digital pole, zero, and gain term from the bilinear
        # transformation of H(s) = (s + w_cla) / (s + w_cha) to
        # H(z) = b0 (1 - z1 z^-1)/(1 - p1 z^-1)
        kl = -w_cla / (2.0 * fs)
        kh = -w_cha / (2.0 * fs)
        z1 = (1.0 + kl) / (1.0 - kl)
        p1 = (1.0 + kh) / (1.0 - kh)
        b0 = (1.0 - kl) / (1.0 - kh)

        # Since H(s = infinity) = 1.0, then H(z = -1) = 1.0 and
        # this filter  has 0 dB gain at fs/2.0.
        # That isn't what users are going to expect, so adjust with a
        # gain, g, so that H(z = 1) = 1.0 for 0 dB gain at DC.
        w_0dB = 2.0 * math.pi * 0.0
        g =        abs(1.0 - p1 * cmath.rect(1.0, -w_0dB))  \
           / (b0 * abs(1.0 - z1 * cmath.rect(1.0, -w_0dB)))

        btaps = [g * b0 * 1.0, g * b0 * -z1]
        ataps = [1.0, -p1]

        if 0:
            print "btaps =", btaps
            print "ataps =", ataps
            global plot2
            plot2 = gru.gnuplot_freqz(gru.freqz(btaps, ataps), fs, True)

        preemph = filter.iir_filter_ffd(btaps, ataps, False)
        self.connect(self, preemph, self)
Beispiel #14
0
    def init(self, freq=50.0, mod=0.9):
        theta = 2 * np.pi * 50 / self.input.sample_rate
        zero = np.exp(np.array([1j, -1j]) * theta)
        pole = mod * zero

        a, b = np.poly(pole), np.poly(zero)
        #notch_ab = numpy.poly(zero), numpy.poly(pole)
        #notch_ab = scipy.signal.iirfilter(32, [30.0 / 125], btype='low')

        self.gr_block = filter.iir_filter_ffd(b, a, oldstyle=False)
Beispiel #15
0
    def init(self, lo, hi): 
        nyquist = self.input.sample_rate / 2.0
        Wp = [lo / nyquist, hi / nyquist]
        #Ws = [(lo - 1) / nyquist, (hi+1) / nyquist]
        #b, a = scipy.signal.iirdesign(Wp, Ws, 0.1, 60.0)
        b, a = scipy.signal.iirfilter(6, Wp, btype='bandpass',
            ftype='ellip', rp=0.1, rs=60.0)

        #self.gr_block = filter.iir_filter_ffd(a, b, oldstyle=False)
        self.gr_block = filter.iir_filter_ffd(b, a, oldstyle=False)
Beispiel #16
0
    def init(self, lo, hi): 
        nyquist = self.input.sample_rate / 2.0
        Wp = [lo / nyquist, hi / nyquist]
        #Ws = [(lo - 1) / nyquist, (hi+1) / nyquist]
        #b, a = scipy.signal.iirdesign(Wp, Ws, 0.1, 60.0)
        b, a = scipy.signal.iirfilter(6, Wp, btype='bandpass',
            ftype='ellip', rp=0.1, rs=60.0)

        #self.gr_block = filter.iir_filter_ffd(a, b, oldstyle=False)
        self.gr_block = filter.iir_filter_ffd(b, a, oldstyle=False)
Beispiel #17
0
    def init(self, freq=50.0, mod=0.9):
        theta = 2 * np.pi * 50 / self.input.sample_rate
        zero = np.exp(np.array([1j, -1j]) * theta)
        pole = mod * zero

        a, b = np.poly(pole), np.poly(zero)
        #notch_ab = numpy.poly(zero), numpy.poly(pole)
        #notch_ab = scipy.signal.iirfilter(32, [30.0 / 125], btype='low')

        self.gr_block = filter.iir_filter_ffd(b, a, oldstyle=False)
Beispiel #18
0
    def __init__(self, fs, tau=75e-6, fh=-1.0):
        """

        Args:
            fs: sampling frequency in Hz (float)
            tau: Time constant in seconds (75us in US, 50us in EUR) (float)
            fh: High frequency at which to flatten out (< 0 means default of 0.925*fs/2.0) (float)
        """
        gr.hier_block2.__init__(self, "fm_preemph",
                                gr.io_signature(1, 1, gr.sizeof_float),  # Input signature
                                gr.io_signature(1, 1, gr.sizeof_float))  # Output signature

	# Set fh to something sensible, if needed.
	# N.B. fh == fs/2.0 or fh == 0.0 results in a pole on the unit circle
	# at z = -1.0 or z = 1.0 respectively.  That makes the filter unstable
	# and useless.
	if fh <= 0.0 or fh >= fs/2.0:
		fh = 0.925 * fs/2.0

	# Digital corner frequencies
	w_cl = 1.0 / tau
	w_ch = 2.0 * math.pi * fh

	# Prewarped analog corner frequencies
	w_cla = 2.0 * fs * math.tan(w_cl / (2.0 * fs))
	w_cha = 2.0 * fs * math.tan(w_ch / (2.0 * fs))

	# Resulting digital pole, zero, and gain term from the bilinear
	# transformation of H(s) = (s + w_cla) / (s + w_cha) to
	# H(z) = b0 (1 - z1 z^-1)/(1 - p1 z^-1)
	kl = -w_cla / (2.0 * fs)
	kh = -w_cha / (2.0 * fs)
	z1 = (1.0 + kl) / (1.0 - kl)
	p1 = (1.0 + kh) / (1.0 - kh)
	b0 = (1.0 - kl) / (1.0 - kh)

	# Since H(s = infinity) = 1.0, then H(z = -1) = 1.0 and
	# this filter  has 0 dB gain at fs/2.0.
	# That isn't what users are going to expect, so adjust with a
	# gain, g, so that H(z = 1) = 1.0 for 0 dB gain at DC.
	w_0dB = 2.0 * math.pi * 0.0
	g =        abs(1.0 - p1 * cmath.rect(1.0, -w_0dB))  \
	   / (b0 * abs(1.0 - z1 * cmath.rect(1.0, -w_0dB)))

	btaps = [ g * b0 * 1.0, g * b0 * -z1 ]
	ataps = [          1.0,          -p1 ]

        if 0:
            print "btaps =", btaps
            print "ataps =", ataps
            global plot2
            plot2 = gru.gnuplot_freqz(gru.freqz(btaps, ataps), fs, True)

        preemph = filter.iir_filter_ffd(btaps, ataps, False)
        self.connect(self, preemph, self)
    def __init__(self, audio_rate):
	gr.hier_block2.__init__(self, "standard_squelch",
				gr.io_signature(1, 1, gr.sizeof_float), # Input signature
				gr.io_signature(1, 1, gr.sizeof_float)) # Output signature

        self.input_node = blocks.add_const_ff(0)          # FIXME kludge

        self.low_iir = filter.iir_filter_ffd((0.0193,0,-0.0193),(1,1.9524,-0.9615))
        self.low_square = blocks.multiply_ff()
        self.low_smooth = filter.single_pole_iir_filter_ff(1/(0.01*audio_rate))   # 100ms time constant

        self.hi_iir = filter.iir_filter_ffd((0.0193,0,-0.0193),(1,1.3597,-0.9615))
        self.hi_square = blocks.multiply_ff()
        self.hi_smooth = filter.single_pole_iir_filter_ff(1/(0.01*audio_rate))

        self.sub = blocks.sub_ff();
        self.add = blocks.add_ff();
        self.gate = blocks.threshold_ff(0.3,0.43,0)
        self.squelch_lpf = filter.single_pole_iir_filter_ff(1/(0.01*audio_rate))

        self.div = blocks.divide_ff()
        self.squelch_mult = blocks.multiply_ff()

	self.connect(self, self.input_node)
        self.connect(self.input_node, (self.squelch_mult, 0))

        self.connect(self.input_node,self.low_iir)
        self.connect(self.low_iir,(self.low_square,0))
        self.connect(self.low_iir,(self.low_square,1))
        self.connect(self.low_square,self.low_smooth,(self.sub,0))
        self.connect(self.low_smooth, (self.add,0))

        self.connect(self.input_node,self.hi_iir)
        self.connect(self.hi_iir,(self.hi_square,0))
        self.connect(self.hi_iir,(self.hi_square,1))
        self.connect(self.hi_square,self.hi_smooth,(self.sub,1))
        self.connect(self.hi_smooth, (self.add,1))

        self.connect(self.sub, (self.div, 0))
        self.connect(self.add, (self.div, 1))
        self.connect(self.div, self.gate, self.squelch_lpf, (self.squelch_mult,1))
	self.connect(self.squelch_mult, self)
Beispiel #20
0
 def test_iir_direct_005(self):
     src_data = (1, 2, 3, 4, 5, 6, 7, 8)
     fftaps = (2, 11, 0)
     fbtaps = (0, -1, 3)
     expected_result = (2, 13, 21, 59, 58, 186, 68, 583)
     src = blocks.vector_source_f(src_data)
     op = filter.iir_filter_ffd(fftaps, fbtaps)
     dst = blocks.vector_sink_f()
     self.tb.connect(src, op)
     self.tb.connect(op, dst)
     self.tb.run()
     result_data = dst.data()
     self.assertFloatTuplesAlmostEqual(expected_result, result_data)
Beispiel #21
0
 def test_iir_direct_003(self):
     src_data = (1, 2, 3, 4, 5, 6, 7, 8)
     fftaps = (2, 11)
     fbtaps = (0, 0)
     expected_result = (2, 15, 28, 41, 54, 67, 80, 93)
     src = blocks.vector_source_f(src_data)
     op = filter.iir_filter_ffd(fftaps, fbtaps)
     dst = blocks.vector_sink_f()
     self.tb.connect(src, op)
     self.tb.connect(op, dst)
     self.tb.run()
     result_data = dst.data()
     self.assertFloatTuplesAlmostEqual(expected_result, result_data)
Beispiel #22
0
 def test_iir_direct_005(self):
     src_data = (1, 2, 3, 4, 5, 6, 7, 8)
     fftaps = (2, 11, 0)
     fbtaps = (0, -1, 3)
     expected_result = (2, 13, 21, 59, 58, 186, 68, 583)
     src = blocks.vector_source_f(src_data)
     op = filter.iir_filter_ffd(fftaps, fbtaps)
     dst = blocks.vector_sink_f()
     self.tb.connect(src, op)
     self.tb.connect(op, dst)
     self.tb.run()
     result_data = dst.data()
     self.assertFloatTuplesAlmostEqual(expected_result, result_data)
Beispiel #23
0
 def test_iir_direct_003(self):
     src_data = (1, 2, 3, 4, 5, 6, 7, 8)
     fftaps = (2, 11)
     fbtaps = (0, 0)
     expected_result = (2, 15, 28, 41, 54, 67, 80, 93)
     src = blocks.vector_source_f(src_data)
     op = filter.iir_filter_ffd(fftaps, fbtaps)
     dst = blocks.vector_sink_f()
     self.tb.connect(src, op)
     self.tb.connect(op, dst)
     self.tb.run()
     result_data = dst.data()
     self.assertFloatTuplesAlmostEqual(expected_result, result_data)
Beispiel #24
0
 def test_iir_direct_008(self):
     src_data = (1, 2, 3, 4, 5, 6, 7, 8)
     expected_result = (2, 4, 4, 10, 18, 14, 26, 56)
     fftaps = (2, )
     fbtaps = (0, 1)
     src = blocks.vector_source_f(src_data)
     op = filter.iir_filter_ffd(fftaps, fbtaps)
     fftaps_data = (1)
     fbtaps = (0, 0, -1, 3)
     op.set_taps(fftaps, fbtaps)
     dst = blocks.vector_sink_f()
     self.tb.connect(src, op)
     self.tb.connect(op, dst)
     self.tb.run()
     result_data = dst.data()
     self.assertFloatTuplesAlmostEqual(expected_result, result_data)
Beispiel #25
0
 def test_iir_direct_008(self):
     src_data = (1, 2, 3, 4, 5, 6, 7, 8)
     expected_result = (2, 4, 4, 10, 18, 14, 26, 56)
     fftaps = (2,)
     fbtaps = (0, 1)
     src = blocks.vector_source_f(src_data)
     op = filter.iir_filter_ffd(fftaps, fbtaps)
     fftaps_data = 1
     fbtaps = (0, 0, -1, 3)
     op.set_taps(fftaps, fbtaps)
     dst = blocks.vector_sink_f()
     self.tb.connect(src, op)
     self.tb.connect(op, dst)
     self.tb.run()
     result_data = dst.data()
     self.assertFloatTuplesAlmostEqual(expected_result, result_data)
Beispiel #26
0
    def __init__(self, fs, tau=75e-6, fh=-1.0):
        gr.hier_block2.__init__(
            self,
            "fm_preemph",
            # Input signature
            gr.io_signature(1, 1, gr.sizeof_float),
            gr.io_signature(1, 1, gr.sizeof_float))  # Output signature

        # Set fh to something sensible, if needed.
        # N.B. fh == fs/2.0 or fh == 0.0 results in a pole on the unit circle
        # at z = -1.0 or z = 1.0 respectively.  That makes the filter unstable
        # and useless.
        if fh <= 0.0 or fh >= fs / 2.0:
            fh = 0.925 * fs / 2.0

        # Digital corner frequencies
        w_cl = 1.0 / tau
        w_ch = 2.0 * math.pi * fh

        # Prewarped analog corner frequencies
        w_cla = 2.0 * fs * math.tan(w_cl / (2.0 * fs))
        w_cha = 2.0 * fs * math.tan(w_ch / (2.0 * fs))

        # Resulting digital pole, zero, and gain term from the bilinear
        # transformation of H(s) = (s + w_cla) / (s + w_cha) to
        # H(z) = b0 (1 - z1 z^-1)/(1 - p1 z^-1)
        kl = -w_cla / (2.0 * fs)
        kh = -w_cha / (2.0 * fs)
        z1 = (1.0 + kl) / (1.0 - kl)
        p1 = (1.0 + kh) / (1.0 - kh)
        b0 = (1.0 - kl) / (1.0 - kh)

        # Since H(s = infinity) = 1.0, then H(z = -1) = 1.0 and
        # this filter  has 0 dB gain at fs/2.0.
        # That isn't what users are going to expect, so adjust with a
        # gain, g, so that H(z = 1) = 1.0 for 0 dB gain at DC.
        w_0dB = 2.0 * math.pi * 0.0
        g = abs(1.0 - p1 * cmath.rect(1.0, -w_0dB)) \
            / (b0 * abs(1.0 - z1 * cmath.rect(1.0, -w_0dB)))

        btaps = [g * b0 * 1.0, g * b0 * -z1]
        ataps = [1.0, -p1]

        preemph = filter.iir_filter_ffd(btaps, ataps, False)
        self.connect(self, preemph, self)
Beispiel #27
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 = 1e6

        ##################################################
        # Blocks
        ##################################################
        self.wxgui_scopesink2_0 = scopesink2.scope_sink_f(
        	self.GetWin(),
        	title="Scope Plot",
        	sample_rate=samp_rate,
        	v_scale=0,
        	v_offset=0,
        	t_scale=0,
        	ac_couple=False,
        	xy_mode=False,
        	num_inputs=1,
        	trig_mode=wxgui.TRIG_MODE_AUTO,
        	y_axis_label="Counts",
        )
        self.Add(self.wxgui_scopesink2_0.win)
        self.iir_filter_xxx_0 = filter.iir_filter_ffd((0.000005, ), ([1,1]), True)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_complex_to_real_0 = blocks.complex_to_real(1)
        self.analog_sig_source_x_0_0 = analog.sig_source_f(samp_rate, analog.GR_COS_WAVE, 10000, 1, 0)
        self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, 100000, 1, 0)
        self.analog_phase_modulator_fc_0 = analog.phase_modulator_fc(100000)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_phase_modulator_fc_0, 0), (self.blocks_multiply_xx_0, 1))    
        self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 0))    
        self.connect((self.analog_sig_source_x_0_0, 0), (self.iir_filter_xxx_0, 0))    
        self.connect((self.blocks_complex_to_real_0, 0), (self.wxgui_scopesink2_0, 0))    
        self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_complex_to_real_0, 0))    
        self.connect((self.iir_filter_xxx_0, 0), (self.analog_phase_modulator_fc_0, 0))    
Beispiel #28
0
 def test_iir_direct_006(self):
     src_data = (1, 2, 3, 4, 5, 6, 7, 8)
     expected_result = (2, 13, 21, 59, 58, 186, 68, 583)
     fftaps = (2, 1)
     fbtaps = (0, -1)
     src = blocks.vector_source_f(src_data)
     op = filter.iir_filter_ffd(fftaps, fbtaps)
     fftaps = (2, 11, 0)
     fbtaps = (0, -1, 3)
     # FIXME: implement set_taps as generalized callback
     # op.set_taps(fftaps, fbtaps)
     op.set_fftaps(fftaps)
     op.set_fbtaps(fbtaps)
     dst = blocks.vector_sink_f()
     self.tb.connect(src, op)
     self.tb.connect(op, dst)
     self.tb.run()
     result_data = dst.data()
     self.assertFloatTuplesAlmostEqual(expected_result, result_data)
Beispiel #29
0
def fm_deemph_hier(self, fs, tau):
    # Digital corner frequency
    w_c = 1.0 / tau

    # Prewarped analog corner frequency
    w_ca = 2.0 * fs * math.tan(w_c / (2.0 * fs))

    # Resulting digital pole, zero, and gain term from the bilinear
    # transformation of H(s) = w_ca / (s + w_ca) to
    # H(z) = b0 (1 - z1 z^-1)/(1 - p1 z^-1)
    k = -w_ca / (2.0 * fs)
    z1 = -1.0
    p1 = (1.0 + k) / (1.0 - k)
    b0 = -k / (1.0 - k)

    btaps = [b0 * 1.0, b0 * -z1]
    ataps = [1.0, -p1]

    # Since H(s = 0) = 1.0, then H(z = 1) = 1.0 and has 0 dB gain at DC

    deemph = filter.iir_filter_ffd(btaps, ataps, False)
    self.connect((self, deemph, self))
Beispiel #30
0
    def __init__( self ):
        gr.hier_block2.__init__(self, "agc",
                                gr.io_signature(1,1,gr.sizeof_float),
                                gr.io_signature(1,1,gr.sizeof_float))

        self.split = blocks.multiply_const_ff( 1 )
        self.sqr   = blocks.multiply_ff( )
        self.int0  = filter.iir_filter_ffd( [.004, 0], [0, .999] )
        self.offs  = blocks.add_const_ff( -30 )
        self.gain  = blocks.multiply_const_ff( 70 )
        self.log   = blocks.nlog10_ff( 10, 1 )
        self.agc   = blocks.divide_ff( )

        self.connect(self,       self.split)
        self.connect(self.split, (self.agc, 0))
        self.connect(self.split, (self.sqr, 0))
        self.connect(self.split, (self.sqr, 1))
        self.connect(self.sqr,    self.int0)
        self.connect(self.int0,   self.log)
        self.connect(self.log,    self.offs)
        self.connect(self.offs,   self.gain)
        self.connect(self.gain,  (self.agc, 1))
        self.connect(self.agc,    self)
    def __init__(self):
        gr.hier_block2.__init__(self, "agc",
                                gr.io_signature(1, 1, gr.sizeof_float),
                                gr.io_signature(1, 1, gr.sizeof_float))

        self.split = blocks.multiply_const_ff(1)
        self.sqr = blocks.multiply_ff()
        self.int0 = filter.iir_filter_ffd([.004, 0], [0, .999])
        self.offs = blocks.add_const_ff(-30)
        self.gain = blocks.multiply_const_ff(70)
        self.log = blocks.nlog10_ff(10, 1)
        self.agc = blocks.divide_ff()

        self.connect(self, self.split)
        self.connect(self.split, (self.agc, 0))
        self.connect(self.split, (self.sqr, 0))
        self.connect(self.split, (self.sqr, 1))
        self.connect(self.sqr, self.int0)
        self.connect(self.int0, self.log)
        self.connect(self.log, self.offs)
        self.connect(self.offs, self.gain)
        self.connect(self.gain, (self.agc, 1))
        self.connect(self.agc, self)
Beispiel #32
0
	def __init__(self, dab_params, rx_params, verbose=False, debug=False):
		"""
		Hierarchical block for OFDM demodulation

		@param dab_params DAB parameter object (dab.parameters.dab_parameters)
		@param rx_params RX parameter object (dab.parameters.receiver_parameters)
		@param debug enables debug output to files
		@param verbose whether to produce verbose messages
		"""

		self.dp = dp = dab_params
		self.rp = rp = rx_params
		self.verbose = verbose

		if self.rp.softbits:
			gr.hier_block2.__init__(self,"ofdm_demod",
						gr.io_signature (1, 1, gr.sizeof_gr_complex), # input signature
						gr.io_signature2(2, 2, gr.sizeof_float*self.dp.num_carriers*2, gr.sizeof_char)) # output signature
		else:
			gr.hier_block2.__init__(self,"ofdm_demod",
						gr.io_signature (1, 1, gr.sizeof_gr_complex), # input signature
						gr.io_signature2(2, 2, gr.sizeof_char*self.dp.num_carriers/4, gr.sizeof_char)) # output signature

		

		# workaround for a problem that prevents connecting more than one block directly (see trac ticket #161)
		#self.input = gr.kludge_copy(gr.sizeof_gr_complex)
		self.input = blocks.multiply_const_cc(1.0) # FIXME
		self.connect(self, self.input)
		
		# input filtering
		if self.rp.input_fft_filter: 
			if verbose: print "--> RX filter enabled"
			lowpass_taps = filter.firdes_low_pass(1.0,                     # gain
							  dp.sample_rate,          # sampling rate
							  rp.filt_bw,              # cutoff frequency
							  rp.filt_tb,              # width of transition band
							  filter.firdes.WIN_HAMMING)   # Hamming window
			self.fft_filter = filter.fft_filter_ccc(1, lowpass_taps)
		

		# correct sample rate offset, if enabled
		if self.rp.autocorrect_sample_rate:
			if verbose: print "--> dynamic sample rate correction enabled"
			self.rate_detect_ns = dab.detect_null(dp.ns_length, False)
			self.rate_estimator = dab.estimate_sample_rate_bf(dp.sample_rate, dp.frame_length)
			self.rate_prober = blocks.probe_signal_f()
			self.connect(self.input, self.rate_detect_ns, self.rate_estimator, self.rate_prober)
			# self.resample = gr.fractional_interpolator_cc(0, 1)
			self.resample = dab.fractional_interpolator_triggered_update_cc(0,1)
			self.connect(self.rate_detect_ns, (self.resample,1))
			self.updater = Timer(0.1,self.update_correction)
			# self.updater = threading.Thread(target=self.update_correction)
			self.run_interpolater_update_thread = True
			self.updater.setDaemon(True)
			self.updater.start()
		else:
			self.run_interpolater_update_thread = False
			if self.rp.sample_rate_correction_factor != 1:
				if verbose: print "--> static sample rate correction enabled"
				self.resample = gr.fractional_interpolator_cc(0, self.rp.sample_rate_correction_factor)

		# timing and fine frequency synchronisation
		self.sync = dab.ofdm_sync_dab2(self.dp, self.rp, debug)

		# ofdm symbol sampler
		self.sampler = dab.ofdm_sampler(dp.fft_length, dp.cp_length, dp.symbols_per_frame, rp.cp_gap)
		
		# fft for symbol vectors
		self.fft = fft.fft_vcc(dp.fft_length, True, [], True)

		# coarse frequency synchronisation
		self.cfs = dab.ofdm_coarse_frequency_correct(dp.fft_length, dp.num_carriers, dp.cp_length)

		# diff phasor
		self.phase_diff = dab.diff_phasor_vcc(dp.num_carriers)

		# remove pilot symbol
		self.remove_pilot = dab.ofdm_remove_first_symbol_vcc(dp.num_carriers)

		# magnitude equalisation
		if self.rp.equalize_magnitude:
			if verbose: print "--> magnitude equalization enabled"
			self.equalizer = dab.magnitude_equalizer_vcc(dp.num_carriers, rp.symbols_for_magnitude_equalization)

		# frequency deinterleaving
		self.deinterleave = dab.frequency_interleaver_vcc(dp.frequency_deinterleaving_sequence_array)
		
		# symbol demapping
		self.demapper = dab.qpsk_demapper_vcb(dp.num_carriers)

		#
		# connect everything
		#

		if self.rp.autocorrect_sample_rate or self.rp.sample_rate_correction_factor != 1:
			self.connect(self.input, self.resample)
			self.input2 = self.resample
		else:
			self.input2 = self.input
		if self.rp.input_fft_filter:
			self.connect(self.input2, self.fft_filter, self.sync)
		else:
			self.connect(self.input2, self.sync)

		# data stream
		self.connect((self.sync, 0), (self.sampler, 0), self.fft, (self.cfs, 0), self.phase_diff, (self.remove_pilot,0))
		if self.rp.equalize_magnitude:
			self.connect((self.remove_pilot,0), (self.equalizer,0), self.deinterleave)
		else:
			self.connect((self.remove_pilot,0), self.deinterleave)
		if self.rp.softbits:
			if verbose: print "--> using soft bits"
			self.softbit_interleaver = dab.complex_to_interleaved_float_vcf(self.dp.num_carriers)
			self.connect(self.deinterleave, self.softbit_interleaver, (self,0))
		else:
			self.connect(self.deinterleave, self.demapper, (self,0))

		# control stream
		self.connect((self.sync, 1), (self.sampler, 1), (self.cfs, 1), (self.remove_pilot,1))
		if self.rp.equalize_magnitude:
			self.connect((self.remove_pilot,1), (self.equalizer,1), (self,1))
		else:
			self.connect((self.remove_pilot,1), (self,1))
			
		# calculate an estimate of the SNR
		self.phase_var_decim   = blocks.keep_one_in_n(gr.sizeof_gr_complex*self.dp.num_carriers, self.rp.phase_var_estimate_downsample)
		self.phase_var_arg     = blocks.complex_to_arg(dp.num_carriers)
		self.phase_var_v2s     = blocks.vector_to_stream(gr.sizeof_float, dp.num_carriers)
		self.phase_var_mod     = dab.modulo_ff(pi/2)
		self.phase_var_avg_mod = filter.iir_filter_ffd([rp.phase_var_estimate_alpha], [0,1-rp.phase_var_estimate_alpha]) 
		self.phase_var_sub_avg = blocks.sub_ff()
		self.phase_var_sqr     = blocks.multiply_ff()
		self.phase_var_avg     = filter.iir_filter_ffd([rp.phase_var_estimate_alpha], [0,1-rp.phase_var_estimate_alpha]) 
		self.probe_phase_var   = blocks.probe_signal_f()
		self.connect((self.remove_pilot,0), self.phase_var_decim, self.phase_var_arg, self.phase_var_v2s, self.phase_var_mod, (self.phase_var_sub_avg,0), (self.phase_var_sqr,0))
		self.connect(self.phase_var_mod, self.phase_var_avg_mod, (self.phase_var_sub_avg,1))
		self.connect(self.phase_var_sub_avg, (self.phase_var_sqr,1))
		self.connect(self.phase_var_sqr, self.phase_var_avg, self.probe_phase_var)

		# measure processing rate
		self.measure_rate = dab.measure_processing_rate(gr.sizeof_gr_complex, 2000000) 
		self.connect(self.input, self.measure_rate)

		# debugging
		if debug:
			self.connect(self.fft, blocks.file_sink(gr.sizeof_gr_complex*dp.fft_length, "debug/ofdm_after_fft.dat"))
			self.connect((self.cfs,0), blocks.file_sink(gr.sizeof_gr_complex*dp.num_carriers, "debug/ofdm_after_cfs.dat"))
			self.connect(self.phase_diff, blocks.file_sink(gr.sizeof_gr_complex*dp.num_carriers, "debug/ofdm_diff_phasor.dat"))
			self.connect((self.remove_pilot,0), blocks.file_sink(gr.sizeof_gr_complex*dp.num_carriers, "debug/ofdm_pilot_removed.dat"))
			self.connect((self.remove_pilot,1), blocks.file_sink(gr.sizeof_char, "debug/ofdm_after_cfs_trigger.dat"))
			self.connect(self.deinterleave, blocks.file_sink(gr.sizeof_gr_complex*dp.num_carriers, "debug/ofdm_deinterleaved.dat"))
			if self.rp.equalize_magnitude:
				self.connect(self.equalizer, blocks.file_sink(gr.sizeof_gr_complex*dp.num_carriers, "debug/ofdm_equalizer.dat"))
			if self.rp.softbits:
				self.connect(self.softbit_interleaver, blocks.file_sink(gr.sizeof_float*dp.num_carriers*2, "debug/softbits.dat"))
Beispiel #33
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Top Block")

        ##################################################
        # Variables
        ##################################################
        self.slider = slider = 0
        self.samp_rate = samp_rate = 2e6

        ##################################################
        # Blocks
        ##################################################
        _slider_sizer = wx.BoxSizer(wx.VERTICAL)
        self._slider_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_slider_sizer,
            value=self.slider,
            callback=self.set_slider,
            label='slider',
            converter=forms.float_converter(),
            proportion=0,
        )
        self._slider_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_slider_sizer,
            value=self.slider,
            callback=self.set_slider,
            minimum=-100,
            maximum=100,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.Add(_slider_sizer)
        self.notebook = self.notebook = wx.Notebook(self.GetWin(),
                                                    style=wx.NB_TOP)
        self.notebook.AddPage(grc_wxgui.Panel(self.notebook), "modulated")
        self.notebook.AddPage(grc_wxgui.Panel(self.notebook), "FFT modulated")
        self.Add(self.notebook)
        self.wxgui_scopesink2_0 = scopesink2.scope_sink_f(
            self.notebook.GetPage(0).GetWin(),
            title='Scope Plot',
            sample_rate=samp_rate / 16,
            v_scale=0,
            v_offset=0,
            t_scale=0,
            ac_couple=False,
            xy_mode=False,
            num_inputs=1,
            trig_mode=wxgui.TRIG_MODE_AUTO,
            y_axis_label='Counts',
        )
        self.notebook.GetPage(0).Add(self.wxgui_scopesink2_0.win)
        self.wxgui_fftsink2_0 = fftsink2.fft_sink_f(
            self.notebook.GetPage(1).GetWin(),
            baseband_freq=0,
            y_per_div=10,
            y_divs=10,
            ref_level=0,
            ref_scale=2.0,
            sample_rate=samp_rate / 16,
            fft_size=1024,
            fft_rate=15,
            average=False,
            avg_alpha=None,
            title='FFT Plot',
            peak_hold=False,
        )
        self.notebook.GetPage(1).Add(self.wxgui_fftsink2_0.win)
        self.rtlsdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " +
                                              '')
        self.rtlsdr_source_0.set_sample_rate(samp_rate)
        self.rtlsdr_source_0.set_center_freq(1155.002e6, 0)
        self.rtlsdr_source_0.set_freq_corr(0, 0)
        self.rtlsdr_source_0.set_dc_offset_mode(0, 0)
        self.rtlsdr_source_0.set_iq_balance_mode(0, 0)
        self.rtlsdr_source_0.set_gain_mode(False, 0)
        self.rtlsdr_source_0.set_gain(60, 0)
        self.rtlsdr_source_0.set_if_gain(60, 0)
        self.rtlsdr_source_0.set_bb_gain(60, 0)
        self.rtlsdr_source_0.set_antenna('', 0)
        self.rtlsdr_source_0.set_bandwidth(0, 0)

        self.low_pass_filter_0 = filter.fir_filter_fff(
            16,
            firdes.low_pass(1, samp_rate, 20e3, 4e3, firdes.WIN_HAMMING, 6.76))
        self.iir_filter_xxx_1_0 = filter.iir_filter_ffd(([
            1,
        ]), ([1, 0.95 + 0.1 * slider]), True)
        self.dc_blocker_xx_0 = filter.dc_blocker_ff(32, True)
        self.blocks_multiply_conjugate_cc_0 = blocks.multiply_conjugate_cc(1)
        self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex * 1, 1)
        self.blocks_complex_to_arg_0 = blocks.complex_to_arg(1)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_complex_to_arg_0, 0),
                     (self.dc_blocker_xx_0, 0))
        self.connect((self.blocks_delay_0, 0),
                     (self.blocks_multiply_conjugate_cc_0, 1))
        self.connect((self.blocks_multiply_conjugate_cc_0, 0),
                     (self.blocks_complex_to_arg_0, 0))
        self.connect((self.dc_blocker_xx_0, 0), (self.iir_filter_xxx_1_0, 0))
        self.connect((self.iir_filter_xxx_1_0, 0), (self.low_pass_filter_0, 0))
        self.connect((self.low_pass_filter_0, 0), (self.wxgui_fftsink2_0, 0))
        self.connect((self.low_pass_filter_0, 0), (self.wxgui_scopesink2_0, 0))
        self.connect((self.rtlsdr_source_0, 0), (self.blocks_delay_0, 0))
        self.connect((self.rtlsdr_source_0, 0),
                     (self.blocks_multiply_conjugate_cc_0, 0))
Beispiel #34
0
    def __init__(self, dab_params, rx_params, verbose=False, debug=False):
        """
		Hierarchical block for OFDM demodulation

		@param dab_params DAB parameter object (grdab.parameters.dab_parameters)
		@param rx_params RX parameter object (grdab.parameters.receiver_parameters)
		@param debug enables debug output to files
		@param verbose whether to produce verbose messages
		"""

        self.dp = dp = dab_params
        self.rp = rp = rx_params
        self.verbose = verbose

        if self.rp.softbits:
            gr.hier_block2.__init__(
                self,
                "ofdm_demod",
                gr.io_signature(1, 1, gr.sizeof_gr_complex),  # input signature
                gr.io_signature(1, 1, gr.sizeof_float * self.dp.num_carriers *
                                2))  # output signature
        else:
            gr.hier_block2.__init__(
                self,
                "ofdm_demod",
                gr.io_signature(1, 1, gr.sizeof_gr_complex),  # input signature
                gr.io_signature(1, 1, gr.sizeof_char * self.dp.num_carriers /
                                4))  # output signature

        # workaround for a problem that prevents connecting more than one block directly (see trac ticket #161)
        #self.input = gr.kludge_copy(gr.sizeof_gr_complex)
        self.input = blocks.multiply_const_cc(1.0)  # FIXME
        self.connect(self, self.input)

        # input filtering
        if self.rp.input_fft_filter:
            if verbose: print("--> RX filter enabled")
            lowpass_taps = filter.firdes_low_pass(
                1.0,  # gain
                dp.sample_rate,  # sampling rate
                rp.filt_bw,  # cutoff frequency
                rp.filt_tb,  # width of transition band
                filter.firdes.WIN_HAMMING)  # Hamming window
            self.fft_filter = filter.fft_filter_ccc(1, lowpass_taps)

        # correct sample rate offset, if enabled
        if self.rp.autocorrect_sample_rate:
            if verbose: print("--> dynamic sample rate correction enabled")
            self.rate_detect_ns = grdab.detect_null(dp.ns_length, False)
            self.rate_estimator = grdab.estimate_sample_rate_bf(
                dp.sample_rate, dp.frame_length)
            self.rate_prober = blocks.probe_signal_f()
            self.connect(self.input, self.rate_detect_ns, self.rate_estimator,
                         self.rate_prober)
            # self.resample = gr.fractional_interpolator_cc(0, 1)
            self.resample = grdab.fractional_interpolator_triggered_update_cc(
                0, 1)
            self.connect(self.rate_detect_ns, (self.resample, 1))
            self.updater = Timer(0.1, self.update_correction)
            # self.updater = threading.Thread(target=self.update_correction)
            self.run_interpolater_update_thread = True
            self.updater.setDaemon(True)
            self.updater.start()
        else:
            self.run_interpolater_update_thread = False
            if self.rp.sample_rate_correction_factor != 1 or self.rp.always_include_resample:
                if verbose: print("--> static sample rate correction enabled")
                self.resample = filter.mmse_resampler_cc(
                    0, self.rp.sample_rate_correction_factor)

        # timing and fine frequency synchronisation
        self.sync = grdab.ofdm_sync_dab2(self.dp, self.rp, debug)

        # ofdm symbol sampler
        self.sampler = grdab.ofdm_sampler(dp.fft_length, dp.cp_length,
                                          dp.symbols_per_frame, rp.cp_gap)

        # fft for symbol vectors
        self.fft = fft.fft_vcc(dp.fft_length, True, [], True)

        # coarse frequency synchronisation
        self.cfs = grdab.ofdm_coarse_frequency_correct(dp.fft_length,
                                                       dp.num_carriers,
                                                       dp.cp_length)

        # diff phasor
        self.phase_diff = grdab.diff_phasor_vcc(dp.num_carriers)

        # remove pilot symbol
        self.remove_pilot = grdab.ofdm_remove_first_symbol_vcc(dp.num_carriers)

        # magnitude equalisation
        if self.rp.equalize_magnitude:
            if verbose: print("--> magnitude equalization enabled")
            self.equalizer = grdab.magnitude_equalizer_vcc(
                dp.num_carriers, rp.symbols_for_magnitude_equalization)

        # frequency deinterleaving
        self.deinterleave = grdab.frequency_interleaver_vcc(
            dp.frequency_deinterleaving_sequence_array)

        # symbol demapping
        self.demapper = grdab.qpsk_demapper_vcb(dp.num_carriers)

        #
        # connect everything
        #

        if self.rp.autocorrect_sample_rate or self.rp.sample_rate_correction_factor != 1 or self.rp.always_include_resample:
            self.connect(self.input, self.resample)
            self.input2 = self.resample
        else:
            self.input2 = self.input
        if self.rp.input_fft_filter:
            self.connect(self.input2, self.fft_filter, self.sync)
        else:
            self.connect(self.input2, self.sync)

        # data stream
        self.connect(self.sync, self.sampler, self.fft, self.cfs,
                     self.phase_diff, self.remove_pilot)
        if self.rp.equalize_magnitude:
            self.connect(self.remove_pilot, self.equalizer, self.deinterleave)
        else:
            self.connect(self.remove_pilot, self.deinterleave)
        if self.rp.softbits:
            if verbose: print("--> using soft bits")
            self.softbit_interleaver = grdab.complex_to_interleaved_float_vcf(
                self.dp.num_carriers)
            self.connect(self.deinterleave, self.softbit_interleaver,
                         (self, 0))
        else:
            self.connect(self.deinterleave, self.demapper, (self, 0))

        # calculate an estimate of the SNR
        self.phase_var_decim = blocks.keep_one_in_n(
            gr.sizeof_gr_complex * self.dp.num_carriers,
            self.rp.phase_var_estimate_downsample)
        self.phase_var_arg = blocks.complex_to_arg(dp.num_carriers)
        self.phase_var_v2s = blocks.vector_to_stream(gr.sizeof_float,
                                                     dp.num_carriers)
        self.phase_var_mod = grdab.modulo_ff(pi / 2)
        self.phase_var_avg_mod = filter.iir_filter_ffd(
            [rp.phase_var_estimate_alpha],
            [0, 1 - rp.phase_var_estimate_alpha])
        self.phase_var_sub_avg = blocks.sub_ff()
        self.phase_var_sqr = blocks.multiply_ff()
        self.phase_var_avg = filter.iir_filter_ffd(
            [rp.phase_var_estimate_alpha],
            [0, 1 - rp.phase_var_estimate_alpha])
        self.probe_phase_var = blocks.probe_signal_f()
        self.connect((self.remove_pilot, 0), self.phase_var_decim,
                     self.phase_var_arg, self.phase_var_v2s,
                     self.phase_var_mod, (self.phase_var_sub_avg, 0),
                     (self.phase_var_sqr, 0))
        self.connect(self.phase_var_mod, self.phase_var_avg_mod,
                     (self.phase_var_sub_avg, 1))
        self.connect(self.phase_var_sub_avg, (self.phase_var_sqr, 1))
        self.connect(self.phase_var_sqr, self.phase_var_avg,
                     self.probe_phase_var)

        # measure processing rate
        self.measure_rate = grdab.measure_processing_rate(
            gr.sizeof_gr_complex, 2000000)
        self.connect(self.input, self.measure_rate)

        # debugging
        if debug:
            self.connect(
                self.fft,
                blocks.file_sink(gr.sizeof_gr_complex * dp.fft_length,
                                 "debug/ofdm_after_fft.dat"))
            self.connect(
                (self.cfs, 0),
                blocks.file_sink(gr.sizeof_gr_complex * dp.num_carriers,
                                 "debug/ofdm_after_cfs.dat"))
            self.connect(
                self.phase_diff,
                blocks.file_sink(gr.sizeof_gr_complex * dp.num_carriers,
                                 "debug/ofdm_diff_phasor.dat"))
            self.connect(
                (self.remove_pilot, 0),
                blocks.file_sink(gr.sizeof_gr_complex * dp.num_carriers,
                                 "debug/ofdm_pilot_removed.dat"))
            self.connect((self.remove_pilot, 1),
                         blocks.file_sink(gr.sizeof_char,
                                          "debug/ofdm_after_cfs_trigger.dat"))
            self.connect(
                self.deinterleave,
                blocks.file_sink(gr.sizeof_gr_complex * dp.num_carriers,
                                 "debug/ofdm_deinterleaved.dat"))
            if self.rp.equalize_magnitude:
                self.connect(
                    self.equalizer,
                    blocks.file_sink(gr.sizeof_gr_complex * dp.num_carriers,
                                     "debug/ofdm_equalizer.dat"))
            if self.rp.softbits:
                self.connect(
                    self.softbit_interleaver,
                    blocks.file_sink(gr.sizeof_float * dp.num_carriers * 2,
                                     "debug/softbits.dat"))
Beispiel #35
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 = 960e3

        ##################################################
        # Blocks
        ##################################################
        self.wxgui_fftsink2_0 = fftsink2.fft_sink_f(
        	self.GetWin(),
        	baseband_freq=0,
        	y_per_div=10,
        	y_divs=10,
        	ref_level=0,
        	ref_scale=2.0,
        	sample_rate=samp_rate,
        	fft_size=1024,
        	fft_rate=15,
        	average=False,
        	avg_alpha=None,
        	title="FFT Plot",
        	peak_hold=False,
        )
        self.Add(self.wxgui_fftsink2_0.win)
        self.rational_resampler_xxx_1 = filter.rational_resampler_fff(
                interpolation=1,
                decimation=30,
                taps=None,
                fractional_bw=None,
        )
        self.iir_filter_xxx_2 = filter.iir_filter_ffd((10, ), (1, .95), True)
        self.iir_filter_xxx_1 = filter.iir_filter_ffd((1/(5e3), ), ([1,1]), True)
        self.iir_filter_xxx_0 = filter.iir_filter_ffd(([1,0.95]), ([1,0]), False)
        self.hilbert_fc_0 = filter.hilbert_fc(65, firdes.WIN_HAMMING, 6.76)
        self.dc_blocker_xx_0 = filter.dc_blocker_ff(8192, True)
        self.blocks_multiply_xx_0_0 = blocks.multiply_vcc(1)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_multiply_conjugate_cc_0 = blocks.multiply_conjugate_cc(1)
        self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex*1, 1)
        self.blocks_complex_to_real_0 = blocks.complex_to_real(1)
        self.blocks_complex_to_arg_0 = blocks.complex_to_arg(1)
        self.blocks_add_xx_2 = blocks.add_vff(1)
        self.blocks_add_xx_1_0 = blocks.add_vff(1)
        self.blocks_add_xx_0 = blocks.add_vcc(1)
        self.audio_sink_0 = audio.sink(32000, "", True)
        self.analog_sig_source_x_3 = analog.sig_source_f(samp_rate, analog.GR_COS_WAVE, 1000, 1, 0)
        self.analog_sig_source_x_2_0 = analog.sig_source_f(samp_rate, analog.GR_COS_WAVE, 10000, 1, 0)
        self.analog_sig_source_x_1_0 = analog.sig_source_f(samp_rate, analog.GR_COS_WAVE, 5000, 1, 0)
        self.analog_sig_source_x_0_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, 300000, 1, 0)
        self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, -300000, 1, 0)
        self.analog_phase_modulator_fc_0 = analog.phase_modulator_fc(5e-6)
        self.analog_noise_source_x_0 = analog.noise_source_c(analog.GR_GAUSSIAN, 0.01, 0)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_noise_source_x_0, 0), (self.blocks_add_xx_0, 1))    
        self.connect((self.analog_phase_modulator_fc_0, 0), (self.blocks_multiply_xx_0_0, 0))    
        self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1))    
        self.connect((self.analog_sig_source_x_0_0, 0), (self.blocks_multiply_xx_0_0, 1))    
        self.connect((self.analog_sig_source_x_1_0, 0), (self.blocks_add_xx_1_0, 1))    
        self.connect((self.analog_sig_source_x_2_0, 0), (self.blocks_add_xx_2, 1))    
        self.connect((self.analog_sig_source_x_3, 0), (self.blocks_add_xx_1_0, 0))    
        self.connect((self.blocks_add_xx_0, 0), (self.blocks_complex_to_real_0, 0))    
        self.connect((self.blocks_add_xx_1_0, 0), (self.blocks_add_xx_2, 0))    
        self.connect((self.blocks_add_xx_2, 0), (self.iir_filter_xxx_0, 0))    
        self.connect((self.blocks_complex_to_arg_0, 0), (self.iir_filter_xxx_2, 0))    
        self.connect((self.blocks_complex_to_real_0, 0), (self.hilbert_fc_0, 0))    
        self.connect((self.blocks_delay_0, 0), (self.blocks_multiply_conjugate_cc_0, 1))    
        self.connect((self.blocks_multiply_conjugate_cc_0, 0), (self.blocks_complex_to_arg_0, 0))    
        self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_delay_0, 0))    
        self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_multiply_conjugate_cc_0, 0))    
        self.connect((self.blocks_multiply_xx_0_0, 0), (self.blocks_add_xx_0, 0))    
        self.connect((self.dc_blocker_xx_0, 0), (self.audio_sink_0, 0))    
        self.connect((self.dc_blocker_xx_0, 0), (self.wxgui_fftsink2_0, 0))    
        self.connect((self.hilbert_fc_0, 0), (self.blocks_multiply_xx_0, 0))    
        self.connect((self.iir_filter_xxx_0, 0), (self.iir_filter_xxx_1, 0))    
        self.connect((self.iir_filter_xxx_1, 0), (self.analog_phase_modulator_fc_0, 0))    
        self.connect((self.iir_filter_xxx_2, 0), (self.rational_resampler_xxx_1, 0))    
        self.connect((self.rational_resampler_xxx_1, 0), (self.dc_blocker_xx_0, 0))    
Beispiel #36
0
    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.sps = sps = 4
        self.nfilts = nfilts = 32
        self.ntaps = ntaps = 11*nfilts*sps
        self.excess_bw = excess_bw = 0.4
        self.tx_taps = tx_taps = firdes.root_raised_cosine(nfilts,nfilts,1.0,excess_bw,ntaps)
        self.timing_bw = timing_bw = 2*pi/100
        self.samp_rate = samp_rate = 320000
        self.rx_taps = rx_taps = filter.firdes.root_raised_cosine(nfilts,nfilts*sps,1.0,excess_bw,ntaps)
        self.freq_bw = freq_bw = 2*pi/100
        self.fll_ntaps = fll_ntaps = 55
        self.const_points = const_points = 8

        ##################################################
        # Blocks
        ##################################################
        self.qtgui_const_sink_x_1 = qtgui.const_sink_c(
        	1024, #size
        	"", #name
        	1 #number of inputs
        )
        self.qtgui_const_sink_x_1.set_update_time(0.10)
        self.qtgui_const_sink_x_1.set_y_axis(-2, 2)
        self.qtgui_const_sink_x_1.set_x_axis(-2, 2)
        self.qtgui_const_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "")
        self.qtgui_const_sink_x_1.enable_autoscale(False)
        self.qtgui_const_sink_x_1.enable_grid(False)
        
        if not True:
          self.qtgui_const_sink_x_1.disable_legend()
        
        labels = ["", "", "", "", "",
                  "", "", "", "", ""]
        widths = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        colors = ["blue", "red", "red", "red", "red",
                  "red", "red", "red", "red", "red"]
        styles = [0, 0, 0, 0, 0,
                  0, 0, 0, 0, 0]
        markers = [0, 0, 0, 0, 0,
                   0, 0, 0, 0, 0]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_const_sink_x_1.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_const_sink_x_1.set_line_label(i, labels[i])
            self.qtgui_const_sink_x_1.set_line_width(i, widths[i])
            self.qtgui_const_sink_x_1.set_line_color(i, colors[i])
            self.qtgui_const_sink_x_1.set_line_style(i, styles[i])
            self.qtgui_const_sink_x_1.set_line_marker(i, markers[i])
            self.qtgui_const_sink_x_1.set_line_alpha(i, alphas[i])
        
        self._qtgui_const_sink_x_1_win = sip.wrapinstance(self.qtgui_const_sink_x_1.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_const_sink_x_1_win)
        self.qtgui_const_sink_x_0 = qtgui.const_sink_c(
        	1024, #size
        	"", #name
        	1 #number of inputs
        )
        self.qtgui_const_sink_x_0.set_update_time(0.10)
        self.qtgui_const_sink_x_0.set_y_axis(-2, 2)
        self.qtgui_const_sink_x_0.set_x_axis(-2, 2)
        self.qtgui_const_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "")
        self.qtgui_const_sink_x_0.enable_autoscale(False)
        self.qtgui_const_sink_x_0.enable_grid(False)
        
        if not True:
          self.qtgui_const_sink_x_0.disable_legend()
        
        labels = ["", "", "", "", "",
                  "", "", "", "", ""]
        widths = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        colors = ["blue", "red", "red", "red", "red",
                  "red", "red", "red", "red", "red"]
        styles = [0, 0, 0, 0, 0,
                  0, 0, 0, 0, 0]
        markers = [0, 0, 0, 0, 0,
                   0, 0, 0, 0, 0]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_const_sink_x_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_const_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_const_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_const_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_const_sink_x_0.set_line_style(i, styles[i])
            self.qtgui_const_sink_x_0.set_line_marker(i, markers[i])
            self.qtgui_const_sink_x_0.set_line_alpha(i, alphas[i])
        
        self._qtgui_const_sink_x_0_win = sip.wrapinstance(self.qtgui_const_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_const_sink_x_0_win)
        self.pfb_arb_resampler_xxx_0_0 = pfb.arb_resampler_ccf(
        	  sps,
                  taps=(tx_taps),
        	  flt_size=32)
        self.pfb_arb_resampler_xxx_0_0.declare_sample_delay(0)
        	
        self.iir_filter_xxx_1 = filter.iir_filter_ffd(([1.0001,-1]), ([-1,1]), True)
        self.iir_filter_xxx_0 = filter.iir_filter_ffd((0.01, ), ([-1,0.99]), True)
        self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(sps, timing_bw, (rx_taps), 32, 16, 1.5, 1)
        self.digital_chunks_to_symbols_xx_0_0 = digital.chunks_to_symbols_bc((((1.414),(1+1j),(1.414j),(-1+1j),(-1.414),(-1-1j),(-1.414j),(1-1j))), 1)
        self.blocks_vco_c_0 = blocks.vco_c(320000, -5, 1)
        self.blocks_udp_source_0 = blocks.udp_source(gr.sizeof_float*1, "127.0.0.1", 12345, 1472, True)
        self.blocks_udp_sink_0 = blocks.udp_sink(gr.sizeof_float*1, "127.0.0.1", 12345, 1472, True)
        self.blocks_throttle_0_1 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True)
        self.blocks_multiply_xx_3 = blocks.multiply_vcc(1)
        self.blocks_multiply_xx_2 = blocks.multiply_vcc(1)
        self.blocks_multiply_xx_1 = blocks.multiply_vcc(1)
        self.blocks_multiply_xx_0_0 = blocks.multiply_vcc(1)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((0.125, ))
        self.blocks_multiply_conjugate_cc_0 = blocks.multiply_conjugate_cc(1)
        self.blocks_delay_1 = blocks.delay(gr.sizeof_float*1, 10)
        self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex*1, 1)
        self.blocks_complex_to_arg_1 = blocks.complex_to_arg(1)
        self.blocks_complex_to_arg_0 = blocks.complex_to_arg(1)
        self.analog_sig_source_x_0_0 = analog.sig_source_c(samp_rate*4, analog.GR_COS_WAVE, 10000, 1, 0)
        self.analog_random_source_x_0_0 = blocks.vector_source_b(map(int, numpy.random.randint(0, const_points, 1000)), True)
        self.VCO = blocks.vco_c(80000*4, -80000*4, 1)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.VCO, 0), (self.blocks_multiply_xx_2, 1))    
        self.connect((self.analog_random_source_x_0_0, 0), (self.digital_chunks_to_symbols_xx_0_0, 0))    
        self.connect((self.analog_sig_source_x_0_0, 0), (self.blocks_multiply_xx_0_0, 1))    
        self.connect((self.blocks_complex_to_arg_0, 0), (self.blocks_multiply_const_vxx_0, 0))    
        self.connect((self.blocks_complex_to_arg_1, 0), (self.iir_filter_xxx_0, 0))    
        self.connect((self.blocks_delay_0, 0), (self.blocks_multiply_conjugate_cc_0, 1))    
        self.connect((self.blocks_delay_1, 0), (self.iir_filter_xxx_1, 0))    
        self.connect((self.blocks_multiply_conjugate_cc_0, 0), (self.blocks_complex_to_arg_0, 0))    
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.VCO, 0))    
        self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_delay_0, 0))    
        self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_multiply_conjugate_cc_0, 0))    
        self.connect((self.blocks_multiply_xx_0_0, 0), (self.digital_pfb_clock_sync_xxx_0, 0))    
        self.connect((self.blocks_multiply_xx_1, 0), (self.blocks_multiply_xx_3, 0))    
        self.connect((self.blocks_multiply_xx_1, 0), (self.blocks_multiply_xx_3, 1))    
        self.connect((self.blocks_multiply_xx_1, 0), (self.blocks_multiply_xx_3, 2))    
        self.connect((self.blocks_multiply_xx_1, 0), (self.blocks_multiply_xx_3, 3))    
        self.connect((self.blocks_multiply_xx_1, 0), (self.blocks_multiply_xx_3, 4))    
        self.connect((self.blocks_multiply_xx_1, 0), (self.blocks_multiply_xx_3, 5))    
        self.connect((self.blocks_multiply_xx_1, 0), (self.blocks_multiply_xx_3, 6))    
        self.connect((self.blocks_multiply_xx_1, 0), (self.blocks_multiply_xx_3, 7))    
        self.connect((self.blocks_multiply_xx_1, 0), (self.blocks_throttle_0, 0))    
        self.connect((self.blocks_multiply_xx_2, 0), (self.blocks_multiply_xx_1, 0))    
        self.connect((self.blocks_multiply_xx_2, 0), (self.blocks_throttle_0_1, 0))    
        self.connect((self.blocks_multiply_xx_3, 0), (self.blocks_complex_to_arg_1, 0))    
        self.connect((self.blocks_throttle_0, 0), (self.qtgui_const_sink_x_0, 0))    
        self.connect((self.blocks_throttle_0_1, 0), (self.qtgui_const_sink_x_1, 0))    
        self.connect((self.blocks_udp_source_0, 0), (self.blocks_delay_1, 0))    
        self.connect((self.blocks_vco_c_0, 0), (self.blocks_multiply_xx_1, 1))    
        self.connect((self.digital_chunks_to_symbols_xx_0_0, 0), (self.pfb_arb_resampler_xxx_0_0, 0))    
        self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.blocks_multiply_xx_0, 0))    
        self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.blocks_multiply_xx_0, 1))    
        self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.blocks_multiply_xx_0, 2))    
        self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.blocks_multiply_xx_0, 3))    
        self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.blocks_multiply_xx_0, 4))    
        self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.blocks_multiply_xx_0, 5))    
        self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.blocks_multiply_xx_0, 6))    
        self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.blocks_multiply_xx_0, 7))    
        self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.blocks_multiply_xx_2, 0))    
        self.connect((self.iir_filter_xxx_0, 0), (self.blocks_udp_sink_0, 0))    
        self.connect((self.iir_filter_xxx_1, 0), (self.blocks_vco_c_0, 0))    
        self.connect((self.pfb_arb_resampler_xxx_0_0, 0), (self.blocks_multiply_xx_0_0, 0))    
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.vol = vol = 100
        self.tau = tau = 50e-6
        self.samp_rate = samp_rate = 1000000
        self.rx_gain = rx_gain = 20
        self.freq = freq = 107.2e6
        self.decim = decim = 80
        self.b_signal = b_signal = 50e3

        ##################################################
        # Blocks
        ##################################################
        _vol_sizer = wx.BoxSizer(wx.VERTICAL)
        self._vol_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_vol_sizer,
        	value=self.vol,
        	callback=self.set_vol,
        	label="Volume L",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._vol_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_vol_sizer,
        	value=self.vol,
        	callback=self.set_vol,
        	minimum=0,
        	maximum=300,
        	num_steps=100,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_vol_sizer, 2, 0, 1, 1)
        _tau_sizer = wx.BoxSizer(wx.VERTICAL)
        self._tau_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_tau_sizer,
        	value=self.tau,
        	callback=self.set_tau,
        	label="Zeitkonstante (Tau)",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._tau_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_tau_sizer,
        	value=self.tau,
        	callback=self.set_tau,
        	minimum=0,
        	maximum=100e-6,
        	num_steps=100,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_tau_sizer, 0, 1, 1, 1)
        self._samp_rate_text_box = forms.text_box(
        	parent=self.GetWin(),
        	value=self.samp_rate,
        	callback=self.set_samp_rate,
        	label="Sampling Rate",
        	converter=forms.float_converter(),
        )
        self.GridAdd(self._samp_rate_text_box, 1, 0, 1, 1)
        _rx_gain_sizer = wx.BoxSizer(wx.VERTICAL)
        self._rx_gain_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_rx_gain_sizer,
        	value=self.rx_gain,
        	callback=self.set_rx_gain,
        	label="Receiver Gain",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._rx_gain_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_rx_gain_sizer,
        	value=self.rx_gain,
        	callback=self.set_rx_gain,
        	minimum=0,
        	maximum=50,
        	num_steps=50,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_rx_gain_sizer, 2, 2, 1, 1)
        _freq_sizer = wx.BoxSizer(wx.VERTICAL)
        self._freq_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_freq_sizer,
        	value=self.freq,
        	callback=self.set_freq,
        	label="Frequenz (UKW)",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._freq_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_freq_sizer,
        	value=self.freq,
        	callback=self.set_freq,
        	minimum=80e6,
        	maximum=230e6,
        	num_steps=1000,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_freq_sizer, 0, 0, 1, 1)
        _b_signal_sizer = wx.BoxSizer(wx.VERTICAL)
        self._b_signal_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_b_signal_sizer,
        	value=self.b_signal,
        	callback=self.set_b_signal,
        	label="Signalbandbreite",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._b_signal_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_b_signal_sizer,
        	value=self.b_signal,
        	callback=self.set_b_signal,
        	minimum=1e3,
        	maximum=400e3,
        	num_steps=399,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_b_signal_sizer, 1, 1, 1, 1)
        self.wxgui_fftsink2_0 = fftsink2.fft_sink_c(
        	self.GetWin(),
        	baseband_freq=0,
        	y_per_div=10,
        	y_divs=10,
        	ref_level=0,
        	ref_scale=2.0,
        	sample_rate=samp_rate,
        	fft_size=1024,
        	fft_rate=15,
        	average=False,
        	avg_alpha=None,
        	title="FFT Plot",
        	peak_hold=False,
        )
        self.Add(self.wxgui_fftsink2_0.win)
        self.rational_resampler_xxx_0 = filter.rational_resampler_fff(
                interpolation=500,
                decimation=480,
                taps=None,
                fractional_bw=None,
        )
        self.osmosdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + "" )
        self.osmosdr_source_0.set_sample_rate(samp_rate)
        self.osmosdr_source_0.set_center_freq(freq, 0)
        self.osmosdr_source_0.set_freq_corr(0, 0)
        self.osmosdr_source_0.set_dc_offset_mode(0, 0)
        self.osmosdr_source_0.set_iq_balance_mode(2, 0)
        self.osmosdr_source_0.set_gain_mode(True, 0)
        self.osmosdr_source_0.set_gain(rx_gain, 0)
        self.osmosdr_source_0.set_if_gain(20, 0)
        self.osmosdr_source_0.set_bb_gain(20, 0)
        self.osmosdr_source_0.set_antenna("", 0)
        self.osmosdr_source_0.set_bandwidth(0, 0)
          
        self.notebook_0 = self.notebook_0 = wx.Notebook(self.GetWin(), style=wx.NB_TOP)
        self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "Audio L (FFT)")
        self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "Audio R (FFT)")
        self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "Audio L (Scope)")
        self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "Audio R (Scope)")
        self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "MPX-Signal (FFT)")
        self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "RX FFT")
        self.GridAdd(self.notebook_0, 3, 0, 1, 3)
        self.low_pass_filter_2_1_0_0 = filter.fir_filter_fff(20, firdes.low_pass(
        	1, samp_rate, 15000, 500, firdes.WIN_HANN, 6.76))
        self.low_pass_filter_0 = filter.fir_filter_ccf(1, firdes.low_pass(
        	1, samp_rate, b_signal, 2000, firdes.WIN_HANN, 6.76))
        self.iir_filter_xxx_0 = filter.iir_filter_ffd(((1.0/(1+tau*2*samp_rate), 1.0/(1+tau*2*samp_rate))), ((1, -(1-tau*2*samp_rate)/(1+tau*2*samp_rate))), True)
        self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vff((vol/100, ))
        self.blocks_multiply_conjugate_cc_0 = blocks.multiply_conjugate_cc(1)
        self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex*1, 1)
        self.blocks_complex_to_arg_0 = blocks.complex_to_arg(1)
        self.audio_sink_0 = audio.sink(48000, "", True)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.audio_sink_0, 0))
        self.connect((self.blocks_delay_0, 0), (self.blocks_multiply_conjugate_cc_0, 1))
        self.connect((self.low_pass_filter_0, 0), (self.blocks_multiply_conjugate_cc_0, 0))
        self.connect((self.blocks_multiply_conjugate_cc_0, 0), (self.blocks_complex_to_arg_0, 0))
        self.connect((self.low_pass_filter_2_1_0_0, 0), (self.rational_resampler_xxx_0, 0))
        self.connect((self.low_pass_filter_0, 0), (self.blocks_delay_0, 0))
        self.connect((self.osmosdr_source_0, 0), (self.low_pass_filter_0, 0))
        self.connect((self.blocks_complex_to_arg_0, 0), (self.iir_filter_xxx_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0), (self.blocks_multiply_const_vxx_0_0, 0))
        self.connect((self.iir_filter_xxx_0, 0), (self.low_pass_filter_2_1_0_0, 0))
        self.connect((self.osmosdr_source_0, 0), (self.wxgui_fftsink2_0, 0))
Beispiel #38
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 = 960000

        ##################################################
        # Blocks
        ##################################################
        self.lab2_part4 = self.lab2_part4 = wx.Notebook(self.GetWin(),
                                                        style=wx.NB_TOP)
        self.lab2_part4.AddPage(grc_wxgui.Panel(self.lab2_part4), "scope")
        self.lab2_part4.AddPage(grc_wxgui.Panel(self.lab2_part4), "fft")
        self.Add(self.lab2_part4)
        self.wxgui_scopesink2_0 = scopesink2.scope_sink_f(
            self.lab2_part4.GetPage(0).GetWin(),
            title="Scope Plot",
            sample_rate=samp_rate,
            v_scale=0,
            v_offset=0,
            t_scale=0,
            ac_couple=False,
            xy_mode=False,
            num_inputs=1,
            trig_mode=wxgui.TRIG_MODE_AUTO,
            y_axis_label="Counts",
        )
        self.lab2_part4.GetPage(0).Add(self.wxgui_scopesink2_0.win)
        self.wxgui_fftsink2_0 = fftsink2.fft_sink_f(
            self.lab2_part4.GetPage(1).GetWin(),
            baseband_freq=0,
            y_per_div=10,
            y_divs=10,
            ref_level=0,
            ref_scale=2.0,
            sample_rate=samp_rate,
            fft_size=1024,
            fft_rate=15,
            average=False,
            avg_alpha=None,
            title="FFT Plot",
            peak_hold=False,
        )
        self.lab2_part4.GetPage(1).Add(self.wxgui_fftsink2_0.win)
        self.iir_filter_ffd_0 = filter.iir_filter_ffd((1 / 960e3, ), (1, 1),
                                                      True)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_float * 1,
                                                 samp_rate)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_complex_to_real_0 = blocks.complex_to_real(1)
        self.analog_sig_source_x_1 = analog.sig_source_c(
            samp_rate, analog.GR_COS_WAVE, 100000, 1, 0)
        self.analog_sig_source_x_0 = analog.sig_source_f(
            samp_rate, analog.GR_COS_WAVE, 10000, 1, 0)
        self.analog_phase_modulator_fc_0 = analog.phase_modulator_fc(471000)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_throttle_0, 0), (self.wxgui_scopesink2_0, 0))
        self.connect((self.blocks_complex_to_real_0, 0),
                     (self.blocks_throttle_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0),
                     (self.blocks_complex_to_real_0, 0))
        self.connect((self.analog_phase_modulator_fc_0, 0),
                     (self.blocks_multiply_xx_0, 0))
        self.connect((self.analog_sig_source_x_1, 0),
                     (self.blocks_multiply_xx_0, 1))
        self.connect((self.iir_filter_ffd_0, 0),
                     (self.analog_phase_modulator_fc_0, 0))
        self.connect((self.blocks_throttle_0, 0), (self.wxgui_fftsink2_0, 0))
        self.connect((self.analog_sig_source_x_0, 0),
                     (self.iir_filter_ffd_0, 0))
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Top Block")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 1e6
        self.m = m = 50
        self.kf = kf = 17
        self.fm = fm = 1.1e3

        ##################################################
        # Blocks
        ##################################################
        _kf_sizer = wx.BoxSizer(wx.VERTICAL)
        self._kf_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_kf_sizer,
        	value=self.kf,
        	callback=self.set_kf,
        	label='kf',
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._kf_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_kf_sizer,
        	value=self.kf,
        	callback=self.set_kf,
        	minimum=0,
        	maximum=25,
        	num_steps=100,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.Add(_kf_sizer)
        self.wxgui_scopesink2_0 = scopesink2.scope_sink_f(
        	self.GetWin(),
        	title="Scope Plot",
        	sample_rate=samp_rate,
        	v_scale=0,
        	v_offset=0,
        	t_scale=0,
        	ac_couple=False,
        	xy_mode=False,
        	num_inputs=1,
        	trig_mode=wxgui.TRIG_MODE_AUTO,
        	y_axis_label="Counts",
        )
        self.Add(self.wxgui_scopesink2_0.win)
        self.wxgui_fftsink2_0 = fftsink2.fft_sink_f(
        	self.GetWin(),
        	baseband_freq=0,
        	y_per_div=10,
        	y_divs=10,
        	ref_level=0,
        	ref_scale=2.0,
        	sample_rate=samp_rate,
        	fft_size=1024,
        	fft_rate=15,
        	average=False,
        	avg_alpha=None,
        	title="FFT Plot",
        	peak_hold=False,
        )
        self.Add(self.wxgui_fftsink2_0.win)
        self.message_0 = analog.sig_source_f(samp_rate, analog.GR_COS_WAVE, 11e3, 0.5, 0)
        self.message = analog.sig_source_f(samp_rate, analog.GR_COS_WAVE, 1.1e3, 0.5, 0)
        _m_sizer = wx.BoxSizer(wx.VERTICAL)
        self._m_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_m_sizer,
        	value=self.m,
        	callback=self.set_m,
        	label='m',
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._m_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_m_sizer,
        	value=self.m,
        	callback=self.set_m,
        	minimum=1,
        	maximum=80,
        	num_steps=1000,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.Add(_m_sizer)
        self.iir_filter_xxx_0 = filter.iir_filter_ffd(([1.0/samp_rate]), ([1,1]), True)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True)
        self.blocks_multiply_xx_0_0 = blocks.multiply_vcc(1)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((10e3, ))
        self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex*1, 1)
        self.blocks_conjugate_cc_0 = blocks.conjugate_cc()
        self.blocks_complex_to_arg_0 = blocks.complex_to_arg(1)
        self.blocks_add_xx_1 = blocks.add_vcc(1)
        self.blocks_add_xx_0 = blocks.add_vff(1)
        self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, 100e3, 1, 0)
        self.analog_phase_modulator_fc_0 = analog.phase_modulator_fc(kf)
        self.analog_noise_source_x_0 = analog.noise_source_c(analog.GR_GAUSSIAN, 0, 0)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_noise_source_x_0, 0), (self.blocks_add_xx_1, 1))    
        self.connect((self.analog_phase_modulator_fc_0, 0), (self.blocks_multiply_xx_0, 0))    
        self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1))    
        self.connect((self.blocks_add_xx_0, 0), (self.iir_filter_xxx_0, 0))    
        self.connect((self.blocks_add_xx_1, 0), (self.blocks_delay_0, 0))    
        self.connect((self.blocks_add_xx_1, 0), (self.blocks_multiply_xx_0_0, 0))    
        self.connect((self.blocks_complex_to_arg_0, 0), (self.wxgui_fftsink2_0, 0))    
        self.connect((self.blocks_complex_to_arg_0, 0), (self.wxgui_scopesink2_0, 0))    
        self.connect((self.blocks_conjugate_cc_0, 0), (self.blocks_multiply_xx_0_0, 1))    
        self.connect((self.blocks_delay_0, 0), (self.blocks_conjugate_cc_0, 0))    
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.analog_phase_modulator_fc_0, 0))    
        self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_throttle_0, 0))    
        self.connect((self.blocks_multiply_xx_0_0, 0), (self.blocks_complex_to_arg_0, 0))    
        self.connect((self.blocks_throttle_0, 0), (self.blocks_add_xx_1, 0))    
        self.connect((self.iir_filter_xxx_0, 0), (self.blocks_multiply_const_vxx_0, 0))    
        self.connect((self.message, 0), (self.blocks_add_xx_0, 0))    
        self.connect((self.message_0, 0), (self.blocks_add_xx_0, 1))    
Beispiel #40
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.sps = sps = 4
        self.ntaps = ntaps = 1408
        self.nfilts = nfilts = 32
        self.excess_bw = excess_bw = 0.45
        self.timing_bw = timing_bw = 2 * pi / 100
        self.sr2 = sr2 = 300000
        self.samp_rate_0 = samp_rate_0 = 32000
        self.samp_rate = samp_rate = 100000
        self.s = s = 0.01
        self.rx_taps = rx_taps = filter.firdes.root_raised_cosine(nfilts, nfilts * sps, 1.0, excess_bw, ntaps)
        self.freq_bw = freq_bw = 2 * pi / 100
        self.fll_ntaps = fll_ntaps = 55

        ##################################################
        # Blocks
        ##################################################
        self.n = self.n = wx.Notebook(self.GetWin(), style=wx.NB_TOP)
        self.n.AddPage(grc_wxgui.Panel(self.n), "tab1")
        self.n.AddPage(grc_wxgui.Panel(self.n), "tab2")
        self.n.AddPage(grc_wxgui.Panel(self.n), "tab3")
        self.Add(self.n)
        self.wxgui_scopesink2_2 = scopesink2.scope_sink_c(
            self.n.GetPage(1).GetWin(),
            title="Scope Plot",
            sample_rate=samp_rate,
            v_scale=0,
            v_offset=0,
            t_scale=0,
            ac_couple=False,
            xy_mode=False,
            num_inputs=1,
            trig_mode=wxgui.TRIG_MODE_AUTO,
            y_axis_label="Counts",
        )
        self.n.GetPage(1).Add(self.wxgui_scopesink2_2.win)
        self.wxgui_scopesink2_1 = scopesink2.scope_sink_f(
            self.n.GetPage(0).GetWin(),
            title="Scope Plot",
            sample_rate=samp_rate,
            v_scale=0,
            v_offset=0,
            t_scale=0,
            ac_couple=False,
            xy_mode=False,
            num_inputs=1,
            trig_mode=wxgui.TRIG_MODE_AUTO,
            y_axis_label="Counts",
        )
        self.n.GetPage(0).Add(self.wxgui_scopesink2_1.win)
        self.wxgui_scopesink2_0 = scopesink2.scope_sink_c(
            self.n.GetPage(2).GetWin(),
            title="Scope Plot",
            sample_rate=samp_rate,
            v_scale=0,
            v_offset=0,
            t_scale=0,
            ac_couple=False,
            xy_mode=False,
            num_inputs=1,
            trig_mode=wxgui.TRIG_MODE_AUTO,
            y_axis_label="Counts",
        )
        self.n.GetPage(2).Add(self.wxgui_scopesink2_0.win)
        _s_sizer = wx.BoxSizer(wx.VERTICAL)
        self._s_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_s_sizer,
            value=self.s,
            callback=self.set_s,
            label="s",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._s_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_s_sizer,
            value=self.s,
            callback=self.set_s,
            minimum=-5,
            maximum=5,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.Add(_s_sizer)
        self.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_ccf(
            4, taps=(firdes.root_raised_cosine(32, 32, 1.0, 0.45, 1408)), flt_size=32
        )
        self.pfb_arb_resampler_xxx_0.declare_sample_delay(0)

        self.iir_filter_xxx_0_0 = filter.iir_filter_ffd(([1.0001, -1]), ([-1, 1]), True)
        self.iir_filter_xxx_0 = filter.iir_filter_ffd((0.01,), ([-1, 0.99]), True)
        self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(4, 2 * pi / 100, (rx_taps), 32, 16, 1.5, 1)
        self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc(
            (((1 + 1j), (1 - 1j), (-1 + 1j), (-1 - 1j))), 1
        )
        self.blocks_vco_c_0 = blocks.vco_c(samp_rate, -5, 1)
        self.blocks_udp_source_0 = blocks.udp_source(gr.sizeof_float * 1, "127.0.0.1", 12345, 1472, True)
        self.blocks_udp_sink_0 = blocks.udp_sink(gr.sizeof_float * 1, "127.0.0.1", 12345, 1472, True)
        self.blocks_threshold_ff_0_0 = blocks.threshold_ff(-0.001, 0.001, 0)
        self.blocks_threshold_ff_0 = blocks.threshold_ff(-0.001, 0.001, 0)
        self.blocks_sub_xx_0 = blocks.sub_ff(1)
        self.blocks_multiply_xx_2 = blocks.multiply_vff(1)
        self.blocks_multiply_xx_1 = blocks.multiply_vff(1)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_multiply_const_vxx_2 = blocks.multiply_const_vff((1,))
        self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vff((1.413,))
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((1.413,))
        self.blocks_delay_0 = blocks.delay(gr.sizeof_float * 1, 1000)
        self.blocks_complex_to_real_0 = blocks.complex_to_real(1)
        self.blocks_complex_to_imag_0 = blocks.complex_to_imag(1)
        self.blocks_add_const_vxx_0_0 = blocks.add_const_vff((-0.5,))
        self.blocks_add_const_vxx_0 = blocks.add_const_vff((-0.5,))
        self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate, analog.GR_SIN_WAVE, 10, 1, 0)
        self.analog_random_source_x_0 = blocks.vector_source_b(map(int, numpy.random.randint(0, 4, 1000)), True)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_random_source_x_0, 0), (self.digital_chunks_to_symbols_xx_0, 0))
        self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1))
        self.connect((self.blocks_add_const_vxx_0, 0), (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.blocks_add_const_vxx_0_0, 0), (self.blocks_multiply_const_vxx_1, 0))
        self.connect((self.blocks_complex_to_imag_0, 0), (self.blocks_multiply_xx_2, 1))
        self.connect((self.blocks_complex_to_imag_0, 0), (self.blocks_threshold_ff_0_0, 0))
        self.connect((self.blocks_complex_to_real_0, 0), (self.blocks_multiply_xx_1, 1))
        self.connect((self.blocks_complex_to_real_0, 0), (self.blocks_threshold_ff_0, 0))
        self.connect((self.blocks_delay_0, 0), (self.iir_filter_xxx_0_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_multiply_xx_2, 0))
        self.connect((self.blocks_multiply_const_vxx_1, 0), (self.blocks_multiply_xx_1, 0))
        self.connect((self.blocks_multiply_const_vxx_2, 0), (self.blocks_delay_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0), (self.digital_pfb_clock_sync_xxx_0, 0))
        self.connect((self.blocks_multiply_xx_1, 0), (self.blocks_sub_xx_0, 1))
        self.connect((self.blocks_multiply_xx_2, 0), (self.blocks_sub_xx_0, 0))
        self.connect((self.blocks_sub_xx_0, 0), (self.iir_filter_xxx_0, 0))
        self.connect((self.blocks_threshold_ff_0, 0), (self.blocks_add_const_vxx_0, 0))
        self.connect((self.blocks_threshold_ff_0_0, 0), (self.blocks_add_const_vxx_0_0, 0))
        self.connect((self.blocks_udp_source_0, 0), (self.blocks_multiply_const_vxx_2, 0))
        self.connect((self.blocks_vco_c_0, 0), (self.blocks_multiply_xx_0, 2))
        self.connect((self.blocks_vco_c_0, 0), (self.wxgui_scopesink2_2, 0))
        self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.pfb_arb_resampler_xxx_0, 0))
        self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.blocks_complex_to_imag_0, 0))
        self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.blocks_complex_to_real_0, 0))
        self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.wxgui_scopesink2_0, 0))
        self.connect((self.iir_filter_xxx_0, 0), (self.blocks_udp_sink_0, 0))
        self.connect((self.iir_filter_xxx_0, 0), (self.wxgui_scopesink2_1, 0))
        self.connect((self.iir_filter_xxx_0_0, 0), (self.blocks_vco_c_0, 0))
        self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.blocks_multiply_xx_0, 0))
Beispiel #41
0
    def __init__(self):
        gr.top_block.__init__(self, "Top Block")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Top Block")
        qtgui.util.check_set_qss()
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

        self.settings = Qt.QSettings("GNU Radio", "top_block")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())


        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 10000
        self.atraso = atraso = 190
        self.K = K = 1000

        ##################################################
        # Blocks
        ##################################################
        self._atraso_range = Range(0, 200, 1, 190, 200)
        self._atraso_win = RangeWidget(self._atraso_range, self.set_atraso, "atraso", "counter_slider", float)
        self.top_grid_layout.addWidget(self._atraso_win, 3, 0, 1, 1)
        for r in range(3, 4):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 1):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._K_range = Range(0, 2000, 1, 1000, 200)
        self._K_win = RangeWidget(self._K_range, self.set_K, "K", "counter_slider", float)
        self.top_grid_layout.addWidget(self._K_win, 2, 0, 1, 1)
        for r in range(2, 3):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 1):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_time_sink_x_1_0 = qtgui.time_sink_f(
        	512, #size
        	samp_rate, #samp_rate
        	"DPCM", #name
        	3 #number of inputs
        )
        self.qtgui_time_sink_x_1_0.set_update_time(0.10)
        self.qtgui_time_sink_x_1_0.set_y_axis(-1, 1)

        self.qtgui_time_sink_x_1_0.set_y_label('Amplitude', "")

        self.qtgui_time_sink_x_1_0.enable_tags(-1, True)
        self.qtgui_time_sink_x_1_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "")
        self.qtgui_time_sink_x_1_0.enable_autoscale(False)
        self.qtgui_time_sink_x_1_0.enable_grid(False)
        self.qtgui_time_sink_x_1_0.enable_axis_labels(True)
        self.qtgui_time_sink_x_1_0.enable_control_panel(False)
        self.qtgui_time_sink_x_1_0.enable_stem_plot(False)

        if not True:
          self.qtgui_time_sink_x_1_0.disable_legend()

        labels = ['RX', 'TX', 'erro', '', '',
                  '', '', '', '', '']
        widths = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        colors = ["blue", "black", "green", "black", "cyan",
                  "magenta", "yellow", "dark red", "dark green", "blue"]
        styles = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1,
                   -1, -1, -1, -1, -1]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]

        for i in xrange(3):
            if len(labels[i]) == 0:
                self.qtgui_time_sink_x_1_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_1_0.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_1_0.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_1_0.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_1_0.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_1_0.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_1_0.set_line_alpha(i, alphas[i])

        self._qtgui_time_sink_x_1_0_win = sip.wrapinstance(self.qtgui_time_sink_x_1_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_1_0_win, 0, 1, 1, 1)
        for r in range(0, 1):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(1, 2):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_time_sink_x_1 = qtgui.time_sink_f(
        	512, #size
        	samp_rate, #samp_rate
        	"PCM", #name
        	3 #number of inputs
        )
        self.qtgui_time_sink_x_1.set_update_time(0.10)
        self.qtgui_time_sink_x_1.set_y_axis(-1, 1)

        self.qtgui_time_sink_x_1.set_y_label('Amplitude', "")

        self.qtgui_time_sink_x_1.enable_tags(-1, True)
        self.qtgui_time_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "")
        self.qtgui_time_sink_x_1.enable_autoscale(False)
        self.qtgui_time_sink_x_1.enable_grid(False)
        self.qtgui_time_sink_x_1.enable_axis_labels(True)
        self.qtgui_time_sink_x_1.enable_control_panel(False)
        self.qtgui_time_sink_x_1.enable_stem_plot(False)

        if not True:
          self.qtgui_time_sink_x_1.disable_legend()

        labels = ['RX', 'TX', 'erro', '', '',
                  '', '', '', '', '']
        widths = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        colors = ["blue", "red", "green", "black", "cyan",
                  "magenta", "yellow", "dark red", "dark green", "blue"]
        styles = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1,
                   -1, -1, -1, -1, -1]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]

        for i in xrange(3):
            if len(labels[i]) == 0:
                self.qtgui_time_sink_x_1.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_1.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_1.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_1.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_1.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_1.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_1.set_line_alpha(i, alphas[i])

        self._qtgui_time_sink_x_1_win = sip.wrapinstance(self.qtgui_time_sink_x_1.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_1_win, 0, 0, 1, 1)
        for r in range(0, 1):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 1):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_time_sink_x_0 = qtgui.time_sink_f(
        	512, #size
        	samp_rate, #samp_rate
        	"Residuos", #name
        	2 #number of inputs
        )
        self.qtgui_time_sink_x_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0.set_y_axis(-1, 1)

        self.qtgui_time_sink_x_0.set_y_label('Amplitude', "")

        self.qtgui_time_sink_x_0.enable_tags(-1, True)
        self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "")
        self.qtgui_time_sink_x_0.enable_autoscale(False)
        self.qtgui_time_sink_x_0.enable_grid(False)
        self.qtgui_time_sink_x_0.enable_axis_labels(True)
        self.qtgui_time_sink_x_0.enable_control_panel(False)
        self.qtgui_time_sink_x_0.enable_stem_plot(False)

        if not True:
          self.qtgui_time_sink_x_0.disable_legend()

        labels = ['Delta[k]', 'Delta_quant[k]', '', '', '',
                  '', '', '', '', '']
        widths = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        colors = ["blue", "red", "green", "black", "cyan",
                  "magenta", "yellow", "dark red", "dark green", "blue"]
        styles = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1,
                   -1, -1, -1, -1, -1]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]

        for i in xrange(2):
            if len(labels[i]) == 0:
                self.qtgui_time_sink_x_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_0.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_0.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i])

        self._qtgui_time_sink_x_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_win, 1, 0, 1, 1)
        for r in range(1, 2):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 1):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_number_sink_0_0 = qtgui.number_sink(
            gr.sizeof_float,
            0,
            qtgui.NUM_GRAPH_HORIZ,
            1
        )
        self.qtgui_number_sink_0_0.set_update_time(0.10)
        self.qtgui_number_sink_0_0.set_title("SNR PCM")

        labels = ['', '', '', '', '',
                  '', '', '', '', '']
        units = ['', '', '', '', '',
                 '', '', '', '', '']
        colors = [("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"),
                  ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black")]
        factor = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        for i in xrange(1):
            self.qtgui_number_sink_0_0.set_min(i, -1)
            self.qtgui_number_sink_0_0.set_max(i, 1)
            self.qtgui_number_sink_0_0.set_color(i, colors[i][0], colors[i][1])
            if len(labels[i]) == 0:
                self.qtgui_number_sink_0_0.set_label(i, "Data {0}".format(i))
            else:
                self.qtgui_number_sink_0_0.set_label(i, labels[i])
            self.qtgui_number_sink_0_0.set_unit(i, units[i])
            self.qtgui_number_sink_0_0.set_factor(i, factor[i])

        self.qtgui_number_sink_0_0.enable_autoscale(False)
        self._qtgui_number_sink_0_0_win = sip.wrapinstance(self.qtgui_number_sink_0_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_number_sink_0_0_win, 3, 1, 1, 1)
        for r in range(3, 4):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(1, 2):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_number_sink_0 = qtgui.number_sink(
            gr.sizeof_float,
            0,
            qtgui.NUM_GRAPH_HORIZ,
            1
        )
        self.qtgui_number_sink_0.set_update_time(0.10)
        self.qtgui_number_sink_0.set_title("SNR DPCM")

        labels = ['', '', '', '', '',
                  '', '', '', '', '']
        units = ['', '', '', '', '',
                 '', '', '', '', '']
        colors = [("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"),
                  ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black")]
        factor = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        for i in xrange(1):
            self.qtgui_number_sink_0.set_min(i, -1)
            self.qtgui_number_sink_0.set_max(i, 1)
            self.qtgui_number_sink_0.set_color(i, colors[i][0], colors[i][1])
            if len(labels[i]) == 0:
                self.qtgui_number_sink_0.set_label(i, "Data {0}".format(i))
            else:
                self.qtgui_number_sink_0.set_label(i, labels[i])
            self.qtgui_number_sink_0.set_unit(i, units[i])
            self.qtgui_number_sink_0.set_factor(i, factor[i])

        self.qtgui_number_sink_0.enable_autoscale(False)
        self._qtgui_number_sink_0_win = sip.wrapinstance(self.qtgui_number_sink_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_number_sink_0_win, 2, 1, 1, 1)
        for r in range(2, 3):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(1, 2):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_const_sink_x_0 = qtgui.const_sink_c(
        	1024, #size
        	"Quantizador", #name
        	1 #number of inputs
        )
        self.qtgui_const_sink_x_0.set_update_time(0.10)
        self.qtgui_const_sink_x_0.set_y_axis(-2, 2)
        self.qtgui_const_sink_x_0.set_x_axis(-2, 2)
        self.qtgui_const_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "")
        self.qtgui_const_sink_x_0.enable_autoscale(False)
        self.qtgui_const_sink_x_0.enable_grid(False)
        self.qtgui_const_sink_x_0.enable_axis_labels(True)

        if not True:
          self.qtgui_const_sink_x_0.disable_legend()

        labels = ['', '', '', '', '',
                  '', '', '', '', '']
        widths = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        colors = ["blue", "red", "red", "red", "red",
                  "red", "red", "red", "red", "red"]
        styles = [0, 0, 0, 0, 0,
                  0, 0, 0, 0, 0]
        markers = [0, 0, 0, 0, 0,
                   0, 0, 0, 0, 0]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_const_sink_x_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_const_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_const_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_const_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_const_sink_x_0.set_line_style(i, styles[i])
            self.qtgui_const_sink_x_0.set_line_marker(i, markers[i])
            self.qtgui_const_sink_x_0.set_line_alpha(i, alphas[i])

        self._qtgui_const_sink_x_0_win = sip.wrapinstance(self.qtgui_const_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_win, 1, 1, 1, 1)
        for r in range(1, 2):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(1, 2):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.iir_filter_xxx_0 = filter.iir_filter_ffd(([1.0/K]), ([1.0, -1.99, 0.990025]), False)
        self.fir_filter_xxx_0 = filter.fir_filter_fff(1, (0,2,-1))
        self.fir_filter_xxx_0.declare_sample_delay(0)
        self.channels_quantizer_0_0 = channels.quantizer(3)
        self.channels_quantizer_0 = channels.quantizer(7)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_float*1, samp_rate,True)
        self.blocks_sub_xx_2 = blocks.sub_ff(1)
        self.blocks_sub_xx_1 = blocks.sub_ff(1)
        self.blocks_sub_xx_0 = blocks.sub_ff(1)
        self.blocks_rms_xx_0_1 = blocks.rms_ff(0.0001)
        self.blocks_rms_xx_0_0_0 = blocks.rms_ff(0.0001)
        self.blocks_rms_xx_0_0 = blocks.rms_ff(0.0001)
        self.blocks_rms_xx_0 = blocks.rms_ff(0.0001)
        self.blocks_nlog10_ff_0_0 = blocks.nlog10_ff(20, 1, 0)
        self.blocks_nlog10_ff_0 = blocks.nlog10_ff(20, 1, 0)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((K, ))
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        self.blocks_divide_xx_0_0 = blocks.divide_ff(1)
        self.blocks_divide_xx_0 = blocks.divide_ff(1)
        self.blocks_delay_0 = blocks.delay(gr.sizeof_float*1, atraso)
        self.analog_sig_source_x_0 = analog.sig_source_f(samp_rate, analog.GR_COS_WAVE, 50, 1, 0)



        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_sig_source_x_0, 0), (self.blocks_throttle_0, 0))
        self.connect((self.blocks_delay_0, 0), (self.blocks_rms_xx_0, 0))
        self.connect((self.blocks_delay_0, 0), (self.blocks_sub_xx_2, 1))
        self.connect((self.blocks_delay_0, 0), (self.qtgui_time_sink_x_1_0, 1))
        self.connect((self.blocks_divide_xx_0, 0), (self.blocks_nlog10_ff_0, 0))
        self.connect((self.blocks_divide_xx_0_0, 0), (self.blocks_nlog10_ff_0_0, 0))
        self.connect((self.blocks_float_to_complex_0, 0), (self.qtgui_const_sink_x_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_float_to_complex_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.channels_quantizer_0_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.qtgui_time_sink_x_0, 0))
        self.connect((self.blocks_nlog10_ff_0, 0), (self.qtgui_number_sink_0, 0))
        self.connect((self.blocks_nlog10_ff_0_0, 0), (self.qtgui_number_sink_0_0, 0))
        self.connect((self.blocks_rms_xx_0, 0), (self.blocks_divide_xx_0, 0))
        self.connect((self.blocks_rms_xx_0_0, 0), (self.blocks_divide_xx_0, 1))
        self.connect((self.blocks_rms_xx_0_0_0, 0), (self.blocks_divide_xx_0_0, 1))
        self.connect((self.blocks_rms_xx_0_1, 0), (self.blocks_divide_xx_0_0, 0))
        self.connect((self.blocks_sub_xx_0, 0), (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.blocks_sub_xx_1, 0), (self.blocks_rms_xx_0_0_0, 0))
        self.connect((self.blocks_sub_xx_1, 0), (self.qtgui_time_sink_x_1, 2))
        self.connect((self.blocks_sub_xx_2, 0), (self.blocks_rms_xx_0_0, 0))
        self.connect((self.blocks_sub_xx_2, 0), (self.qtgui_time_sink_x_1_0, 2))
        self.connect((self.blocks_throttle_0, 0), (self.blocks_delay_0, 0))
        self.connect((self.blocks_throttle_0, 0), (self.blocks_rms_xx_0_1, 0))
        self.connect((self.blocks_throttle_0, 0), (self.blocks_sub_xx_0, 0))
        self.connect((self.blocks_throttle_0, 0), (self.blocks_sub_xx_1, 0))
        self.connect((self.blocks_throttle_0, 0), (self.channels_quantizer_0, 0))
        self.connect((self.blocks_throttle_0, 0), (self.fir_filter_xxx_0, 0))
        self.connect((self.blocks_throttle_0, 0), (self.qtgui_time_sink_x_1, 1))
        self.connect((self.channels_quantizer_0, 0), (self.blocks_sub_xx_1, 1))
        self.connect((self.channels_quantizer_0, 0), (self.qtgui_time_sink_x_1, 0))
        self.connect((self.channels_quantizer_0_0, 0), (self.blocks_float_to_complex_0, 1))
        self.connect((self.channels_quantizer_0_0, 0), (self.iir_filter_xxx_0, 0))
        self.connect((self.channels_quantizer_0_0, 0), (self.qtgui_time_sink_x_0, 1))
        self.connect((self.fir_filter_xxx_0, 0), (self.blocks_sub_xx_0, 1))
        self.connect((self.iir_filter_xxx_0, 0), (self.blocks_sub_xx_2, 0))
        self.connect((self.iir_filter_xxx_0, 0), (self.qtgui_time_sink_x_1_0, 0))
Beispiel #42
0
    def __init__(self):
        gr.top_block.__init__(self, "Lab 3 Task 1B")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Lab 3 Task 1B")
        qtgui.util.check_set_qss()
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

        self.settings = Qt.QSettings("GNU Radio", "lab3_task1b")

        try:
            if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"):
                self.restoreGeometry(
                    self.settings.value("geometry").toByteArray())
            else:
                self.restoreGeometry(self.settings.value("geometry"))
        except:
            pass

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 3528000
        self.samp_msg = samp_msg = 44100

        ##################################################
        # Blocks
        ##################################################
        self.tab = Qt.QTabWidget()
        self.tab_widget_0 = Qt.QWidget()
        self.tab_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom,
                                          self.tab_widget_0)
        self.tab_grid_layout_0 = Qt.QGridLayout()
        self.tab_layout_0.addLayout(self.tab_grid_layout_0)
        self.tab.addTab(self.tab_widget_0, 'Modulated')
        self.tab_widget_1 = Qt.QWidget()
        self.tab_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom,
                                          self.tab_widget_1)
        self.tab_grid_layout_1 = Qt.QGridLayout()
        self.tab_layout_1.addLayout(self.tab_grid_layout_1)
        self.tab.addTab(self.tab_widget_1, 'Demodulated')
        self.tab_widget_2 = Qt.QWidget()
        self.tab_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom,
                                          self.tab_widget_2)
        self.tab_grid_layout_2 = Qt.QGridLayout()
        self.tab_layout_2.addLayout(self.tab_grid_layout_2)
        self.tab.addTab(self.tab_widget_2, 'Demodulated (only Real)')
        self.tab_widget_3 = Qt.QWidget()
        self.tab_layout_3 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom,
                                          self.tab_widget_3)
        self.tab_grid_layout_3 = Qt.QGridLayout()
        self.tab_layout_3.addLayout(self.tab_grid_layout_3)
        self.tab.addTab(self.tab_widget_3, 'Demodulated (only Imag)')
        self.top_grid_layout.addWidget(self.tab)
        self.rational_resampler_xxx_0_0_0_0 = filter.rational_resampler_fff(
            interpolation=samp_msg,
            decimation=samp_rate,
            taps=None,
            fractional_bw=None)
        self.rational_resampler_xxx_0_0_0 = filter.rational_resampler_fff(
            interpolation=samp_msg,
            decimation=samp_rate,
            taps=None,
            fractional_bw=None)
        self.rational_resampler_xxx_0_0 = filter.rational_resampler_fff(
            interpolation=samp_msg,
            decimation=samp_rate,
            taps=None,
            fractional_bw=None)
        self.qtgui_sink_x_1 = qtgui.sink_c(
            1024,  #fftsize
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate,  #bw
            'Modulated',  #name
            True,  #plotfreq
            True,  #plotwaterfall
            True,  #plottime
            True  #plotconst
        )
        self.qtgui_sink_x_1.set_update_time(1.0 / 10)
        self._qtgui_sink_x_1_win = sip.wrapinstance(
            self.qtgui_sink_x_1.pyqwidget(), Qt.QWidget)

        self.qtgui_sink_x_1.enable_rf_freq(False)

        self.tab_layout_0.addWidget(self._qtgui_sink_x_1_win)
        self.qtgui_sink_x_0_0_0 = qtgui.sink_f(
            1024,  #fftsize
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_msg,  #bw
            'Demodulated (only Imag)',  #name
            True,  #plotfreq
            True,  #plotwaterfall
            True,  #plottime
            True  #plotconst
        )
        self.qtgui_sink_x_0_0_0.set_update_time(1.0 / 10)
        self._qtgui_sink_x_0_0_0_win = sip.wrapinstance(
            self.qtgui_sink_x_0_0_0.pyqwidget(), Qt.QWidget)

        self.qtgui_sink_x_0_0_0.enable_rf_freq(False)

        self.tab_layout_3.addWidget(self._qtgui_sink_x_0_0_0_win)
        self.qtgui_sink_x_0_0 = qtgui.sink_f(
            1024,  #fftsize
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_msg,  #bw
            'Demodulated (only Real)',  #name
            True,  #plotfreq
            True,  #plotwaterfall
            True,  #plottime
            True  #plotconst
        )
        self.qtgui_sink_x_0_0.set_update_time(1.0 / 10)
        self._qtgui_sink_x_0_0_win = sip.wrapinstance(
            self.qtgui_sink_x_0_0.pyqwidget(), Qt.QWidget)

        self.qtgui_sink_x_0_0.enable_rf_freq(False)

        self.tab_layout_2.addWidget(self._qtgui_sink_x_0_0_win)
        self.qtgui_sink_x_0 = qtgui.sink_f(
            1024,  #fftsize
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_msg,  #bw
            'Demodulated',  #name
            True,  #plotfreq
            True,  #plotwaterfall
            True,  #plottime
            True  #plotconst
        )
        self.qtgui_sink_x_0.set_update_time(1.0 / 10)
        self._qtgui_sink_x_0_win = sip.wrapinstance(
            self.qtgui_sink_x_0.pyqwidget(), Qt.QWidget)

        self.qtgui_sink_x_0.enable_rf_freq(False)

        self.tab_layout_1.addWidget(self._qtgui_sink_x_0_win)
        self.low_pass_filter_1_0 = filter.fir_filter_fff(
            1,
            firdes.low_pass(1, samp_rate, 15000, 1000, firdes.WIN_HAMMING,
                            6.76))
        self.low_pass_filter_1 = filter.fir_filter_fff(
            1,
            firdes.low_pass(1, samp_rate, 15000, 1000, firdes.WIN_HAMMING,
                            6.76))
        self.low_pass_filter_0 = filter.fir_filter_fff(
            1,
            firdes.low_pass(1, samp_rate, 15000, 1000, firdes.WIN_KAISER,
                            6.76))
        self.iir_filter_xxx_2_0_0 = filter.iir_filter_ffd([1], [1, -0.95],
                                                          False)
        self.iir_filter_xxx_2_0 = filter.iir_filter_ffd([1], [1, -0.95], False)
        self.iir_filter_xxx_2 = filter.iir_filter_ffd([1], [1, -0.95], False)
        self.iir_filter_xxx_0_0 = filter.iir_filter_ffd([1, -1], [1], False)
        self.iir_filter_xxx_0 = filter.iir_filter_ffd([1, -1], [1], True)
        self.dc_blocker_xx_0_0_0 = filter.dc_blocker_ff(10000, True)
        self.dc_blocker_xx_0_0 = filter.dc_blocker_ff(32000, True)
        self.dc_blocker_xx_0 = filter.dc_blocker_ff(10000, True)
        self.blocks_wavfile_sink_0_0_0 = blocks.wavfile_sink(
            '/home/ipsit/Documents/EE 340/Lab 3/task1bi.wav', 1, samp_msg, 8)
        self.blocks_wavfile_sink_0_0 = blocks.wavfile_sink(
            '/home/ipsit/Documents/EE 340/Lab 3/task1br.wav', 1, samp_msg, 8)
        self.blocks_wavfile_sink_0 = blocks.wavfile_sink(
            '/home/ipsit/Documents/EE 340/Lab 3/task1b.wav', 1, samp_msg, 8)
        self.blocks_throttle_1_0_0_0 = blocks.throttle(gr.sizeof_float * 1,
                                                       samp_msg, True)
        self.blocks_throttle_1_0_0 = blocks.throttle(gr.sizeof_float * 1,
                                                     samp_msg, True)
        self.blocks_throttle_1_0 = blocks.throttle(gr.sizeof_float * 1,
                                                   samp_msg, True)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1,
                                                 samp_rate, True)
        self.blocks_multiply_xx_1 = blocks.multiply_vcc(1)
        self.blocks_multiply_const_vxx_0_1_0 = blocks.multiply_const_ff(10)
        self.blocks_multiply_const_vxx_0_1 = blocks.multiply_const_ff(10)
        self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_ff(1 / 6.28)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_ff(100)
        self.blocks_file_source_0 = blocks.file_source(
            gr.sizeof_gr_complex * 1,
            '/home/ipsit/Documents/EE 340/Lab 3/task2b.dat', True, 0, 0)
        self.blocks_file_source_0.set_begin_tag(pmt.PMT_NIL)
        self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex * 1, 1)
        self.blocks_conjugate_cc_0 = blocks.conjugate_cc()
        self.blocks_complex_to_real_0 = blocks.complex_to_real(1)
        self.blocks_complex_to_imag_0 = blocks.complex_to_imag(1)
        self.blocks_complex_to_arg_0 = blocks.complex_to_arg(1)
        self.blocks_abs_xx_0_0 = blocks.abs_ff(1)
        self.blocks_abs_xx_0 = blocks.abs_ff(1)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_abs_xx_0, 0), (self.low_pass_filter_1, 0))
        self.connect((self.blocks_abs_xx_0_0, 0),
                     (self.low_pass_filter_1_0, 0))
        self.connect((self.blocks_complex_to_arg_0, 0),
                     (self.blocks_multiply_const_vxx_0_0, 0))
        self.connect((self.blocks_complex_to_imag_0, 0),
                     (self.iir_filter_xxx_0_0, 0))
        self.connect((self.blocks_complex_to_real_0, 0),
                     (self.iir_filter_xxx_0, 0))
        self.connect((self.blocks_conjugate_cc_0, 0),
                     (self.blocks_multiply_xx_1, 1))
        self.connect((self.blocks_delay_0, 0), (self.blocks_conjugate_cc_0, 0))
        self.connect((self.blocks_file_source_0, 0),
                     (self.blocks_complex_to_imag_0, 0))
        self.connect((self.blocks_file_source_0, 0),
                     (self.blocks_complex_to_real_0, 0))
        self.connect((self.blocks_file_source_0, 0), (self.blocks_delay_0, 0))
        self.connect((self.blocks_file_source_0, 0),
                     (self.blocks_multiply_xx_1, 0))
        self.connect((self.blocks_file_source_0, 0),
                     (self.blocks_throttle_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.blocks_throttle_1_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0_0, 0),
                     (self.low_pass_filter_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0_1, 0),
                     (self.blocks_throttle_1_0_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0_1_0, 0),
                     (self.blocks_throttle_1_0_0_0, 0))
        self.connect((self.blocks_multiply_xx_1, 0),
                     (self.blocks_complex_to_arg_0, 0))
        self.connect((self.blocks_throttle_0, 0), (self.qtgui_sink_x_1, 0))
        self.connect((self.blocks_throttle_1_0, 0),
                     (self.blocks_wavfile_sink_0, 0))
        self.connect((self.blocks_throttle_1_0, 0), (self.qtgui_sink_x_0, 0))
        self.connect((self.blocks_throttle_1_0_0, 0),
                     (self.blocks_wavfile_sink_0_0, 0))
        self.connect((self.blocks_throttle_1_0_0, 0),
                     (self.qtgui_sink_x_0_0, 0))
        self.connect((self.blocks_throttle_1_0_0_0, 0),
                     (self.blocks_wavfile_sink_0_0_0, 0))
        self.connect((self.blocks_throttle_1_0_0_0, 0),
                     (self.qtgui_sink_x_0_0_0, 0))
        self.connect((self.dc_blocker_xx_0, 0),
                     (self.rational_resampler_xxx_0_0, 0))
        self.connect((self.dc_blocker_xx_0_0, 0),
                     (self.rational_resampler_xxx_0_0_0, 0))
        self.connect((self.dc_blocker_xx_0_0_0, 0),
                     (self.rational_resampler_xxx_0_0_0_0, 0))
        self.connect((self.iir_filter_xxx_0, 0), (self.blocks_abs_xx_0, 0))
        self.connect((self.iir_filter_xxx_0_0, 0), (self.blocks_abs_xx_0_0, 0))
        self.connect((self.iir_filter_xxx_2, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.iir_filter_xxx_2_0, 0),
                     (self.blocks_multiply_const_vxx_0_1, 0))
        self.connect((self.iir_filter_xxx_2_0_0, 0),
                     (self.blocks_multiply_const_vxx_0_1_0, 0))
        self.connect((self.low_pass_filter_0, 0), (self.dc_blocker_xx_0, 0))
        self.connect((self.low_pass_filter_1, 0), (self.dc_blocker_xx_0_0, 0))
        self.connect((self.low_pass_filter_1_0, 0),
                     (self.dc_blocker_xx_0_0_0, 0))
        self.connect((self.rational_resampler_xxx_0_0, 0),
                     (self.iir_filter_xxx_2, 0))
        self.connect((self.rational_resampler_xxx_0_0_0, 0),
                     (self.iir_filter_xxx_2_0, 0))
        self.connect((self.rational_resampler_xxx_0_0_0_0, 0),
                     (self.iir_filter_xxx_2_0_0, 0))
Beispiel #43
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.quad_rate = quad_rate = 640000
        self.audio_rate = audio_rate = 40000

        ##################################################
        # Blocks
        ##################################################
        self.n = self.n = wx.Notebook(self.GetWin(), style=wx.NB_TOP)
        self.n.AddPage(grc_wxgui.Panel(self.n), "FM")
        self.n.AddPage(grc_wxgui.Panel(self.n), "FFT")
        self.Add(self.n)
        self.wxgui_scopesink2_0 = scopesink2.scope_sink_f(
        	self.n.GetPage(0).GetWin(),
        	title="Scope Plot",
        	sample_rate=audio_rate,
        	v_scale=0,
        	v_offset=0,
        	t_scale=0,
        	ac_couple=False,
        	xy_mode=False,
        	num_inputs=1,
        	trig_mode=wxgui.TRIG_MODE_AUTO,
        	y_axis_label="Counts",
        )
        self.n.GetPage(0).Add(self.wxgui_scopesink2_0.win)
        self.wxgui_fftsink2_0 = fftsink2.fft_sink_f(
        	self.n.GetPage(1).GetWin(),
        	baseband_freq=0,
        	y_per_div=10,
        	y_divs=10,
        	ref_level=0,
        	ref_scale=2.0,
        	sample_rate=audio_rate,
        	fft_size=1024,
        	fft_rate=15,
        	average=False,
        	avg_alpha=None,
        	title="FFT Plot",
        	peak_hold=False,
        )
        self.n.GetPage(1).Add(self.wxgui_fftsink2_0.win)
        self.rational_resampler_xxx_0 = filter.rational_resampler_fff(
                interpolation=16,
                decimation=1,
                taps=None,
                fractional_bw=None,
        )
        self.low_pass_filter_0 = filter.fir_filter_fff(16, firdes.low_pass(
        	1, quad_rate, 15000, 4000, firdes.WIN_HAMMING, 6.76))
        self.iir_filter_xxx_2 = filter.iir_filter_ffd(([1,0]), ([1,0.95]), True)
        self.iir_filter_xxx_1 = filter.iir_filter_ffd(([1,-0.95]), ([1,0]), True)
        self.iir_filter_xxx_0 = filter.iir_filter_ffd((25e-6, ), ([1,1]), True)
        self.dc_blocker_xx_0 = filter.dc_blocker_ff(32, True)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_float*1, audio_rate,True)
        self.blocks_multiply_xx_1 = blocks.multiply_vcc(1)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex*1, 1)
        self.blocks_conjugate_cc_0 = blocks.conjugate_cc()
        self.blocks_complex_to_real_0 = blocks.complex_to_real(1)
        self.blocks_add_xx_1 = blocks.add_vcc(1)
        self.blocks_add_xx_0 = blocks.add_vff(1)
        self.analog_sig_source_x_2 = analog.sig_source_c(quad_rate, analog.GR_COS_WAVE, 100000, 1, 0)
        self.analog_sig_source_x_1 = analog.sig_source_f(audio_rate, analog.GR_COS_WAVE, 1100, 0.5, 0)
        self.analog_sig_source_x_0 = analog.sig_source_f(audio_rate, analog.GR_COS_WAVE, 11000, .5, 0)
        self.analog_phase_modulator_fc_0 = analog.phase_modulator_fc(2*3.14*75000)
        self.analog_noise_source_x_0 = analog.noise_source_c(analog.GR_GAUSSIAN, .2, 0)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_noise_source_x_0, 0), (self.blocks_add_xx_1, 1))    
        self.connect((self.analog_phase_modulator_fc_0, 0), (self.blocks_multiply_xx_0, 0))    
        self.connect((self.analog_sig_source_x_0, 0), (self.blocks_add_xx_0, 1))    
        self.connect((self.analog_sig_source_x_1, 0), (self.blocks_add_xx_0, 0))    
        self.connect((self.analog_sig_source_x_2, 0), (self.blocks_multiply_xx_0, 1))    
        self.connect((self.blocks_add_xx_0, 0), (self.iir_filter_xxx_1, 0))    
        self.connect((self.blocks_add_xx_1, 0), (self.blocks_delay_0, 0))    
        self.connect((self.blocks_add_xx_1, 0), (self.blocks_multiply_xx_1, 0))    
        self.connect((self.blocks_complex_to_real_0, 0), (self.low_pass_filter_0, 0))    
        self.connect((self.blocks_conjugate_cc_0, 0), (self.blocks_multiply_xx_1, 1))    
        self.connect((self.blocks_delay_0, 0), (self.blocks_conjugate_cc_0, 0))    
        self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_add_xx_1, 0))    
        self.connect((self.blocks_multiply_xx_1, 0), (self.blocks_complex_to_real_0, 0))    
        self.connect((self.blocks_throttle_0, 0), (self.wxgui_fftsink2_0, 0))    
        self.connect((self.blocks_throttle_0, 0), (self.wxgui_scopesink2_0, 0))    
        self.connect((self.dc_blocker_xx_0, 0), (self.iir_filter_xxx_2, 0))    
        self.connect((self.iir_filter_xxx_0, 0), (self.rational_resampler_xxx_0, 0))    
        self.connect((self.iir_filter_xxx_1, 0), (self.iir_filter_xxx_0, 0))    
        self.connect((self.iir_filter_xxx_2, 0), (self.blocks_throttle_0, 0))    
        self.connect((self.low_pass_filter_0, 0), (self.dc_blocker_xx_0, 0))    
        self.connect((self.rational_resampler_xxx_0, 0), (self.analog_phase_modulator_fc_0, 0))    
Beispiel #44
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.sps = sps = 4
        self.nfilts = nfilts = 32
        self.ntaps = ntaps = 11 * nfilts * sps
        self.excess_bw = excess_bw = 400e-3
        self.tx_taps = tx_taps = firdes.root_raised_cosine(
            nfilts, nfilts, 1.0, excess_bw, ntaps)
        self.timing_bw = timing_bw = 2 * pi / 100
        self.sqrt_2 = sqrt_2 = 1.4142135623730951
        self.samp_rate = samp_rate = 320000
        self.rx_taps = rx_taps = filter.firdes.root_raised_cosine(
            nfilts, nfilts * sps, 1.0, excess_bw, ntaps)
        self.const_points = const_points = 4

        ##################################################
        # Blocks
        ##################################################
        self.notebook_0 = self.notebook_0 = wx.Notebook(self.GetWin(),
                                                        style=wx.NB_TOP)
        self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "tab1")
        self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "tab2")
        self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "tab3")
        self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "tab4")
        self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "tab5")
        self.Add(self.notebook_0)
        self.wxgui_scopesink2_1 = scopesink2.scope_sink_f(
            self.notebook_0.GetPage(2).GetWin(),
            title="Scope Plot",
            sample_rate=samp_rate,
            v_scale=0,
            v_offset=0,
            t_scale=0,
            ac_couple=False,
            xy_mode=False,
            num_inputs=1,
            trig_mode=wxgui.TRIG_MODE_AUTO,
            y_axis_label="Counts",
        )
        self.notebook_0.GetPage(2).Add(self.wxgui_scopesink2_1.win)
        self.wxgui_scopesink2_0 = scopesink2.scope_sink_c(
            self.notebook_0.GetPage(0).GetWin(),
            title="Scope Plot",
            sample_rate=samp_rate * sps,
            v_scale=0,
            v_offset=0,
            t_scale=0,
            ac_couple=False,
            xy_mode=False,
            num_inputs=1,
            trig_mode=wxgui.TRIG_MODE_AUTO,
            y_axis_label="Counts",
        )
        self.notebook_0.GetPage(0).Add(self.wxgui_scopesink2_0.win)
        self.wxgui_fftsink2_0 = fftsink2.fft_sink_c(
            self.notebook_0.GetPage(1).GetWin(),
            baseband_freq=0,
            y_per_div=10,
            y_divs=10,
            ref_level=0,
            ref_scale=2.0,
            sample_rate=samp_rate * sps,
            fft_size=1024,
            fft_rate=15,
            average=False,
            avg_alpha=None,
            title="FFT Plot",
            peak_hold=False,
        )
        self.notebook_0.GetPage(1).Add(self.wxgui_fftsink2_0.win)
        self.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_ccf(sps,
                                                             taps=(tx_taps),
                                                             flt_size=32)

        self.notebook_0_0 = self.notebook_0_0 = wx.Notebook(self.GetWin(),
                                                            style=wx.NB_TOP)
        self.notebook_0_0.AddPage(grc_wxgui.Panel(self.notebook_0_0), "tab1")
        self.notebook_0_0.AddPage(grc_wxgui.Panel(self.notebook_0_0), "tab2")
        self.notebook_0_0.AddPage(grc_wxgui.Panel(self.notebook_0_0), "tab3")
        self.notebook_0_0.AddPage(grc_wxgui.Panel(self.notebook_0_0), "tab4")
        self.Add(self.notebook_0_0)
        self.iir_filter_ffd_1 = filter.iir_filter_ffd(([1.0001, -1]),
                                                      ([-1, 1]), True)
        self.iir_filter_ffd_0 = filter.iir_filter_ffd((0.01, ), ([-1, 0.99]),
                                                      True)
        self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(
            sps, timing_bw, (rx_taps), nfilts, 16, 1.5, 1)
        self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc(
            (((1 - 1j), (1 + 1j), (-1 + 1j), (-1 - 1j))), 1)
        self.blocks_vco_c_0 = blocks.vco_c(samp_rate, -5, 1)
        self.blocks_udp_source_0 = blocks.udp_source(gr.sizeof_float * 1,
                                                     "127.0.0.1", 12345, 1472,
                                                     True)
        self.blocks_udp_sink_0 = blocks.udp_sink(gr.sizeof_float * 1,
                                                 "127.0.0.1", 12345, 1472,
                                                 True)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1,
                                                 samp_rate * sps)
        self.blocks_threshold_ff_0_0 = blocks.threshold_ff(-100e-5, 100e-5, 0)
        self.blocks_threshold_ff_0 = blocks.threshold_ff(-100e-5, 100e-5, 0)
        self.blocks_sub_xx_0 = blocks.sub_ff(1)
        self.blocks_multiply_xx_2 = blocks.multiply_vcc(1)
        self.blocks_multiply_xx_1_0 = blocks.multiply_vff(1)
        self.blocks_multiply_xx_1 = blocks.multiply_vff(1)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((20, ))
        self.blocks_delay_0 = blocks.delay(gr.sizeof_float * 1, 10)
        self.blocks_complex_to_float_0 = blocks.complex_to_float(1)
        self.blocks_add_const_vxx_0_0 = blocks.add_const_vff((-.5, ))
        self.blocks_add_const_vxx_0 = blocks.add_const_vff((-.5, ))
        self.analog_sig_source_x_0 = analog.sig_source_c(
            samp_rate * sps, analog.GR_COS_WAVE, 0.1, 1, 0)
        self.analog_random_source_x_0 = blocks.vector_source_b(
            map(int, numpy.random.randint(0, const_points, 1000)), True)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_delay_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.blocks_udp_source_0, 0), (self.blocks_delay_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0),
                     (self.digital_pfb_clock_sync_xxx_0, 0))
        self.connect((self.analog_sig_source_x_0, 0),
                     (self.blocks_multiply_xx_0, 1))
        self.connect((self.pfb_arb_resampler_xxx_0, 0),
                     (self.blocks_multiply_xx_0, 0))
        self.connect((self.blocks_throttle_0, 0), (self.wxgui_fftsink2_0, 0))
        self.connect((self.digital_chunks_to_symbols_xx_0, 0),
                     (self.pfb_arb_resampler_xxx_0, 0))
        self.connect((self.blocks_throttle_0, 0), (self.wxgui_scopesink2_0, 0))
        self.connect((self.analog_random_source_x_0, 0),
                     (self.digital_chunks_to_symbols_xx_0, 0))
        self.connect((self.blocks_complex_to_float_0, 1),
                     (self.blocks_threshold_ff_0_0, 0))
        self.connect((self.blocks_complex_to_float_0, 0),
                     (self.blocks_threshold_ff_0, 0))
        self.connect((self.blocks_threshold_ff_0, 0),
                     (self.blocks_add_const_vxx_0, 0))
        self.connect((self.blocks_threshold_ff_0_0, 0),
                     (self.blocks_add_const_vxx_0_0, 0))
        self.connect((self.blocks_add_const_vxx_0, 0),
                     (self.blocks_multiply_xx_1, 0))
        self.connect((self.blocks_complex_to_float_0, 1),
                     (self.blocks_multiply_xx_1, 1))
        self.connect((self.blocks_add_const_vxx_0_0, 0),
                     (self.blocks_multiply_xx_1_0, 1))
        self.connect((self.blocks_complex_to_float_0, 0),
                     (self.blocks_multiply_xx_1_0, 0))
        self.connect((self.blocks_multiply_xx_1_0, 0),
                     (self.blocks_sub_xx_0, 1))
        self.connect((self.blocks_multiply_xx_1, 0), (self.blocks_sub_xx_0, 0))
        self.connect((self.blocks_sub_xx_0, 0), (self.iir_filter_ffd_0, 0))
        self.connect((self.iir_filter_ffd_0, 0), (self.wxgui_scopesink2_1, 0))
        self.connect((self.iir_filter_ffd_0, 0), (self.blocks_udp_sink_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.iir_filter_ffd_1, 0))
        self.connect((self.iir_filter_ffd_1, 0), (self.blocks_vco_c_0, 0))
        self.connect((self.blocks_vco_c_0, 0), (self.blocks_multiply_xx_2, 1))
        self.connect((self.digital_pfb_clock_sync_xxx_0, 0),
                     (self.blocks_multiply_xx_2, 0))
        self.connect((self.blocks_multiply_xx_2, 0),
                     (self.blocks_complex_to_float_0, 0))
        self.connect((self.blocks_multiply_xx_2, 0),
                     (self.blocks_throttle_0, 0))
Beispiel #45
0
    def __init__(self, *args, **kwds):
        # begin wxGlade: MyFrame.__init__
        kwds["style"] = wx.DEFAULT_FRAME_STYLE
        wx.Frame.__init__(self, *args, **kwds)

        # Menu Bar
        self.frame_1_menubar = wx.MenuBar()
        self.SetMenuBar(self.frame_1_menubar)
        wxglade_tmp_menu = wx.Menu()
        self.Exit = wx.MenuItem(wxglade_tmp_menu, ID_EXIT, "Exit", "Exit", wx.ITEM_NORMAL)
        wxglade_tmp_menu.AppendItem(self.Exit)
        self.frame_1_menubar.Append(wxglade_tmp_menu, "File")
        # Menu Bar end
        self.panel_1 = wx.Panel(self, -1)
        self.button_1 = wx.Button(self, ID_BUTTON_1, "LSB")
        self.button_2 = wx.Button(self, ID_BUTTON_2, "USB")
        self.button_3 = wx.Button(self, ID_BUTTON_3, "AM")
        self.button_4 = wx.Button(self, ID_BUTTON_4, "CW")
        self.button_5 = wx.ToggleButton(self, ID_BUTTON_5, "Upper")
        self.slider_fcutoff_hi = wx.Slider(self, ID_SLIDER_1, 0, -15798, 15799, style=wx.SL_HORIZONTAL | wx.SL_LABELS)
        self.button_6 = wx.ToggleButton(self, ID_BUTTON_6, "Lower")
        self.slider_fcutoff_lo = wx.Slider(self, ID_SLIDER_2, 0, -15799, 15798, style=wx.SL_HORIZONTAL | wx.SL_LABELS)
        self.panel_5 = wx.Panel(self, -1)
        self.label_1 = wx.StaticText(self, -1, " Band\nCenter")
        self.text_ctrl_1 = wx.TextCtrl(self, ID_TEXT_1, "")
        self.panel_6 = wx.Panel(self, -1)
        self.panel_7 = wx.Panel(self, -1)
        self.panel_2 = wx.Panel(self, -1)
        self.button_7 = wx.ToggleButton(self, ID_BUTTON_7, "Freq")
        self.slider_3 = wx.Slider(self, ID_SLIDER_3, 3000, 0, 6000)
        self.spin_ctrl_1 = wx.SpinCtrl(self, ID_SPIN_1, "", min=0, max=100)
        self.button_8 = wx.ToggleButton(self, ID_BUTTON_8, "Vol")
        self.slider_4 = wx.Slider(self, ID_SLIDER_4, 0, 0, 500)
        self.slider_5 = wx.Slider(self, ID_SLIDER_5, 0, 0, 20)
        self.button_9 = wx.ToggleButton(self, ID_BUTTON_9, "Time")
        self.button_11 = wx.Button(self, ID_BUTTON_11, "Rew")
        self.button_10 = wx.Button(self, ID_BUTTON_10, "Fwd")
        self.panel_3 = wx.Panel(self, -1)
        self.label_2 = wx.StaticText(self, -1, "PGA               ")
        self.panel_4 = wx.Panel(self, -1)
        self.panel_8 = wx.Panel(self, -1)
        self.panel_9 = wx.Panel(self, -1)
        self.label_3 = wx.StaticText(self, -1, "AM Sync\nCarrier")
        self.slider_6 = wx.Slider(self, ID_SLIDER_6, 50, 0, 200, style=wx.SL_HORIZONTAL | wx.SL_LABELS)
        self.label_4 = wx.StaticText(self, -1, "Antenna Tune")
        self.slider_7 = wx.Slider(self, ID_SLIDER_7, 1575, 950, 2200, style=wx.SL_HORIZONTAL | wx.SL_LABELS)
        self.panel_10 = wx.Panel(self, -1)
        self.button_12 = wx.ToggleButton(self, ID_BUTTON_12, "Auto Tune")
        self.button_13 = wx.Button(self, ID_BUTTON_13, "Calibrate")
        self.button_14 = wx.Button(self, ID_BUTTON_14, "Reset")
        self.panel_11 = wx.Panel(self, -1)
        self.panel_12 = wx.Panel(self, -1)

        self.__set_properties()
        self.__do_layout()
        # end wxGlade

        parser = OptionParser(option_class=eng_option)
        parser.add_option(
            "",
            "--address",
            type="string",
            default="addr=192.168.10.2",
            help="Address of UHD device, [default=%default]",
        )
        parser.add_option(
            "-c", "--ddc-freq", type="eng_float", default=3.9e6, help="set Rx DDC frequency to FREQ", metavar="FREQ"
        )
        parser.add_option(
            "-s", "--samp-rate", type="eng_float", default=256e3, help="set sample rate (bandwidth) [default=%default]"
        )
        parser.add_option("-a", "--audio_file", default="", help="audio output file", metavar="FILE")
        parser.add_option("-r", "--radio_file", default="", help="radio output file", metavar="FILE")
        parser.add_option("-i", "--input_file", default="", help="radio input file", metavar="FILE")
        parser.add_option(
            "-O",
            "--audio-output",
            type="string",
            default="",
            help="audio output device name. E.g., hw:0,0, /dev/dsp, or pulse",
        )

        (options, args) = parser.parse_args()

        self.usrp_center = options.ddc_freq
        input_rate = options.samp_rate
        self.slider_range = input_rate * 0.9375
        self.f_lo = self.usrp_center - (self.slider_range / 2)
        self.f_hi = self.usrp_center + (self.slider_range / 2)
        self.af_sample_rate = 32000
        fir_decim = long(input_rate / self.af_sample_rate)

        # data point arrays for antenna tuner
        self.xdata = []
        self.ydata = []

        self.tb = gr.top_block()

        # radio variables, initial conditions
        self.frequency = self.usrp_center
        # these map the frequency slider (0-6000) to the actual range
        self.f_slider_offset = self.f_lo
        self.f_slider_scale = 10000
        self.spin_ctrl_1.SetRange(self.f_lo, self.f_hi)
        self.text_ctrl_1.SetValue(str(int(self.usrp_center)))
        self.slider_5.SetValue(0)
        self.AM_mode = False

        self.slider_3.SetValue((self.frequency - self.f_slider_offset) / self.f_slider_scale)
        self.spin_ctrl_1.SetValue(int(self.frequency))

        POWERMATE = True
        try:
            self.pm = powermate.powermate(self)
        except:
            sys.stderr.write("Unable to find PowerMate or Contour Shuttle\n")
            POWERMATE = False

        if POWERMATE:
            powermate.EVT_POWERMATE_ROTATE(self, self.on_rotate)
            powermate.EVT_POWERMATE_BUTTON(self, self.on_pmButton)
        self.active_button = 7

        # command line options
        if options.audio_file == "":
            SAVE_AUDIO_TO_FILE = False
        else:
            SAVE_AUDIO_TO_FILE = True
        if options.radio_file == "":
            SAVE_RADIO_TO_FILE = False
        else:
            SAVE_RADIO_TO_FILE = True
        if options.input_file == "":
            self.PLAY_FROM_USRP = True
        else:
            self.PLAY_FROM_USRP = False

        if self.PLAY_FROM_USRP:
            self.src = uhd.usrp_source(device_addr=options.address, io_type=uhd.io_type.COMPLEX_FLOAT32, num_channels=1)
            self.src.set_samp_rate(input_rate)
            input_rate = self.src.get_samp_rate()

            self.src.set_center_freq(self.usrp_center, 0)
            self.tune_offset = 0

        else:
            self.src = blocks.file_source(gr.sizeof_short, options.input_file)
            self.tune_offset = 2200  # 2200 works for 3.5-4Mhz band

            # convert rf data in interleaved short int form to complex
            s2ss = blocks.stream_to_streams(gr.sizeof_short, 2)
            s2f1 = blocks.short_to_float()
            s2f2 = blocks.short_to_float()
            src_f2c = blocks.float_to_complex()
            self.tb.connect(self.src, s2ss)
            self.tb.connect((s2ss, 0), s2f1)
            self.tb.connect((s2ss, 1), s2f2)
            self.tb.connect(s2f1, (src_f2c, 0))
            self.tb.connect(s2f2, (src_f2c, 1))

        # save radio data to a file
        if SAVE_RADIO_TO_FILE:
            radio_file = blocks.file_sink(gr.sizeof_short, options.radio_file)
            self.tb.connect(self.src, radio_file)

        # 2nd DDC
        xlate_taps = filter.firdes.low_pass(1.0, input_rate, 16e3, 4e3, filter.firdes.WIN_HAMMING)
        self.xlate = filter.freq_xlating_fir_filter_ccf(fir_decim, xlate_taps, self.tune_offset, input_rate)

        # Complex Audio filter
        audio_coeffs = filter.firdes.complex_band_pass(
            1.0,  # gain
            self.af_sample_rate,  # sample rate
            -3000,  # low cutoff
            0,  # high cutoff
            100,  # transition
            filter.firdes.WIN_HAMMING,
        )  # window
        self.slider_fcutoff_hi.SetValue(0)
        self.slider_fcutoff_lo.SetValue(-3000)

        self.audio_filter = filter.fir_filter_ccc(1, audio_coeffs)

        # Main +/- 16Khz spectrum display
        self.fft = fftsink2.fft_sink_c(
            self.panel_2, fft_size=512, sample_rate=self.af_sample_rate, average=True, size=(640, 240)
        )

        # AM Sync carrier
        if AM_SYNC_DISPLAY:
            self.fft2 = fftsink.fft_sink_c(
                self.tb,
                self.panel_9,
                y_per_div=20,
                fft_size=512,
                sample_rate=self.af_sample_rate,
                average=True,
                size=(640, 240),
            )

        c2f = blocks.complex_to_float()

        # AM branch
        self.sel_am = blocks.multiply_const_cc(0)
        # the following frequencies turn out to be in radians/sample
        # analog.pll_refout_cc(alpha,beta,min_freq,max_freq)
        # suggested alpha = X, beta = .25 * X * X
        pll = analog.pll_refout_cc(
            0.5, 0.0625, (2.0 * math.pi * 7.5e3 / self.af_sample_rate), (2.0 * math.pi * 6.5e3 / self.af_sample_rate)
        )
        self.pll_carrier_scale = blocks.multiply_const_cc(complex(10, 0))
        am_det = blocks.multiply_cc()
        # these are for converting +7.5kHz to -7.5kHz
        # for some reason blocks.conjugate_cc() adds noise ??
        c2f2 = blocks.complex_to_float()
        c2f3 = blocks.complex_to_float()
        f2c = blocks.float_to_complex()
        phaser1 = blocks.multiply_const_ff(1)
        phaser2 = blocks.multiply_const_ff(-1)

        # filter for pll generated carrier
        pll_carrier_coeffs = filter.firdes.complex_band_pass(
            2.0,  # gain
            self.af_sample_rate,  # sample rate
            7400,  # low cutoff
            7600,  # high cutoff
            100,  # transition
            filter.firdes.WIN_HAMMING,
        )  # window

        self.pll_carrier_filter = filter.fir_filter_ccc(1, pll_carrier_coeffs)

        self.sel_sb = blocks.multiply_const_ff(1)
        combine = blocks.add_ff()

        # AGC
        sqr1 = blocks.multiply_ff()
        intr = filter.iir_filter_ffd([0.004, 0], [0, 0.999])
        offset = blocks.add_const_ff(1)
        agc = blocks.divide_ff()

        self.scale = blocks.multiply_const_ff(0.00001)
        dst = audio.sink(long(self.af_sample_rate), options.audio_output)

        if self.PLAY_FROM_USRP:
            self.tb.connect(self.src, self.xlate, self.fft)
        else:
            self.tb.connect(src_f2c, self.xlate, self.fft)

        self.tb.connect(self.xlate, self.audio_filter, self.sel_am, (am_det, 0))
        self.tb.connect(self.sel_am, pll, self.pll_carrier_scale, self.pll_carrier_filter, c2f3)
        self.tb.connect((c2f3, 0), phaser1, (f2c, 0))
        self.tb.connect((c2f3, 1), phaser2, (f2c, 1))
        self.tb.connect(f2c, (am_det, 1))
        self.tb.connect(am_det, c2f2, (combine, 0))
        self.tb.connect(self.audio_filter, c2f, self.sel_sb, (combine, 1))

        if AM_SYNC_DISPLAY:
            self.tb.connect(self.pll_carrier_filter, self.fft2)

        self.tb.connect(combine, self.scale)
        self.tb.connect(self.scale, (sqr1, 0))
        self.tb.connect(self.scale, (sqr1, 1))
        self.tb.connect(sqr1, intr, offset, (agc, 1))
        self.tb.connect(self.scale, (agc, 0))
        self.tb.connect(agc, dst)

        if SAVE_AUDIO_TO_FILE:
            f_out = blocks.file_sink(gr.sizeof_short, options.audio_file)
            sc1 = blocks.multiply_const_ff(64000)
            f2s1 = blocks.float_to_short()
            self.tb.connect(agc, sc1, f2s1, f_out)

        self.tb.start()

        # for mouse position reporting on fft display
        self.fft.win.Bind(wx.EVT_LEFT_UP, self.Mouse)
        # and left click to re-tune
        self.fft.win.Bind(wx.EVT_LEFT_DOWN, self.Click)

        # start a timer to check for web commands
        if WEB_CONTROL:
            self.timer = UpdateTimer(self, 1000)  # every 1000 mSec, 1 Sec

        wx.EVT_BUTTON(self, ID_BUTTON_1, self.set_lsb)
        wx.EVT_BUTTON(self, ID_BUTTON_2, self.set_usb)
        wx.EVT_BUTTON(self, ID_BUTTON_3, self.set_am)
        wx.EVT_BUTTON(self, ID_BUTTON_4, self.set_cw)
        wx.EVT_BUTTON(self, ID_BUTTON_10, self.fwd)
        wx.EVT_BUTTON(self, ID_BUTTON_11, self.rew)
        wx.EVT_BUTTON(self, ID_BUTTON_13, self.AT_calibrate)
        wx.EVT_BUTTON(self, ID_BUTTON_14, self.AT_reset)
        wx.EVT_TOGGLEBUTTON(self, ID_BUTTON_5, self.on_button)
        wx.EVT_TOGGLEBUTTON(self, ID_BUTTON_6, self.on_button)
        wx.EVT_TOGGLEBUTTON(self, ID_BUTTON_7, self.on_button)
        wx.EVT_TOGGLEBUTTON(self, ID_BUTTON_8, self.on_button)
        wx.EVT_TOGGLEBUTTON(self, ID_BUTTON_9, self.on_button)
        wx.EVT_SLIDER(self, ID_SLIDER_1, self.set_filter)
        wx.EVT_SLIDER(self, ID_SLIDER_2, self.set_filter)
        wx.EVT_SLIDER(self, ID_SLIDER_3, self.slide_tune)
        wx.EVT_SLIDER(self, ID_SLIDER_4, self.set_volume)
        wx.EVT_SLIDER(self, ID_SLIDER_5, self.set_pga)
        wx.EVT_SLIDER(self, ID_SLIDER_6, self.am_carrier)
        wx.EVT_SLIDER(self, ID_SLIDER_7, self.antenna_tune)
        wx.EVT_SPINCTRL(self, ID_SPIN_1, self.spin_tune)

        wx.EVT_MENU(self, ID_EXIT, self.TimeToQuit)
    def __init__(self):
        gr.top_block.__init__(self, "Lab 3 Task 0")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Lab 3 Task 0")
        qtgui.util.check_set_qss()
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

        self.settings = Qt.QSettings("GNU Radio", "lab3_task0")

        try:
            if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"):
                self.restoreGeometry(
                    self.settings.value("geometry").toByteArray())
            else:
                self.restoreGeometry(self.settings.value("geometry"))
        except:
            pass

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 5000000
        self.samp_msg = samp_msg = 44100

        ##################################################
        # Blocks
        ##################################################
        self.tab = Qt.QTabWidget()
        self.tab_widget_0 = Qt.QWidget()
        self.tab_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom,
                                          self.tab_widget_0)
        self.tab_grid_layout_0 = Qt.QGridLayout()
        self.tab_layout_0.addLayout(self.tab_grid_layout_0)
        self.tab.addTab(self.tab_widget_0, 'Message')
        self.tab_widget_1 = Qt.QWidget()
        self.tab_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom,
                                          self.tab_widget_1)
        self.tab_grid_layout_1 = Qt.QGridLayout()
        self.tab_layout_1.addLayout(self.tab_grid_layout_1)
        self.tab.addTab(self.tab_widget_1, 'Modulated')
        self.tab_widget_2 = Qt.QWidget()
        self.tab_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom,
                                          self.tab_widget_2)
        self.tab_grid_layout_2 = Qt.QGridLayout()
        self.tab_layout_2.addLayout(self.tab_grid_layout_2)
        self.tab.addTab(self.tab_widget_2, 'Demodulated')
        self.top_grid_layout.addWidget(self.tab)
        self.rational_resampler_xxx_0_0 = filter.rational_resampler_fff(
            interpolation=samp_msg,
            decimation=samp_rate,
            taps=None,
            fractional_bw=None)
        self.rational_resampler_xxx_0 = filter.rational_resampler_fff(
            interpolation=samp_rate,
            decimation=samp_msg,
            taps=None,
            fractional_bw=None)
        self.qtgui_sink_x_1 = qtgui.sink_c(
            1024,  #fftsize
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate,  #bw
            'Modulated',  #name
            True,  #plotfreq
            True,  #plotwaterfall
            True,  #plottime
            True  #plotconst
        )
        self.qtgui_sink_x_1.set_update_time(1.0 / 10)
        self._qtgui_sink_x_1_win = sip.wrapinstance(
            self.qtgui_sink_x_1.pyqwidget(), Qt.QWidget)

        self.qtgui_sink_x_1.enable_rf_freq(False)

        self.tab_layout_1.addWidget(self._qtgui_sink_x_1_win)
        self.qtgui_sink_x_0_1 = qtgui.sink_f(
            1024,  #fftsize
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_msg,  #bw
            'Message',  #name
            True,  #plotfreq
            True,  #plotwaterfall
            True,  #plottime
            True  #plotconst
        )
        self.qtgui_sink_x_0_1.set_update_time(1.0 / 10)
        self._qtgui_sink_x_0_1_win = sip.wrapinstance(
            self.qtgui_sink_x_0_1.pyqwidget(), Qt.QWidget)

        self.qtgui_sink_x_0_1.enable_rf_freq(False)

        self.tab_layout_0.addWidget(self._qtgui_sink_x_0_1_win)
        self.qtgui_sink_x_0 = qtgui.sink_f(
            1024,  #fftsize
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_msg,  #bw
            'Demodulated',  #name
            True,  #plotfreq
            True,  #plotwaterfall
            True,  #plottime
            True  #plotconst
        )
        self.qtgui_sink_x_0.set_update_time(1.0 / 10)
        self._qtgui_sink_x_0_win = sip.wrapinstance(
            self.qtgui_sink_x_0.pyqwidget(), Qt.QWidget)

        self.qtgui_sink_x_0.enable_rf_freq(False)

        self.tab_layout_2.addWidget(self._qtgui_sink_x_0_win)
        self.low_pass_filter_0 = filter.fir_filter_fff(
            1,
            firdes.low_pass(1, samp_rate, 12000, 1000, firdes.WIN_KAISER,
                            6.76))
        self.iir_filter_xxx_0 = filter.iir_filter_ffd([0, 1 / samp_msg],
                                                      [1, 1], True)
        self.dc_blocker_xx_0 = filter.dc_blocker_ff(20000, True)
        self.blocks_throttle_1_0 = blocks.throttle(gr.sizeof_float * 1,
                                                   samp_msg, True)
        self.blocks_throttle_1 = blocks.throttle(gr.sizeof_float * 1, samp_msg,
                                                 True)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1,
                                                 samp_rate, True)
        self.blocks_multiply_xx_1 = blocks.multiply_vcc(1)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_ff(1 / 6.28)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_ff(100)
        self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex * 1, 1)
        self.blocks_conjugate_cc_0 = blocks.conjugate_cc()
        self.blocks_complex_to_arg_0 = blocks.complex_to_arg(1)
        self.blocks_add_xx_1 = blocks.add_vff(1)
        self.blocks_add_xx_0 = blocks.add_vcc(1)
        self.analog_sig_source_x_1_0 = analog.sig_source_c(
            samp_rate, analog.GR_COS_WAVE, 100000, 2, 0, 0)
        self.analog_sig_source_x_1 = analog.sig_source_f(
            samp_msg, analog.GR_COS_WAVE, 11000, 0.5, 0, 0)
        self.analog_sig_source_x_0 = analog.sig_source_f(
            samp_msg, analog.GR_COS_WAVE, 1100, 0.5, 0, 0)
        self.analog_phase_modulator_fc_0 = analog.phase_modulator_fc(2 * 3.14 *
                                                                     75 * 1000)
        self.analog_noise_source_x_0 = analog.noise_source_c(
            analog.GR_GAUSSIAN, 0.2, 0)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_noise_source_x_0, 0),
                     (self.blocks_add_xx_0, 1))
        self.connect((self.analog_phase_modulator_fc_0, 0),
                     (self.blocks_multiply_xx_0, 0))
        self.connect((self.analog_sig_source_x_0, 0),
                     (self.blocks_add_xx_1, 0))
        self.connect((self.analog_sig_source_x_1, 0),
                     (self.blocks_add_xx_1, 1))
        self.connect((self.analog_sig_source_x_1_0, 0),
                     (self.blocks_multiply_xx_0, 1))
        self.connect((self.blocks_add_xx_0, 0), (self.blocks_delay_0, 0))
        self.connect((self.blocks_add_xx_0, 0), (self.blocks_multiply_xx_1, 0))
        self.connect((self.blocks_add_xx_1, 0), (self.blocks_throttle_1, 0))
        self.connect((self.blocks_add_xx_1, 0), (self.iir_filter_xxx_0, 0))
        self.connect((self.blocks_complex_to_arg_0, 0),
                     (self.blocks_multiply_const_vxx_0_0, 0))
        self.connect((self.blocks_conjugate_cc_0, 0),
                     (self.blocks_multiply_xx_1, 1))
        self.connect((self.blocks_delay_0, 0), (self.blocks_conjugate_cc_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.blocks_throttle_1_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0_0, 0),
                     (self.low_pass_filter_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_add_xx_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0),
                     (self.blocks_throttle_0, 0))
        self.connect((self.blocks_multiply_xx_1, 0),
                     (self.blocks_complex_to_arg_0, 0))
        self.connect((self.blocks_throttle_0, 0), (self.qtgui_sink_x_1, 0))
        self.connect((self.blocks_throttle_1, 0), (self.qtgui_sink_x_0_1, 0))
        self.connect((self.blocks_throttle_1_0, 0), (self.qtgui_sink_x_0, 0))
        self.connect((self.dc_blocker_xx_0, 0),
                     (self.rational_resampler_xxx_0_0, 0))
        self.connect((self.iir_filter_xxx_0, 0),
                     (self.rational_resampler_xxx_0, 0))
        self.connect((self.low_pass_filter_0, 0), (self.dc_blocker_xx_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.analog_phase_modulator_fc_0, 0))
        self.connect((self.rational_resampler_xxx_0_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Top Block")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Variables
        ##################################################
        self.sps = sps = 4
        self.nfilts = nfilts = 32
        self.ntaps = ntaps = 11 * nfilts * sps
        self.excess_bw = excess_bw = 0.4
        self.tx_taps = tx_taps = firdes.root_raised_cosine(
            nfilts, nfilts, 1.1, 0.4, ntaps)
        self.timing_bw = timing_bw = 2 * 3.14 / 100
        self.samp_rate = samp_rate = 64000
        self.rx_taps = rx_taps = filter.firdes.root_raised_cosine(
            nfilts, nfilts * sps, 1.0, excess_bw, ntaps)
        self.gain = gain = 0.001
        self.freq_bw = freq_bw = 2 * 3.14 / 100
        self.fll_ntaps = fll_ntaps = 55
        self.const_points = const_points = 8
        self.b4 = b4 = 0.0625
        self.b3 = b3 = -0.125
        self.b2 = b2 = 0.25
        self.b1 = b1 = -0.5

        ##################################################
        # Blocks
        ##################################################
        _gain_sizer = wx.BoxSizer(wx.VERTICAL)
        self._gain_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_gain_sizer,
            value=self.gain,
            callback=self.set_gain,
            label='gain',
            converter=forms.float_converter(),
            proportion=0,
        )
        self._gain_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_gain_sizer,
            value=self.gain,
            callback=self.set_gain,
            minimum=0,
            maximum=0.01,
            num_steps=1000,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.Add(_gain_sizer)
        _b4_sizer = wx.BoxSizer(wx.VERTICAL)
        self._b4_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_b4_sizer,
            value=self.b4,
            callback=self.set_b4,
            label='b4',
            converter=forms.float_converter(),
            proportion=0,
        )
        self._b4_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_b4_sizer,
            value=self.b4,
            callback=self.set_b4,
            minimum=-1,
            maximum=1,
            num_steps=1000,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.Add(_b4_sizer)
        _b3_sizer = wx.BoxSizer(wx.VERTICAL)
        self._b3_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_b3_sizer,
            value=self.b3,
            callback=self.set_b3,
            label='b3',
            converter=forms.float_converter(),
            proportion=0,
        )
        self._b3_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_b3_sizer,
            value=self.b3,
            callback=self.set_b3,
            minimum=-1,
            maximum=1,
            num_steps=1000,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.Add(_b3_sizer)
        _b2_sizer = wx.BoxSizer(wx.VERTICAL)
        self._b2_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_b2_sizer,
            value=self.b2,
            callback=self.set_b2,
            label='b2',
            converter=forms.float_converter(),
            proportion=0,
        )
        self._b2_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_b2_sizer,
            value=self.b2,
            callback=self.set_b2,
            minimum=-1,
            maximum=1,
            num_steps=1000,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.Add(_b2_sizer)
        _b1_sizer = wx.BoxSizer(wx.VERTICAL)
        self._b1_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_b1_sizer,
            value=self.b1,
            callback=self.set_b1,
            label='b1',
            converter=forms.float_converter(),
            proportion=0,
        )
        self._b1_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_b1_sizer,
            value=self.b1,
            callback=self.set_b1,
            minimum=-1,
            maximum=1,
            num_steps=1000,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.Add(_b1_sizer)
        self.wxgui_scopesink2_1_0 = scopesink2.scope_sink_c(
            self.GetWin(),
            title="Scope Plot",
            sample_rate=samp_rate / 4,
            v_scale=0,
            v_offset=0,
            t_scale=0,
            ac_couple=False,
            xy_mode=False,
            num_inputs=1,
            trig_mode=wxgui.TRIG_MODE_AUTO,
            y_axis_label="Counts",
        )
        self.Add(self.wxgui_scopesink2_1_0.win)
        self.wxgui_scopesink2_1 = scopesink2.scope_sink_c(
            self.GetWin(),
            title="Scope Plot",
            sample_rate=samp_rate / 4,
            v_scale=0,
            v_offset=0,
            t_scale=0,
            ac_couple=False,
            xy_mode=False,
            num_inputs=1,
            trig_mode=wxgui.TRIG_MODE_AUTO,
            y_axis_label="Counts",
        )
        self.Add(self.wxgui_scopesink2_1.win)
        self.wxgui_scopesink2_0 = scopesink2.scope_sink_f(
            self.GetWin(),
            title="Scope Plot",
            sample_rate=samp_rate,
            v_scale=0,
            v_offset=0,
            t_scale=0,
            ac_couple=False,
            xy_mode=False,
            num_inputs=1,
            trig_mode=wxgui.TRIG_MODE_AUTO,
            y_axis_label="Counts",
        )
        self.Add(self.wxgui_scopesink2_0.win)
        self.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_ccf(sps,
                                                             taps=(tx_taps),
                                                             flt_size=32)
        self.pfb_arb_resampler_xxx_0.declare_sample_delay(0)

        self.iir_filter_xxx_0 = filter.iir_filter_ffd(([0.001]), ([1, 0.98]),
                                                      True)
        self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(
            sps, timing_bw, (rx_taps), nfilts, 16, 1.5, 1)
        self.digital_costas_loop_cc_0 = digital.costas_loop_cc(
            freq_bw, const_points, False)
        self.digital_cma_equalizer_cc_0 = digital.cma_equalizer_cc(
            100, 1, gain, 1)
        self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc(
            ((1 + 0j), (0.707 + 0.707j), (0 + 1j), (-0.707 + 0.707j),
             (-1 + 0j), (-0.707 - 0.707j), (0 - 1j), (0.707 - 0.707j)), 1)
        self.blocks_multiply_const_vxx_1_2 = blocks.multiply_const_vcc((b4, ))
        self.blocks_multiply_const_vxx_1_1 = blocks.multiply_const_vcc((b2, ))
        self.blocks_multiply_const_vxx_1_0 = blocks.multiply_const_vcc((b3, ))
        self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vcc((b1, ))
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((0.5, ))
        self.blocks_delay_0_3 = blocks.delay(gr.sizeof_gr_complex * 1, 1)
        self.blocks_delay_0_2 = blocks.delay(gr.sizeof_gr_complex * 1, 1)
        self.blocks_delay_0_1 = blocks.delay(gr.sizeof_gr_complex * 1, 1)
        self.blocks_delay_0_0 = blocks.delay(gr.sizeof_gr_complex * 1, 1)
        self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex * 1, sps)
        self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1)
        self.blocks_add_xx_1 = blocks.add_vcc(1)
        self.blocks_add_xx_0_0_2 = blocks.add_vcc(1)
        self.blocks_add_xx_0_0_1 = blocks.add_vcc(1)
        self.blocks_add_xx_0_0_0 = blocks.add_vcc(1)
        self.blocks_add_xx_0_0 = blocks.add_vcc(1)
        self.blocks_add_xx_0 = blocks.add_vcc(1)
        self.blocks_add_const_vxx_0 = blocks.add_const_vff((-1, ))
        self.blocks_abs_xx_0 = blocks.abs_ff(1)
        self.analog_random_source_x_0 = blocks.vector_source_b(
            map(int, numpy.random.randint(0, const_points, 1000)), True)
        self.analog_noise_source_x_0 = analog.noise_source_c(
            analog.GR_GAUSSIAN, 0.01, 0)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_noise_source_x_0, 0),
                     (self.blocks_add_xx_1, 1))
        self.connect((self.analog_random_source_x_0, 0),
                     (self.digital_chunks_to_symbols_xx_0, 0))
        self.connect((self.blocks_abs_xx_0, 0), (self.iir_filter_xxx_0, 0))
        self.connect((self.blocks_add_const_vxx_0, 0),
                     (self.blocks_abs_xx_0, 0))
        self.connect((self.blocks_add_xx_0, 0),
                     (self.digital_pfb_clock_sync_xxx_0, 0))
        self.connect((self.blocks_add_xx_0_0, 0),
                     (self.blocks_add_xx_0_0_0, 1))
        self.connect((self.blocks_add_xx_0_0_0, 0),
                     (self.blocks_add_xx_0_0_1, 1))
        self.connect((self.blocks_add_xx_0_0_1, 0),
                     (self.blocks_add_xx_0_0_2, 1))
        self.connect((self.blocks_add_xx_0_0_2, 0),
                     (self.blocks_complex_to_mag_squared_0, 0))
        self.connect((self.blocks_add_xx_0_0_2, 0),
                     (self.wxgui_scopesink2_1_0, 0))
        self.connect((self.blocks_add_xx_1, 0), (self.blocks_add_xx_0, 0))
        self.connect((self.blocks_add_xx_1, 0), (self.blocks_delay_0, 0))
        self.connect((self.blocks_complex_to_mag_squared_0, 0),
                     (self.blocks_add_const_vxx_0, 0))
        self.connect((self.blocks_delay_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.blocks_delay_0_0, 0), (self.blocks_delay_0_1, 0))
        self.connect((self.blocks_delay_0_0, 0),
                     (self.blocks_multiply_const_vxx_1, 0))
        self.connect((self.blocks_delay_0_1, 0), (self.blocks_delay_0_2, 0))
        self.connect((self.blocks_delay_0_1, 0),
                     (self.blocks_multiply_const_vxx_1_1, 0))
        self.connect((self.blocks_delay_0_2, 0), (self.blocks_delay_0_3, 0))
        self.connect((self.blocks_delay_0_2, 0),
                     (self.blocks_multiply_const_vxx_1_0, 0))
        self.connect((self.blocks_delay_0_3, 0),
                     (self.blocks_multiply_const_vxx_1_2, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.blocks_add_xx_0, 1))
        self.connect((self.blocks_multiply_const_vxx_1, 0),
                     (self.blocks_add_xx_0_0, 0))
        self.connect((self.blocks_multiply_const_vxx_1_0, 0),
                     (self.blocks_add_xx_0_0_1, 0))
        self.connect((self.blocks_multiply_const_vxx_1_1, 0),
                     (self.blocks_add_xx_0_0_0, 0))
        self.connect((self.blocks_multiply_const_vxx_1_2, 0),
                     (self.blocks_add_xx_0_0_2, 0))
        self.connect((self.digital_chunks_to_symbols_xx_0, 0),
                     (self.pfb_arb_resampler_xxx_0, 0))
        self.connect((self.digital_cma_equalizer_cc_0, 0),
                     (self.digital_costas_loop_cc_0, 0))
        self.connect((self.digital_costas_loop_cc_0, 0),
                     (self.wxgui_scopesink2_1, 0))
        self.connect((self.digital_pfb_clock_sync_xxx_0, 0),
                     (self.blocks_add_xx_0_0, 1))
        self.connect((self.digital_pfb_clock_sync_xxx_0, 0),
                     (self.blocks_delay_0_0, 0))
        self.connect((self.digital_pfb_clock_sync_xxx_0, 0),
                     (self.digital_cma_equalizer_cc_0, 0))
        self.connect((self.iir_filter_xxx_0, 0), (self.wxgui_scopesink2_0, 0))
        self.connect((self.pfb_arb_resampler_xxx_0, 0),
                     (self.blocks_add_xx_1, 0))
    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 = 300e3

        ##################################################
        # Blocks
        ##################################################
        self.qtgui_time_sink_x_0_1_0 = qtgui.time_sink_c(
            1024,  #size
            samp_rate,  #samp_rate
            "",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_0_1_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0_1_0.set_y_axis(-1, 1)

        self.qtgui_time_sink_x_0_1_0.set_y_label("Amplitude", "")

        self.qtgui_time_sink_x_0_1_0.enable_tags(-1, True)
        self.qtgui_time_sink_x_0_1_0.set_trigger_mode(qtgui.TRIG_MODE_FREE,
                                                      qtgui.TRIG_SLOPE_POS,
                                                      0.0, 0, 0, "")
        self.qtgui_time_sink_x_0_1_0.enable_autoscale(True)
        self.qtgui_time_sink_x_0_1_0.enable_grid(False)
        self.qtgui_time_sink_x_0_1_0.enable_control_panel(False)

        if not True:
            self.qtgui_time_sink_x_0_1_0.disable_legend()

        labels = ["", "", "", "", "", "", "", "", "", ""]
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "green", "black", "cyan", "magenta", "yellow",
            "dark red", "dark green", "blue"
        ]
        styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]

        for i in xrange(2 * 1):
            if len(labels[i]) == 0:
                if (i % 2 == 0):
                    self.qtgui_time_sink_x_0_1_0.set_line_label(
                        i, "Re{{Data {0}}}".format(i / 2))
                else:
                    self.qtgui_time_sink_x_0_1_0.set_line_label(
                        i, "Im{{Data {0}}}".format(i / 2))
            else:
                self.qtgui_time_sink_x_0_1_0.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_0_1_0.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_0_1_0.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_0_1_0.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_0_1_0.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_0_1_0.set_line_alpha(i, alphas[i])

        self._qtgui_time_sink_x_0_1_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_0_1_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_time_sink_x_0_1_0_win)
        self.qtgui_time_sink_x_0_1 = qtgui.time_sink_f(
            1024,  #size
            samp_rate,  #samp_rate
            "",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_0_1.set_update_time(0.10)
        self.qtgui_time_sink_x_0_1.set_y_axis(-1, 1)

        self.qtgui_time_sink_x_0_1.set_y_label("Amplitude", "")

        self.qtgui_time_sink_x_0_1.enable_tags(-1, True)
        self.qtgui_time_sink_x_0_1.set_trigger_mode(qtgui.TRIG_MODE_FREE,
                                                    qtgui.TRIG_SLOPE_POS, 0.0,
                                                    0, 0, "")
        self.qtgui_time_sink_x_0_1.enable_autoscale(True)
        self.qtgui_time_sink_x_0_1.enable_grid(False)
        self.qtgui_time_sink_x_0_1.enable_control_panel(False)

        if not True:
            self.qtgui_time_sink_x_0_1.disable_legend()

        labels = ["", "", "", "", "", "", "", "", "", ""]
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "green", "black", "cyan", "magenta", "yellow",
            "dark red", "dark green", "blue"
        ]
        styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]

        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_time_sink_x_0_1.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_0_1.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_0_1.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_0_1.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_0_1.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_0_1.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_0_1.set_line_alpha(i, alphas[i])

        self._qtgui_time_sink_x_0_1_win = sip.wrapinstance(
            self.qtgui_time_sink_x_0_1.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_time_sink_x_0_1_win)
        self.qtgui_time_sink_x_0 = qtgui.time_sink_f(
            1024,  #size
            samp_rate,  #samp_rate
            "",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0.set_y_axis(-1, 1)

        self.qtgui_time_sink_x_0.set_y_label("Amplitude", "")

        self.qtgui_time_sink_x_0.enable_tags(-1, True)
        self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE,
                                                  qtgui.TRIG_SLOPE_POS, 0.0, 0,
                                                  0, "")
        self.qtgui_time_sink_x_0.enable_autoscale(True)
        self.qtgui_time_sink_x_0.enable_grid(False)
        self.qtgui_time_sink_x_0.enable_control_panel(False)

        if not True:
            self.qtgui_time_sink_x_0.disable_legend()

        labels = ["", "", "", "", "", "", "", "", "", ""]
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "green", "black", "cyan", "magenta", "yellow",
            "dark red", "dark green", "blue"
        ]
        styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]

        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_time_sink_x_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_0.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_0.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i])

        self._qtgui_time_sink_x_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_time_sink_x_0_win)
        self.iir_filter_xxx_0 = filter.iir_filter_ffd((1.0 / samp_rate, ),
                                                      ([1, 1]), True)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_complex_to_real_0 = blocks.complex_to_real(1)
        self.analog_sig_source_x_0_0 = analog.sig_source_c(
            samp_rate, analog.GR_COS_WAVE, 10000, 1, 0)
        self.analog_sig_source_x_0 = analog.sig_source_f(
            samp_rate, analog.GR_COS_WAVE, 1000, 1, 0)
        self.analog_phase_modulator_fc_0 = analog.phase_modulator_fc(2 * 3.14 *
                                                                     5000)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_phase_modulator_fc_0, 0),
                     (self.blocks_multiply_xx_0, 0))
        self.connect((self.analog_sig_source_x_0, 0),
                     (self.iir_filter_xxx_0, 0))
        self.connect((self.analog_sig_source_x_0, 0),
                     (self.qtgui_time_sink_x_0_1, 0))
        self.connect((self.analog_sig_source_x_0_0, 0),
                     (self.blocks_multiply_xx_0, 1))
        self.connect((self.analog_sig_source_x_0_0, 0),
                     (self.qtgui_time_sink_x_0_1_0, 0))
        self.connect((self.blocks_complex_to_real_0, 0),
                     (self.qtgui_time_sink_x_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0),
                     (self.blocks_complex_to_real_0, 0))
        self.connect((self.iir_filter_xxx_0, 0),
                     (self.analog_phase_modulator_fc_0, 0))
Beispiel #49
0
    def __init__(self):
        gr.top_block.__init__(self, "Top Block")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Top Block")
        qtgui.util.check_set_qss()
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

        self.settings = Qt.QSettings("GNU Radio", "top_block")
        self.restoreGeometry(self.settings.value("geometry", type=QtCore.QByteArray))


        ##################################################
        # Variables
        ##################################################
        self.sps = sps = 4
        self.nfilts = nfilts = 32
        self.ntaps = ntaps = 11*nfilts*sps
        self.excess_bw = excess_bw = 0.4
        self.tx_taps = tx_taps = firdes.root_raised_cosine(nfilts, nfilts, 1.0, excess_bw, ntaps)
        self.timing_bw = timing_bw = 2*pi/100
        self.samp_rate_2 = samp_rate_2 = 20000
        self.samp_rate = samp_rate = 320000
        self.rx_taps = rx_taps = firdes.root_raised_cosine(nfilts, nfilts, 1.0, excess_bw, ntaps)
        self.const_points = const_points = 4

        ##################################################
        # Blocks
        ##################################################
        self.qtgui_time_sink_x_0 = qtgui.time_sink_f(
        	1024, #size
        	samp_rate/4, #samp_rate
        	"", #name
        	1 #number of inputs
        )
        self.qtgui_time_sink_x_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0.set_y_axis(-1, 1)

        self.qtgui_time_sink_x_0.set_y_label('Amplitude', "")

        self.qtgui_time_sink_x_0.enable_tags(-1, True)
        self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "")
        self.qtgui_time_sink_x_0.enable_autoscale(False)
        self.qtgui_time_sink_x_0.enable_grid(False)
        self.qtgui_time_sink_x_0.enable_axis_labels(True)
        self.qtgui_time_sink_x_0.enable_control_panel(True)
        self.qtgui_time_sink_x_0.enable_stem_plot(False)

        if not True:
          self.qtgui_time_sink_x_0.disable_legend()

        labels = ['', '', '', '', '',
                  '', '', '', '', '']
        widths = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        colors = ["blue", "red", "green", "black", "cyan",
                  "magenta", "yellow", "dark red", "dark green", "blue"]
        styles = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1,
                   -1, -1, -1, -1, -1]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]

        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_time_sink_x_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_0.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_0.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i])

        self._qtgui_time_sink_x_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_win)
        self.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_ccf(
        	  sps,
                  taps=(tx_taps),
        	  flt_size=32)
        self.pfb_arb_resampler_xxx_0.declare_sample_delay(0)

        self.iir_filter_xxx_0 = filter.iir_filter_ffd(([0.01]), ([-1,0.99]), True)
        self.digital_pfb_clock_sync_xxx_0_0 = digital.pfb_clock_sync_ccf(sps, timing_bw, (rx_taps), nfilts, 16, 1.5, 1)
        self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc(([1+1j,-1+1j,-1-1j,1-1j]), 1)
        self.blocks_throttle_1 = blocks.throttle(gr.sizeof_float*1, samp_rate/4,True)
        self.blocks_threshold_ff_0_0 = blocks.threshold_ff(-0.001, 0.001, 0)
        self.blocks_threshold_ff_0 = blocks.threshold_ff(-0.001, 0.001, 0)
        self.blocks_sub_xx_0 = blocks.sub_ff(1)
        self.blocks_multiply_xx_1_0 = blocks.multiply_vff(1)
        self.blocks_multiply_xx_1 = blocks.multiply_vff(1)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_complex_to_float_0 = blocks.complex_to_float(1)
        self.blocks_add_const_vxx_0_0 = blocks.add_const_vff((-0.5, ))
        self.blocks_add_const_vxx_0 = blocks.add_const_vff((-0.5, ))
        self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate, analog.GR_SIN_WAVE, 10, 1, 0)
        self.analog_random_source_x_0 = blocks.vector_source_b(map(int, numpy.random.randint(0, 4, 1000)), True)



        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_random_source_x_0, 0), (self.digital_chunks_to_symbols_xx_0, 0))
        self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1))
        self.connect((self.blocks_add_const_vxx_0, 0), (self.blocks_multiply_xx_1, 0))
        self.connect((self.blocks_add_const_vxx_0_0, 0), (self.blocks_multiply_xx_1_0, 1))
        self.connect((self.blocks_complex_to_float_0, 1), (self.blocks_multiply_xx_1, 1))
        self.connect((self.blocks_complex_to_float_0, 0), (self.blocks_multiply_xx_1_0, 0))
        self.connect((self.blocks_complex_to_float_0, 0), (self.blocks_threshold_ff_0, 0))
        self.connect((self.blocks_complex_to_float_0, 1), (self.blocks_threshold_ff_0_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0), (self.digital_pfb_clock_sync_xxx_0_0, 0))
        self.connect((self.blocks_multiply_xx_1, 0), (self.blocks_sub_xx_0, 0))
        self.connect((self.blocks_multiply_xx_1_0, 0), (self.blocks_sub_xx_0, 1))
        self.connect((self.blocks_sub_xx_0, 0), (self.iir_filter_xxx_0, 0))
        self.connect((self.blocks_threshold_ff_0, 0), (self.blocks_add_const_vxx_0, 0))
        self.connect((self.blocks_threshold_ff_0_0, 0), (self.blocks_add_const_vxx_0_0, 0))
        self.connect((self.blocks_throttle_1, 0), (self.qtgui_time_sink_x_0, 0))
        self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.pfb_arb_resampler_xxx_0, 0))
        self.connect((self.digital_pfb_clock_sync_xxx_0_0, 0), (self.blocks_complex_to_float_0, 0))
        self.connect((self.iir_filter_xxx_0, 0), (self.blocks_throttle_1, 0))
        self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.blocks_multiply_xx_0, 0))
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Top Block")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 40000

        ##################################################
        # Blocks
        ##################################################
        self.lab5_part2 = self.lab5_part2 = wx.Notebook(self.GetWin(),
                                                        style=wx.NB_TOP)
        self.lab5_part2.AddPage(grc_wxgui.Panel(self.lab5_part2), "scope")
        self.lab5_part2.AddPage(grc_wxgui.Panel(self.lab5_part2), "fft")
        self.Add(self.lab5_part2)
        self.wxgui_scopesink2_0 = scopesink2.scope_sink_f(
            self.lab5_part2.GetPage(0).GetWin(),
            title="Scope Plot",
            sample_rate=40000,
            v_scale=0,
            v_offset=0,
            t_scale=0,
            ac_couple=False,
            xy_mode=False,
            num_inputs=1,
            trig_mode=wxgui.TRIG_MODE_AUTO,
            y_axis_label="Counts",
        )
        self.lab5_part2.GetPage(0).Add(self.wxgui_scopesink2_0.win)
        self.wxgui_fftsink2_0 = fftsink2.fft_sink_f(
            self.lab5_part2.GetPage(1).GetWin(),
            baseband_freq=0,
            y_per_div=10,
            y_divs=10,
            ref_level=0,
            ref_scale=2.0,
            sample_rate=40000,
            fft_size=1024,
            fft_rate=15,
            average=False,
            avg_alpha=None,
            title="FFT Plot",
            peak_hold=False,
        )
        self.lab5_part2.GetPage(1).Add(self.wxgui_fftsink2_0.win)
        self.rational_resampler_xxx_0 = filter.rational_resampler_fff(
            interpolation=16,
            decimation=1,
            taps=None,
            fractional_bw=None,
        )
        self.low_pass_filter_0 = filter.fir_filter_fff(
            16,
            firdes.low_pass(1, 640000, 20000, 4000, firdes.WIN_HAMMING, 6.76))
        self.iir_filter_xxx_2 = filter.iir_filter_ffd((1, -0.95), (1, ), True)
        self.iir_filter_xxx_1 = filter.iir_filter_ffd((1, ), (1, 0.95), True)
        self.iir_filter_xxx_0 = filter.iir_filter_ffd((1 / 40e3, ), (1, 1),
                                                      True)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1,
                                                 640000, True)
        self.blocks_multiply_xx_1 = blocks.multiply_vcc(1)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff(
            (1 / 640e3, ))
        self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex * 1, 1)
        self.blocks_conjugate_cc_0 = blocks.conjugate_cc()
        self.blocks_complex_to_arg_0 = blocks.complex_to_arg(1)
        self.blocks_add_xx_1 = blocks.add_vcc(1)
        self.blocks_add_xx_0 = blocks.add_vff(1)
        self.analog_sig_source_x_2 = analog.sig_source_f(
            samp_rate, analog.GR_COS_WAVE, 11000, 0.5, 0)
        self.analog_sig_source_x_1 = analog.sig_source_c(
            640000, analog.GR_COS_WAVE, 100000, 1, 0)
        self.analog_sig_source_x_0 = analog.sig_source_f(
            samp_rate, analog.GR_COS_WAVE, 1100, 0.5, 0)
        self.analog_phase_modulator_fc_0 = analog.phase_modulator_fc(471000)
        self.analog_noise_source_x_0 = analog.noise_source_c(
            analog.GR_GAUSSIAN, 0.2, 0)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_noise_source_x_0, 0),
                     (self.blocks_add_xx_1, 1))
        self.connect((self.analog_phase_modulator_fc_0, 0),
                     (self.blocks_multiply_xx_0, 0))
        self.connect((self.analog_sig_source_x_0, 0),
                     (self.blocks_add_xx_0, 1))
        self.connect((self.analog_sig_source_x_1, 0),
                     (self.blocks_multiply_xx_0, 1))
        self.connect((self.analog_sig_source_x_2, 0),
                     (self.blocks_add_xx_0, 0))
        self.connect((self.blocks_add_xx_0, 0), (self.iir_filter_xxx_0, 0))
        self.connect((self.blocks_add_xx_1, 0), (self.blocks_delay_0, 0))
        self.connect((self.blocks_add_xx_1, 0), (self.blocks_multiply_xx_1, 0))
        self.connect((self.blocks_complex_to_arg_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.blocks_conjugate_cc_0, 0),
                     (self.blocks_multiply_xx_1, 1))
        self.connect((self.blocks_delay_0, 0), (self.blocks_conjugate_cc_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.low_pass_filter_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0),
                     (self.blocks_throttle_0, 0))
        self.connect((self.blocks_multiply_xx_1, 0),
                     (self.blocks_complex_to_arg_0, 0))
        self.connect((self.blocks_throttle_0, 0), (self.blocks_add_xx_1, 0))
        self.connect((self.iir_filter_xxx_0, 0),
                     (self.rational_resampler_xxx_0, 0))
        self.connect((self.iir_filter_xxx_1, 0), (self.wxgui_fftsink2_0, 0))
        self.connect((self.iir_filter_xxx_1, 0), (self.wxgui_scopesink2_0, 0))
        self.connect((self.iir_filter_xxx_2, 0),
                     (self.analog_phase_modulator_fc_0, 0))
        self.connect((self.low_pass_filter_0, 0), (self.iir_filter_xxx_1, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.iir_filter_xxx_2, 0))