Пример #1
0
    def test_9(self):
        fm = FractalMusic(proportions=[1, 2, 3, 4, 5, 6, 7],
                          tree_permutation_order=[3, 6, 2, 5, 1, 7, 4])

        fm.multi = (7, 4)
        fm.tempo = 60
        fm.quarter_duration = 70

        fm.midi_generator.microtone = 4
        # fm.quantize_leaves(0.5)
        fm.midi_generator.directions = [1, -1, 1, -1, 1, -1, 1]

        fm.midi_generator.midi_range = [36, 56]
        fm.add_layer()

        fm.reduce_children(lambda child: child.fractal_order > 4)
        fm.quantize_leaves(0.5)
        fm.get_children()[3].add_layer()
        fm.get_children()[3].reduce_children(
            lambda child: child.fractal_order > 4)
        for node in fm.traverse():
            node.chord.add_words(node.midi_value)
        text_path = path + '_test_9.txt'
        fm.write_infos(text_path)
        self.assertCompareFiles(actual_file_path=text_path)

        score = fm.get_score()
        xml_path = path + '_test_9.xml'
        score.write(xml_path)
        self.assertCompareFiles(actual_file_path=xml_path)
Пример #2
0
 def test_1(self):
     fm = FractalMusic(proportions=[1, 2, 3], tree_permutation_order=[3, 1, 2], duration=12, tempo=72)
     fm.quarter_duration = round(fm.quarter_duration)
     fm.add_layer()
     quarter_durations = [float(leaf.quarter_duration) for leaf in fm.traverse_leaves()]
     # print(quarter_durations)
     # print(sum(quarter_durations))
     fm.quantize_leaves(grid_size=0.5)
     quarter_durations = [float(leaf.quarter_duration) for leaf in fm.traverse_leaves()]
     self.assertEqual(quarter_durations, [7.0, 2.5, 4.5])
Пример #3
0
 def test_4(self):
     fm = FractalMusic(duration=30)
     fm.add_layer()
     fm.get_children()[1].tempo = 72
     fm.set_none_tempi(80)
     fm.quantize_leaves(0.5)
     fm.add_layer()
     score = fm.get_root_score(layer_number=1, show_fractal_orders=True)
     xml_path = path + '_test_4.xml'
     score.write(path=xml_path)
     with self.assertRaises(SetTempoFirstException):
         fm.get_score()