示例#1
0
    def test_split_beats_2(self):
        m = TreeMeasure(time=(3, 4))
        p = TreePart(id='one')
        p.max_division = 8
        p.forbidden_divisions = []
        m.add_child(p)
        # p.set_beats()

        p.add_chord(TreeChord(60, quarter_duration=1.4))
        p.add_chord(TreeChord(60, quarter_duration=1.6))
        # p._add_chords_to_beats()
        # p._split_chords_beatwise()
        p.finish()
        result = [Fraction(1, 1), Fraction(2, 5), Fraction(3, 5), Fraction(1, 1)]
        self.assertEqual([chord.quarter_duration for chord in p.chords], result)
示例#2
0
    def test_quantize(self):
        m = TreeMeasure(time=(4, 4))
        p = TreePart(id='one')
        p.max_division = 8
        p.forbidden_divisions = []
        m.add_child(p)
        p.add_chord(TreeChord(60, quarter_duration=1))
        p.add_chord(TreeChord(60, quarter_duration=1.2))
        p.add_chord(TreeChord(60, quarter_duration=0.3))
        p.add_chord(TreeChord(60, quarter_duration=0.2))
        p.add_chord(TreeChord(60, quarter_duration=1.3))
        p.finish()

        result = [Fraction(1, 1), Fraction(1, 1), Fraction(1, 6), Fraction(1, 3), Fraction(1, 6), Fraction(1, 3),
                  Fraction(1, 1)]
        self.assertEqual([chord.quarter_duration for chord in p.chords], result)