Example #1
0
    def testSingle(self):
        gen = VectorInput([1])
        clip = Clipper()
        p = Pool()

        gen.data >> clip.signal >> (p, 'clipped')
        run(gen)

        self.assertEqualVector(p['clipped'], [1])
Example #2
0
    def testEmpty(self):
        gen = VectorInput([])
        clip = Clipper()
        p = Pool()

        gen.data >> clip.signal >> (p, 'clipped')
        run(gen)

        self.assertEqualVector(p.descriptorNames(), [])
Example #3
0
    def testUnClipped(self):
        input = [5, 0, -1, 2, -3, 4]
        expected = input

        gen = VectorInput(input)
        clip = Clipper(min=min(input), max=max(input))
        p = Pool()

        gen.data >> clip.signal >> (p, 'clipped')
        run(gen)

        self.assertEqualVector(p['clipped'], expected)
Example #4
0
    def testSimple(self):
        sr = 44100
        max = 0.5
        min = -1

        input = [2 * sin(2 * pi * i * 5 / sr) for i in range(sr)]
        gen = VectorInput(input)
        clip = Clipper(min=min, max=max)
        p = Pool()

        gen.data >> clip.signal >> (p, 'clipped')
        run(gen)

        for val in p['clipped']:
            self.assertTrue(val <= max)
            self.assertTrue(val >= min)