Example #1
0
 def test_saw_f(self):
     tb = self.tb
     expected_result = (.5, .625, .75, .875, 0, .125, .25, .375, .5)
     src1 = analog.sig_source_f(8, analog.GR_SAW_WAVE, 1.0, 1.0)
     op = blocks.head(gr.sizeof_float, 9)
     dst1 = blocks.vector_sink_f()
     tb.connect(src1, op)
     tb.connect(op, dst1)
     tb.run()
     dst_data = dst1.data()
     self.assertFloatTuplesAlmostEqual(expected_result, dst_data, 5)
Example #2
0
 def test_const_f(self):
     tb = self.tb
     expected_result = (1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5)
     src1 = analog.sig_source_f(1e6, analog.GR_CONST_WAVE, 0, 1.5)
     op = blocks.head(gr.sizeof_float, 10)
     dst1 = blocks.vector_sink_f()
     tb.connect(src1, op)
     tb.connect(op, dst1)
     tb.run()
     dst_data = dst1.data()
     self.assertEqual(expected_result, dst_data)
Example #3
0
 def test_tri_f(self):
     tb = self.tb
     expected_result = (1, .75, .5, .25, 0, .25, .5, .75, 1)
     src1 = analog.sig_source_f(8, analog.GR_TRI_WAVE, 1.0, 1.0)
     op = gr.head(gr.sizeof_float, 9)
     dst1 = gr.vector_sink_f()
     tb.connect(src1, op)
     tb.connect(op, dst1)
     tb.run()
     dst_data = dst1.data()
     self.assertFloatTuplesAlmostEqual(expected_result, dst_data, 5)
Example #4
0
 def test_sqr_f(self):
     tb = self.tb
     expected_result = (0, 0, 0, 0, 1, 1, 1, 1, 0)
     src1 = analog.sig_source_f(8, analog.GR_SQR_WAVE, 1.0, 1.0)
     op = blocks.head(gr.sizeof_float, 9)
     dst1 = blocks.vector_sink_f()
     tb.connect(src1, op)
     tb.connect(op, dst1)
     tb.run()
     dst_data = dst1.data()
     self.assertEqual(expected_result, dst_data)
 def test_tri_f(self):
     tb = self.tb
     expected_result = (1, .75, .5, .25, 0, .25, .5, .75, 1)
     src1 = analog.sig_source_f(8, analog.GR_TRI_WAVE, 1.0, 1.0)
     op = gr.head(gr.sizeof_float, 9)
     dst1 = gr.vector_sink_f()
     tb.connect(src1, op)
     tb.connect(op, dst1)
     tb.run()
     dst_data = dst1.data()
     self.assertFloatTuplesAlmostEqual(expected_result, dst_data, 5)
Example #6
0
 def test_cosine_f(self):
     tb = self.tb
     sqrt2 = math.sqrt(2) / 2
     expected_result = (1, sqrt2, 0, -sqrt2, -1, -sqrt2, 0, sqrt2, 1)
     src1 = analog.sig_source_f(8, analog.GR_COS_WAVE, 1.0, 1.0)
     op = blocks.head(gr.sizeof_float, 9)
     dst1 = blocks.vector_sink_f()
     tb.connect(src1, op)
     tb.connect(op, dst1)
     tb.run()
     dst_data = dst1.data()
     self.assertFloatTuplesAlmostEqual(expected_result, dst_data, 5)
Example #7
0
    def test_002(self):
        ''' Test the floating point AGC loop (single rate input) '''
        tb = self.tb

        expected_result = (
            7.2191943445432116e-07, 58.837181091308594, 89.700050354003906,
            81.264183044433594, 45.506141662597656, 4.269894304798072e-07,
            -42.948936462402344, -65.50335693359375, -59.368724822998047,
            -33.261005401611328, -4.683740257860336e-07, 31.423542022705078,
            47.950984954833984, 43.485683441162109, 24.378345489501953,
            5.7254135299444897e-07, -23.062990188598633, -35.218441009521484,
            -31.964075088500977, -17.934831619262695, -5.0591745548445033e-07,
            16.998210906982422, 25.982204437255859, 23.606258392333984,
            13.260685920715332, 4.9936483037527069e-07, -12.59880542755127,
            -19.28221321105957, -17.54347038269043, -9.8700437545776367,
            -4.188150626305287e-07, 9.4074573516845703, 14.422011375427246,
            13.145503044128418, 7.41046142578125, 3.8512698097292741e-07,
            -7.0924453735351562, -10.896408081054688, -9.9552040100097656,
            -5.6262712478637695, -3.1982864356905338e-07, 5.4131259918212891,
            8.3389215469360352, 7.6409502029418945, 4.3320145606994629,
            2.882407841298118e-07, -4.194943904876709, -6.4837145805358887,
            -5.9621825218200684, -3.3931560516357422)

        sampling_freq = 100
        src1 = analog.sig_source_f(sampling_freq, analog.GR_SIN_WAVE,
                                   sampling_freq * 0.10, 100.0)
        dst1 = blocks.vector_sink_f()
        head = blocks.head(gr.sizeof_float, int(5 * sampling_freq * 0.10))

        agc = analog.agc_ff(1e-3, 1, 1)

        tb.connect(src1, head)
        tb.connect(head, agc)
        tb.connect(agc, dst1)

        tb.run()
        dst_data = dst1.data()
        self.assertFloatTuplesAlmostEqual(expected_result, dst_data, 4)
Example #8
0
    def test_004(self):
        ''' Test the floating point AGC loop (attack and decay rate inputs) '''
        tb = self.tb

        expected_result = \
            (7.2191943445432116e-07,
             58.837181091308594,
             40.194305419921875,
             2.9183335304260254,
             0.67606079578399658,
             8.6260438791896377e-09,
             -1.4542514085769653,
             -1.9210131168365479,
             -1.0450780391693115,
             -0.61939650774002075,
             -1.2590258613442984e-08,
             1.4308931827545166,
             1.9054338932037354,
             1.0443156957626343,
             0.61937344074249268,
             2.0983527804219193e-08,
             -1.4308838844299316,
             -1.9054274559020996,
             -1.0443152189254761,
             -0.61937344074249268,
             -2.5180233009791664e-08,
             1.4308837652206421,
             1.9054274559020996,
             1.0443154573440552,
             0.61937344074249268,
             3.3573645197293445e-08,
             -1.4308838844299316,
             -1.9054274559020996,
             -1.0443152189254761,
             -0.61937350034713745,
             -3.7770352179222755e-08,
             1.4308837652206421,
             1.9054274559020996,
             1.0443154573440552,
             0.61937350034713745,
             4.6163762590367696e-08,
             -1.4308838844299316,
             -1.9054274559020996,
             -1.0443153381347656,
             -0.61937344074249268,
             -5.0360466019583328e-08,
             1.4308837652206421,
             1.9054274559020996,
             1.0443155765533447,
             0.61937344074249268,
             5.8753879983441948e-08,
             -1.4308837652206421,
             -1.9054274559020996,
             -1.0443153381347656,
             -0.61937344074249268)

        sampling_freq = 100
        src1 = analog.sig_source_f(sampling_freq, analog.GR_SIN_WAVE,
                                   sampling_freq * 0.10, 100)
        dst1 = blocks.vector_sink_f()
        head = blocks.head(gr.sizeof_float, int(5*sampling_freq * 0.10))

        agc = analog.agc2_ff(1e-2, 1e-3, 1, 1)

        tb.connect(src1, head)
        tb.connect(head, agc)
        tb.connect(agc, dst1)

        tb.run()
        dst_data = dst1.data()
        self.assertFloatTuplesAlmostEqual(expected_result, dst_data, 4)
Example #9
0
    def test_002(self):
        ''' Test the floating point AGC loop (single rate input) '''
        tb = self.tb

        expected_result = (
            7.2191943445432116e-07,
            58.837181091308594,
            89.700050354003906,
            81.264183044433594,
            45.506141662597656,
            4.269894304798072e-07,
            -42.948936462402344,
            -65.50335693359375,
            -59.368724822998047,
            -33.261005401611328,
            -4.683740257860336e-07,
            31.423542022705078,
            47.950984954833984,
            43.485683441162109,
            24.378345489501953,
            5.7254135299444897e-07,
            -23.062990188598633,
            -35.218441009521484,
            -31.964075088500977,
            -17.934831619262695,
            -5.0591745548445033e-07,
            16.998210906982422,
            25.982204437255859,
            23.606258392333984,
            13.260685920715332,
            4.9936483037527069e-07,
            -12.59880542755127,
            -19.28221321105957,
            -17.54347038269043,
            -9.8700437545776367,
            -4.188150626305287e-07,
            9.4074573516845703,
            14.422011375427246,
            13.145503044128418,
            7.41046142578125,
            3.8512698097292741e-07,
            -7.0924453735351562,
            -10.896408081054688,
            -9.9552040100097656,
            -5.6262712478637695,
            -3.1982864356905338e-07,
            5.4131259918212891,
            8.3389215469360352,
            7.6409502029418945,
            4.3320145606994629,
            2.882407841298118e-07,
            -4.194943904876709,
            -6.4837145805358887,
            -5.9621825218200684,
            -3.3931560516357422)

        sampling_freq = 100
        src1 = analog.sig_source_f(sampling_freq, analog.GR_SIN_WAVE,
                                   sampling_freq * 0.10, 100.0)
        dst1 = blocks.vector_sink_f ()
        head = blocks.head (gr.sizeof_float, int (5*sampling_freq * 0.10))

        agc = analog.agc_ff(1e-3, 1, 1)

        tb.connect (src1, head)
        tb.connect (head, agc)
        tb.connect (agc, dst1)

        tb.run ()
        dst_data = dst1.data ()
        self.assertFloatTuplesAlmostEqual (expected_result, dst_data, 4)
Example #10
0
    def test_004(self):
        ''' Test the floating point AGC loop (attack and decay rate inputs) '''
        tb = self.tb

        expected_result = \
            (7.2191943445432116e-07,
             58.837181091308594,
             40.194305419921875,
             2.9183335304260254,
             0.67606079578399658,
             8.6260438791896377e-09,
             -1.4542514085769653,
             -1.9210131168365479,
             -1.0450780391693115,
             -0.61939650774002075,
             -1.2590258613442984e-08,
             1.4308931827545166,
             1.9054338932037354,
             1.0443156957626343,
             0.61937344074249268,
             2.0983527804219193e-08,
             -1.4308838844299316,
             -1.9054274559020996,
             -1.0443152189254761,
             -0.61937344074249268,
             -2.5180233009791664e-08,
             1.4308837652206421,
             1.9054274559020996,
             1.0443154573440552,
             0.61937344074249268,
             3.3573645197293445e-08,
             -1.4308838844299316,
             -1.9054274559020996,
             -1.0443152189254761,
             -0.61937350034713745,
             -3.7770352179222755e-08,
             1.4308837652206421,
             1.9054274559020996,
             1.0443154573440552,
             0.61937350034713745,
             4.6163762590367696e-08,
             -1.4308838844299316,
             -1.9054274559020996,
             -1.0443153381347656,
             -0.61937344074249268,
             -5.0360466019583328e-08,
             1.4308837652206421,
             1.9054274559020996,
             1.0443155765533447,
             0.61937344074249268,
             5.8753879983441948e-08,
             -1.4308837652206421,
             -1.9054274559020996,
             -1.0443153381347656,
             -0.61937344074249268)

        sampling_freq = 100
        src1 = analog.sig_source_f(sampling_freq, analog.GR_SIN_WAVE,
                                   sampling_freq * 0.10, 100)
        dst1 = blocks.vector_sink_f()
        head = blocks.head(gr.sizeof_float, int(5 * sampling_freq * 0.10))

        agc = analog.agc2_ff(1e-2, 1e-3, 1, 1)

        tb.connect(src1, head)
        tb.connect(head, agc)
        tb.connect(agc, dst1)

        tb.run()
        dst_data = dst1.data()
        self.assertFloatTuplesAlmostEqual(expected_result, dst_data, 4)