def test_tie_break(self): print('test tie break') a = Note(DiatonicPitch(3, 'a'), Duration(1, 8)) b = Note(DiatonicPitch(3, 'b'), Duration(1, 8)) c = Note(DiatonicPitch(3, 'c'), Duration(1, 8)) d = Note(DiatonicPitch(3, 'a'), Duration(1, 8)) sub_beam = Beam([b, c]) beam = Beam([a, d]) a.tie() assert a.is_tied_to assert d.is_tied_from beam.add(sub_beam, 1) assert not a.is_tied_to assert not d.is_tied_from
def test_tie(self): print('test_next_note') a = Note(DiatonicPitch(3, 'a'), Duration(1, 8)) b = Note(DiatonicPitch(3, 'a'), Duration(1, 8)) c = Note(DiatonicPitch(3, 'c'), Duration(1, 8)) Beam([a, b, c]) assert not a.is_tied_to assert not b.is_tied_from a.tie() assert a.is_tied_to assert b.is_tied_from assert a.tied_to == b assert b.tied_from == a a.untie() assert not a.is_tied_to assert not b.is_tied_from assert a.tied_to is None assert b.tied_from is None with self.assertRaises(Exception): c.tie()
def test_ties_reverse(self): print('test ties reverse') a = Note(DiatonicPitch(3, 'b'), Duration(1, 8)) b = Note(DiatonicPitch(4, 'b'), Duration(1, 8)) c = Note(DiatonicPitch(4, 'c'), Duration(1, 8)) d = Note(DiatonicPitch(4, 'd'), Duration(1, 8)) tuplet = Tuplet(Duration(1, 8), 3, [a, b, c, d]) e = Note(DiatonicPitch(4, 'd'), Duration(1, 8)) f = Note(DiatonicPitch(4, 'f'), Duration(1, 8)) g = Note(DiatonicPitch(4, 'g'), Duration(1, 8)) a1 = Note(DiatonicPitch(3, 'd'), Duration(1, 8)) sub_beam = Beam([e, f, g, a1]) b1 = Note(DiatonicPitch(3, 'b'), Duration(1, 8)) c1 = Note(DiatonicPitch(4, 'd'), Duration(1, 8)) d1 = Note(DiatonicPitch(3, 'd'), Duration(1, 8)) e1 = Note(DiatonicPitch(3, 'e'), Duration(1, 8)) beam = Beam([b1, tuplet, c1, sub_beam, d1, e1]) b1.tie() d.tie() c1.tie() a1.tie() AbstractNote.print_structure(beam) beam.reverse() AbstractNote.print_structure(beam) assert a.is_tied_to and a.tied_to == b1 assert b1.is_tied_from and b1.tied_from == a assert c1.is_tied_to and c1.tied_to == d assert d.is_tied_from and d.tied_from == c1 assert e.is_tied_to and e.tied_to == c1 assert c1.is_tied_from and c1.tied_from == e assert d1.is_tied_to and d1.tied_to == a1 assert a1.is_tied_from and a1.tied_from == d1