Exemplo n.º 1
0
    def test_duration(self):
        m = TreeMeasure(time=(3, 4))
        self.assertEqual(m.quarter_duration, 3)

        p = TreePart(id='one')
        m.add_child(p)

        tree_part_voice = p.get_staff(1).get_voice(1)
        tree_part_voice.set_beats([
            TreeBeat(duration=2),
            TreeBeat(duration=0.5),
            TreeBeat(duration=0.5)
        ])
        result = [0, 2, 2.5]
        self.assertEqual([beat.offset for beat in tree_part_voice.beats],
                         result)
Exemplo n.º 2
0
 def test_beats(self):
     m = TreeMeasure(time=(3, 8, 2, 4))
     p = TreePart(id='one')
     m.add_child(p)
     tree_part_voice = p.get_staff(1).get_voice(1)
     tree_part_voice.set_beats()
     result = [0.5, 0.5, 0.5, 1.0, 1.0]
     self.assertEqual([beat.duration for beat in tree_part_voice.beats], result)
     result = [0, 0.5, 1.0, 1.5, 2.5]
     self.assertEqual([beat.offset for beat in tree_part_voice.beats], result)
     # result = [4, 4, 4, 8, 8]
     # self.assertEqual([beat.max_division for beat in tree_part_voice.beats], result)
     # tree_part_voice.beats[3].max_division = 5
     # result = [4, 4, 4, 5, 8]
     # self.assertEqual([beat.max_division for beat in tree_part_voice.beats], result)
     with self.assertRaises(ValueError):
         tree_part_voice.set_beats([TreeBeat(duration=0.5), TreeBeat(duration=0.5), TreeBeat(duration=0.5)])
     tree_part_voice.set_beats([TreeBeat(duration=1), TreeBeat(duration=0.5), TreeBeat(duration=2)])
     result = [0, 1, 1.5]
     self.assertEqual([beat.offset for beat in tree_part_voice.beats], result)