Пример #1
0
    def test_5(self):
        score = TreeScoreTimewise()

        fm = FractalMusic(tempo=60,
                          proportions=[1, 2, 3, 4],
                          tree_permutation_order=[3, 1, 4, 2],
                          quarter_duration=20)
        fm.midi_generator.midi_range = [60, 79]
        fm.midi_generator.microtone = 4
        fm.add_layer()

        for child in fm.get_children():
            child.chord.add_lyric(child.fractal_order)

        simple_format = fm.get_simple_format(1)
        v = simple_format.to_stream_voice(1)
        v.add_to_score(score, 1)

        fm.reduce_children(lambda child: child.fractal_order in [1])

        simple_format = fm.get_simple_format(1)
        v = simple_format.to_stream_voice(1)
        v.add_to_score(score, 2)

        fm.add_layer()

        for leaf in fm.traverse_leaves():
            leaf.chord.add_lyric(leaf.fractal_order)
            # leaf.chord.add_words(leaf.midi_generator.midi_range[1])

        simple_format = fm.get_simple_format(2)
        v = simple_format.to_stream_voice(1)
        v.add_to_score(score, 3)

        text_path = path + '_test_5.txt'
        fm.write_infos(text_path)
        self.assertCompareFiles(actual_file_path=text_path)

        xml_path = path + '_test_5.xml'
        score.max_division = 7
        score.write(xml_path)
        self.assertCompareFiles(actual_file_path=xml_path)
Пример #2
0
from musicscore.musicstream.streamvoice import SimpleFormat
from musicscore.musictree.treeclef import ALTO_CLEF, TREBLE_CLEF
from musicscore.musictree.treescoretimewise import TreeScoreTimewise

path = str(os.path.abspath(__file__).split('.')[0])
durations = [
    Fraction(31, 14),
    Fraction(93, 56),
    Fraction(31, 28),
    Fraction(155, 56),
    Fraction(57, 56)
]
clefs = [ALTO_CLEF, None, None, TREBLE_CLEF, ALTO_CLEF]


def get_chords():
    return score.get_measure(1).get_part(1).voices[1].chords


sf = SimpleFormat(quarter_durations=durations)
for chord, clef in zip(sf.chords, clefs):
    if clef:
        chord.add_clef(clef)

score = TreeScoreTimewise()
score.max_division = 7
sf.to_stream_voice().add_to_score(score)
xml_path = path + '_1.xml'
score.write(xml_path)