Ejemplo n.º 1
0
    def test_empty_segments(self):
        env = envelope.Segments()

        expected = []
        function_tester(env, self, expected)

        expected = [0, 0, 0, 0]
        function_tester(env, self, expected)
Ejemplo n.º 2
0
    def test_square(self):
        env = envelope.Square()
        expected = [0, 0, 0, 0, 1, 1, 1, 1, 0]
        function_tester(env, self, expected)

        env = envelope.Square(duty_cycle=Fraction(1, 6))
        expected = [0, 0, 0, 0, 0, 0, 0, 1, 0]
        function_tester(env, self, expected)

        env = envelope.Square(duty_cycle=Fraction(5, 6))
        expected = [0, 0, 1, 1, 1, 1, 1, 1, 0]
        function_tester(env, self, expected)
Ejemplo n.º 3
0
    def test_simple_segments(self):
        env = envelope.Segments([1, 2, 3, 4])
        self.assertEqual(env.period, 1)

        expected = [0, 0.5, 1, 1.5, 2, 2.5, 3, 3.5, 0]
        function_tester(env, self, expected)
Ejemplo n.º 4
0
 def test_identity(self):
     env = envelope.Linear()
     expected = [0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 0]
     function_tester(env, self, expected)
Ejemplo n.º 5
0
 def test_triangular(self):
     env = envelope.Triangular()
     expected = [0, 0.25, 0.5, 0.75]
     expected += [1] + expected[::-1]
     function_tester(env, self, expected)
Ejemplo n.º 6
0
 def test_sine(self):
     env = envelope.Sine()
     expected = [math.sin(i * math.pi / 5) for i in range(11)]
     function_tester(env, self, expected)
Ejemplo n.º 7
0
 def test_symmetry(self):
     env = envelope.Linear(symmetry=Fraction(1) / 3)
     expected = [0 / 32, 6 / 32, 12 / 32, 17 / 32, 20 / 32,
                 23 / 32, 26 / 32, 29 / 32, 0 / 32]
     function_tester(env, self, expected)
Ejemplo n.º 8
0
 def test_period(self):
     env = envelope.Linear(period=2)
     expected = [i / 20 for i in range(20)] + [0]
     function_tester(env, self, expected, 10)
Ejemplo n.º 9
0
 def test_offset_and_scale(self):
     env = envelope.Linear(offset=0.05, scale=2)
     expected = [0.05, 0.25, 0.45, 0.65, 0.85,
                 1.05, 1.25, 1.45, 1.65, 1.85, 0.05]
     function_tester(env, self, expected)
Ejemplo n.º 10
0
 def test_disable(self):
     env = envelope.Linear(base_value=0.5, enabled=False)
     expected = [0.5] * 11
     function_tester(env, self, expected)
Ejemplo n.º 11
0
    def test_decreasing_segments(self):
        env = envelope.Segments([1, 3, 2, 4])
        self.assertEqual(env.period, 1)

        expected = [0, 0.5, 1, 2, 3, 2.5, 2, 3, 0]
        function_tester(env, self, expected)