예제 #1
0
    def test_8(self):
        fm = FractalMusic(duration=100)
        fm.tempo = 72
        fm.add_layer()
        fm.add_layer()
        fm.add_layer()
        fm.set_none_tempi(60)

        self.assertEqual(fm.get_layer(2, key='tempo'),
                         [[72, 72, 72], [72, 72, 72], [72, 72, 72]])
예제 #2
0
    def test_6(self):
        fm = FractalMusic(duration=100)
        fm.add_layer()

        fm.get_children()[1].tempo = 80
        fm.add_layer()
        fm.get_children()[2].get_children()[2].tempo = 72
        fm.add_layer()

        self.assertEqual(fm.get_layer(2, key='tempo'),
                         [[None, None, None], [80, 80, 80], [None, None, 72]])
예제 #3
0
    def test_7(self):
        fm = FractalMusic(duration=100)
        fm.add_layer()

        fm.get_children()[1].tempo = 80
        fm.add_layer()
        fm.get_children()[2].get_children()[2].tempo = 72
        fm.add_layer()
        fm.set_none_tempi(60)

        self.assertEqual(fm.get_layer(2, key='tempo'),
                         [[60, 60, 60], [80, 80, 80], [60, 60, 72]])
예제 #4
0
class Test(TestCase):
    def setUp(self) -> None:
        self.fm = FractalMusic(tempo=72, quarter_duration=10)

    def test_1(self):
        self.fm.change_quarter_duration(20)
        expected = 20
        self.assertEqual(expected, self.fm.quarter_duration)

    def test_2(self):
        self.fm.add_layer()
        self.fm.get_children()[0].change_quarter_duration(10)
        expected = 15
        self.assertEqual(expected, self.fm.quarter_duration)

    def test_3(self):
        self.fm.add_layer()
        self.fm.get_children()[0].change_quarter_duration(10)
        expected = [Fraction(10, 1), Fraction(5, 3), Fraction(10, 3)]
        self.assertEqual(
            expected,
            [child.quarter_duration for child in self.fm.get_children()])

    def test_4(self):
        self.fm.add_layer()
        self.fm.change_quarter_duration(15)
        expected = [Fraction(15, 2), Fraction(5, 2), Fraction(5, 1)]
        self.assertEqual(
            expected,
            [child.quarter_duration for child in self.fm.get_children()])

    def test_5(self):
        self.fm.add_layer()
        self.fm.add_layer()
        self.fm.get_children()[0].change_quarter_duration(10)
        expected = [[Fraction(15, 1)], [10,
                                        Fraction(5, 3),
                                        Fraction(10, 3)],
                    [[Fraction(5, 3),
                      Fraction(10, 3),
                      Fraction(5, 1)],
                     [Fraction(5, 6),
                      Fraction(5, 18),
                      Fraction(5, 9)],
                     [Fraction(10, 9),
                      Fraction(5, 3),
                      Fraction(5, 9)]]]
        self.assertEqual(expected, [
            self.fm.get_layer(layer=i, key='quarter_duration')
            for i in range(self.fm.number_of_layers + 1)
        ])