def test_Mutation_copy_06(): staff = abjad.Staff("abj: | 2/8 c'8 d'8 || 2/8 e'8 f'8 |" "| 2/8 g'8 a'8 || 2/8 b'8 c''8 |") leaves = abjad.select(staff).leaves() abjad.beam(leaves) abjad.slur(leaves) assert format(staff) == abjad.String.normalize(r""" \new Staff { { \time 2/8 c'8 [ ( d'8 } { \time 2/8 e'8 f'8 } { \time 2/8 g'8 a'8 } { \time 2/8 b'8 c''8 ) ] } } """), print(format(staff)) result = abjad.mutate(leaves[:6]).copy() new_staff = abjad.Staff(result) assert format(new_staff) == abjad.String.normalize(r""" \new Staff { \time 2/8 c'8 [ ( d'8 \time 2/8 e'8 f'8 \time 2/8 g'8 a'8 } """), print(format(new_staff)) assert abjad.inspect(staff).wellformed() assert abjad.inspect(new_staff).wellformed()
def test_Inspection_indicators_01(): staff = abjad.Staff("c'8 d'8 e'8 f'8") abjad.slur(staff[:]) command_1 = abjad.LilyPondLiteral(r"\slurDotted") abjad.attach(command_1, staff[0]) command_2 = abjad.LilyPondLiteral(r"\slurUp") abjad.attach(command_2, staff[0]) assert format(staff) == abjad.String.normalize(r""" \new Staff { \slurDotted \slurUp c'8 ( d'8 e'8 f'8 ) } """), format(staff) indicators = abjad.inspect(staff[0]).indicators(abjad.LilyPondLiteral) assert command_1 in indicators assert command_2 in indicators assert len(indicators) == 2
def test_Leaf__split_by_durations_17(): """ Split one leaf in score. Ties after split. """ staff = abjad.Staff() staff.append(abjad.Container("c'8 d'8")) staff.append(abjad.Container("e'8 f'8")) leaves = abjad.select(staff).leaves() abjad.beam(leaves[:2]) abjad.beam(leaves[-2:]) abjad.slur(leaves) assert format(staff) == abjad.String.normalize(r""" \new Staff { { c'8 [ ( d'8 ] } { e'8 [ f'8 ) ] } } """), print(format(staff)) new_leaves = leaves[0]._split_by_durations([abjad.Duration(1, 32)], tie_split_notes=True) assert format(staff) == abjad.String.normalize(r""" \new Staff { { c'32 [ ( ~ c'16. d'8 ] } { e'8 [ f'8 ) ] } } """), print(format(staff)) assert abjad.inspect(staff).wellformed()
def test_LilyPondParser__spanners__Slur_01(): """ Successful slurs, showing single leaf overlap. """ maker = abjad.NoteMaker() target = abjad.Container(maker([0] * 4, [(1, 4)])) abjad.slur(target[2:]) abjad.slur(target[:3]) assert format(target) == abjad.String.normalize( r""" { c'4 ( c'4 c'4 ) ( c'4 ) } """ ) parser = abjad.parser.LilyPondParser() result = parser(format(target)) assert format(target) == format(result) and target is not result
def test_LilyPondParser__spanners__Slur_02(): """ Swapped start and stop. """ maker = abjad.NoteMaker() target = abjad.Container(maker([0] * 4, [(1, 4)])) abjad.slur(target[2:]) abjad.slur(target[:3]) assert format(target) == abjad.String.normalize( r""" { c'4 ( c'4 c'4 ) ( c'4 ) } """ ) string = r"\relative c' { c ( c c () c ) }" parser = abjad.parser.LilyPondParser() result = parser(string) assert format(target) == format(result) and target is not result
def test_LilyPondParser__spanners__Slur_07(): """ With direction. """ maker = abjad.NoteMaker() target = abjad.Container(maker([0] * 4, [(1, 4)])) start_slur = abjad.StartSlur(direction=abjad.Down) abjad.slur(target[:3], start_slur=start_slur) start_slur = abjad.StartSlur(direction=abjad.Up) abjad.slur(target[2:], start_slur=start_slur) assert format(target) == abjad.String.normalize( r""" { c'4 _ ( c'4 c'4 ) ^ ( c'4 ) } """ ) parser = abjad.parser.LilyPondParser() result = parser(format(target)) assert format(target) == format(result) and target is not result
def test_Inspection_indicators_02(): staff = abjad.Staff("c'8 d'8 e'8 f'8") abjad.slur(staff[:]) comment = abjad.LilyPondComment("beginning of note content") abjad.attach(comment, staff[0]) command = abjad.LilyPondLiteral(r"\slurDotted") abjad.attach(command, staff[0]) assert format(staff) == abjad.String.normalize( r""" \new Staff { % beginning of note content \slurDotted c'8 ( d'8 e'8 f'8 ) } """ ), format(staff) items = abjad.inspect(staff[0]).indicators() assert comment in items assert command in items assert len(items) == 3
def test_Inspection_indicators_01(): staff = abjad.Staff("c'8 d'8 e'8 f'8") abjad.slur(staff[:]) command_1 = abjad.LilyPondLiteral(r"\slurDotted") abjad.attach(command_1, staff[0]) command_2 = abjad.LilyPondLiteral(r"\slurUp") abjad.attach(command_2, staff[0]) assert format(staff) == abjad.String.normalize( r""" \new Staff { \slurDotted \slurUp c'8 ( d'8 e'8 f'8 ) } """ ), format(staff) indicators = abjad.inspect(staff[0]).indicators(abjad.LilyPondLiteral) assert command_1 in indicators assert command_2 in indicators assert len(indicators) == 2
def test_Inspection_indicators_02(): staff = abjad.Staff("c'8 d'8 e'8 f'8") abjad.slur(staff[:]) comment = abjad.LilyPondComment("beginning of note content") abjad.attach(comment, staff[0]) command = abjad.LilyPondLiteral(r"\slurDotted") abjad.attach(command, staff[0]) assert format(staff) == abjad.String.normalize(r""" \new Staff { % beginning of note content \slurDotted c'8 ( d'8 e'8 f'8 ) } """), format(staff) items = abjad.inspect(staff[0]).indicators() assert comment in items assert command in items assert len(items) == 3
def test_Leaf__split_by_durations_16(): staff = abjad.Staff() staff.append(abjad.Container("c'8 d'8")) staff.append(abjad.Container("e'8 f'8")) leaves = abjad.select(staff).leaves() abjad.beam(leaves[:2]) abjad.beam(leaves[-2:]) abjad.slur(leaves) assert format(staff) == abjad.String.normalize( r""" \new Staff { { c'8 [ ( d'8 ] } { e'8 [ f'8 ) ] } } """ ), print(format(staff)) new_leaves = leaves[0]._split_by_durations( [abjad.Duration(1, 32)], tie_split_notes=False ) assert format(staff) == abjad.String.normalize( r""" \new Staff { { c'32 [ ( c'16. d'8 ] } { e'8 [ f'8 ) ] } } """ ), print(format(staff)) assert abjad.inspect(staff).wellformed()
def test_LilyPondParser__spanners__Slur_01(): """ Successful slurs, showing single leaf overlap. """ maker = abjad.NoteMaker() target = abjad.Container(maker([0] * 4, [(1, 4)])) abjad.slur(target[2:]) abjad.slur(target[:3]) assert format(target) == abjad.String.normalize(r""" { c'4 ( c'4 c'4 ) ( c'4 ) } """) parser = abjad.parser.LilyPondParser() result = parser(format(target)) assert format(target) == format(result) and target is not result
def test_LilyPondParser__spanners__Slur_02(): """ Swapped start and stop. """ maker = abjad.NoteMaker() target = abjad.Container(maker([0] * 4, [(1, 4)])) abjad.slur(target[2:]) abjad.slur(target[:3]) assert format(target) == abjad.String.normalize(r""" { c'4 ( c'4 c'4 ) ( c'4 ) } """) string = r"\relative c' { c ( c c () c ) }" parser = abjad.parser.LilyPondParser() result = parser(string) assert format(target) == format(result) and target is not result
def test_LilyPondParser__spanners__Slur_07(): """ With direction. """ maker = abjad.NoteMaker() target = abjad.Container(maker([0] * 4, [(1, 4)])) start_slur = abjad.StartSlur(direction=abjad.Down) abjad.slur(target[:3], start_slur=start_slur) start_slur = abjad.StartSlur(direction=abjad.Up) abjad.slur(target[2:], start_slur=start_slur) assert format(target) == abjad.String.normalize(r""" { c'4 _ ( c'4 c'4 ) ^ ( c'4 ) } """) parser = abjad.parser.LilyPondParser() result = parser(format(target)) assert format(target) == format(result) and target is not result
def test_Mutation_fuse_08(): """ Fuses fixed-multiplier tuplets with same multiplier in score. """ tuplet_1 = abjad.Tuplet(abjad.Multiplier(2, 3), "c'8 d'8 e'8") abjad.beam(tuplet_1[:]) tuplet_2 = abjad.Tuplet(abjad.Multiplier(2, 3), "c'8 d'8 e'8 f'8 g'8") abjad.slur(tuplet_2[:]) voice = abjad.Voice([tuplet_1, tuplet_2]) assert format(voice) == abjad.String.normalize(r""" \new Voice { \times 2/3 { c'8 [ d'8 e'8 ] } \tweak edge-height #'(0.7 . 0) \times 2/3 { c'8 ( d'8 e'8 f'8 g'8 ) } } """), print(format(voice)) tuplets = voice[:] abjad.mutate(tuplets).fuse() assert format(voice) == abjad.String.normalize(r""" \new Voice { \tweak edge-height #'(0.7 . 0) \times 2/3 { c'8 [ d'8 e'8 ] c'8 ( d'8 e'8 f'8 g'8 ) } } """), print(format(voice)) assert abjad.inspect(voice).wellformed()
def test_mutate__split_leaf_by_durations_10(): """ Split one leaf in score. Ties after split. """ staff = abjad.Staff() staff.append(abjad.Container("c'8 d'8")) staff.append(abjad.Container("e'8 f'8")) leaves = abjad.select(staff).leaves() abjad.beam(leaves[:2]) abjad.beam(leaves[-2:]) abjad.slur(leaves) assert abjad.lilypond(staff) == abjad.String.normalize(r""" \new Staff { { c'8 [ ( d'8 ] } { e'8 [ f'8 ) ] } } """), print(abjad.lilypond(staff)) abjad.mutate._split_leaf_by_durations(leaves[0], [abjad.Duration(1, 32)]) assert abjad.lilypond(staff) == abjad.String.normalize(r""" \new Staff { { c'32 [ ( ~ c'16. d'8 ] } { e'8 [ f'8 ) ] } } """), print(abjad.lilypond(staff)) assert abjad.wf.wellformed(staff)
def test_Container__split_by_duration_01(): staff = abjad.Staff() staff.append(abjad.Container("c'8 d'8")) staff.append(abjad.Container("e'8 f'8")) leaves = abjad.select(staff).leaves() abjad.beam(leaves[:2]) abjad.beam(leaves[-2:]) abjad.slur(leaves) assert format(staff) == abjad.String.normalize(r""" \new Staff { { c'8 [ ( d'8 ] } { e'8 [ f'8 ) ] } } """), print(format(staff)) halves = staff[0]._split_by_duration( abjad.Duration(1, 32), tie_split_notes=False, ) assert format(staff) == abjad.String.normalize(r""" \new Staff { { c'32 [ ( } { c'16. d'8 ] } { e'8 [ f'8 ) ] } } """), print(format(staff)) assert abjad.inspect(staff).wellformed()
def test_Mutation_fuse_06(): """ Fuses two unincorporated tuplets with same multiplier. """ tuplet_1 = abjad.Tuplet((2, 3), "c'8 d'8 e'8") abjad.beam(tuplet_1[:]) tuplet_2 = abjad.Tuplet((2, 3), "c'16 d'16 e'16") abjad.slur(tuplet_2[:]) assert format(tuplet_1) == abjad.String.normalize( r""" \times 2/3 { c'8 [ d'8 e'8 ] } """ ), print(format(tuplet_1)) assert format(tuplet_2) == abjad.String.normalize( r""" \times 2/3 { c'16 ( d'16 e'16 ) } """ ), print(format(tuplet_2)) tuplets = abjad.select([tuplet_1, tuplet_2]) new = abjad.mutate(tuplets).fuse() assert format(new) == abjad.String.normalize( r""" \times 2/3 { c'8 [ d'8 e'8 ] c'16 ( d'16 e'16 ) } """ ), print(format(new)) assert len(tuplet_1) == 0 assert len(tuplet_2) == 0 assert new is not tuplet_1 and new is not tuplet_2 assert abjad.inspect(new).wellformed()
def test_Mutation_fuse_07(): """ Fuses tuplets with same multiplier in score. """ tuplet_1 = abjad.Tuplet((2, 3), "c'8 d'8 e'8") abjad.beam(tuplet_1[:]) tuplet_2 = abjad.Tuplet((2, 3), "c'16 d'16 e'16") abjad.slur(tuplet_2[:]) voice = abjad.Voice([tuplet_1, tuplet_2]) assert format(voice) == abjad.String.normalize( r""" \new Voice { \times 2/3 { c'8 [ d'8 e'8 ] } \times 2/3 { c'16 ( d'16 e'16 ) } } """ ), print(format(voice)) tuplets = voice[:] abjad.mutate(tuplets).fuse() assert format(voice) == abjad.String.normalize( r""" \new Voice { \times 2/3 { c'8 [ d'8 e'8 ] c'16 ( d'16 e'16 ) } } """ ), print(format(voice)) assert abjad.inspect(voice).wellformed()
def test_Mutation_split_14(): """ Cyclically splits all components in container. """ voice = abjad.Voice([abjad.Container("c'8 d'8 e'8 f'8")]) leaves = abjad.select(voice).leaves() abjad.beam(leaves) abjad.slur(leaves) assert format(voice) == abjad.String.normalize( r""" \new Voice { { c'8 [ ( d'8 e'8 f'8 ) ] } } """ ), print(format(voice)) container = voice[0] abjad.mutate(container).split([abjad.Duration(1, 8)], cyclic=True) assert format(voice) == abjad.String.normalize( r""" \new Voice { { c'8 [ ( } { d'8 } { e'8 } { f'8 ) ] } } """ ), print(format(voice)) assert abjad.inspect(voice).wellformed()
def test_Mutation_copy_03(): """ Three notes crossing measure boundaries. """ staff = abjad.Staff("abj: | 2/8 c'8 d'8 || 2/8 e'8 f'8 || 2/8 g'8 a'8 |") leaves = abjad.select(staff).leaves() abjad.slur(leaves) abjad.trill_spanner(leaves) abjad.beam(leaves) assert format(staff) == abjad.String.normalize(r""" \new Staff { { \time 2/8 c'8 ( \startTrillSpan [ d'8 } { \time 2/8 e'8 f'8 } { \time 2/8 g'8 a'8 ) \stopTrillSpan ] } } """), print(format(staff)) result = abjad.mutate(leaves[-3:]).copy() new = abjad.Staff(result) assert format(new) == abjad.String.normalize(r""" \new Staff { f'8 \time 2/8 g'8 a'8 ) \stopTrillSpan ] } """), print(format(new)) assert abjad.inspect(staff).wellformed() assert abjad.inspect(new).wellformed()
def test_Container_extend_08(): """ Extend container with partial and spanned contents of other container. Covered span comes with components from donor container. """ voice_1 = abjad.Voice("c'8 d'8") abjad.beam(voice_1[:]) voice_2 = abjad.Voice("c'8 d'8 e'8 f'8") abjad.beam(voice_2[:]) abjad.slur(voice_2[-2:]) assert format(voice_2) == abjad.String.normalize(r""" \new Voice { c'8 [ d'8 e'8 ( f'8 ) ] } """), print(format(voice_2)) voice_1.extend(voice_2[-2:]) assert format(voice_1) == abjad.String.normalize(r""" \new Voice { c'8 [ d'8 ] e'8 ( f'8 ) ] } """), print(format(voice_1)) assert abjad.inspect(voice_1).wellformed() assert format(voice_2) == abjad.String.normalize(r""" \new Voice { c'8 [ d'8 } """), print(format(voice_2)) assert abjad.inspect(voice_2).wellformed()
def test_Mutation_split_19(): """ Cyclically splits all components in container. """ voice = abjad.Voice([abjad.Container("c'8 d'8 e'8 f'8")]) leaves = abjad.select(voice).leaves() abjad.beam(leaves) abjad.slur(leaves) assert format(voice) == abjad.String.normalize( r""" \new Voice { { c'8 [ ( d'8 e'8 f'8 ) ] } } """ ), print(format(voice)) container = voice[0] result = abjad.mutate(container).split([abjad.Duration(1, 8)], cyclic=True) assert format(voice) == abjad.String.normalize( r""" \new Voice { { c'8 [ ( } { d'8 } { e'8 } { f'8 ) ] } } """ ), print(format(voice)) assert abjad.inspect(voice).wellformed()
def test_Mutation_copy_01(): """ Deep copies components. Returns Python list of copied components. """ staff = abjad.Staff("abj: | 2/8 c'8 d'8 || 2/8 e'8 f'8 || 2/8 g'8 a'8 |") leaves = abjad.select(staff).leaves() abjad.slur(leaves) abjad.trill_spanner(leaves) abjad.beam(leaves) assert format(staff) == abjad.String.normalize(r""" \new Staff { { \time 2/8 c'8 ( \startTrillSpan [ d'8 } { \time 2/8 e'8 f'8 } { \time 2/8 g'8 a'8 ) \stopTrillSpan ] } } """), print(format(staff)) result = abjad.mutate(leaves[2:4]).copy() new = abjad.Staff(result) assert format(new) == abjad.String.normalize( r""" \new Staff { \time 2/8 e'8 f'8 } """, print(format(new)), ) assert abjad.inspect(staff).wellformed() assert abjad.inspect(new).wellformed()
def test_Mutation_fuse_07(): """ Fuses tuplets with same multiplier in score. """ tuplet_1 = abjad.Tuplet((2, 3), "c'8 d'8 e'8") abjad.beam(tuplet_1[:]) tuplet_2 = abjad.Tuplet((2, 3), "c'16 d'16 e'16") abjad.slur(tuplet_2[:]) voice = abjad.Voice([tuplet_1, tuplet_2]) assert format(voice) == abjad.String.normalize(r""" \new Voice { \times 2/3 { c'8 [ d'8 e'8 ] } \times 2/3 { c'16 ( d'16 e'16 ) } } """), print(format(voice)) tuplets = voice[:] abjad.mutate(tuplets).fuse() assert format(voice) == abjad.String.normalize(r""" \new Voice { \times 2/3 { c'8 [ d'8 e'8 ] c'16 ( d'16 e'16 ) } } """), print(format(voice)) assert abjad.inspect(voice).wellformed()
def test_Mutation_fuse_06(): """ Fuses two unincorporated tuplets with same multiplier. """ tuplet_1 = abjad.Tuplet((2, 3), "c'8 d'8 e'8") abjad.beam(tuplet_1[:]) tuplet_2 = abjad.Tuplet((2, 3), "c'16 d'16 e'16") abjad.slur(tuplet_2[:]) assert format(tuplet_1) == abjad.String.normalize(r""" \times 2/3 { c'8 [ d'8 e'8 ] } """), print(format(tuplet_1)) assert format(tuplet_2) == abjad.String.normalize(r""" \times 2/3 { c'16 ( d'16 e'16 ) } """), print(format(tuplet_2)) tuplets = abjad.select([tuplet_1, tuplet_2]) new = abjad.mutate(tuplets).fuse() assert format(new) == abjad.String.normalize(r""" \times 2/3 { c'8 [ d'8 e'8 ] c'16 ( d'16 e'16 ) } """), print(format(new)) assert len(tuplet_1) == 0 assert len(tuplet_2) == 0 assert new is not tuplet_1 and new is not tuplet_2 assert abjad.inspect(new).wellformed()
def test_Container_remove_01(): """ Containers remove leaves correctly. Leaf abjad.detaches from parentage. Leaf returns after removal. """ voice = abjad.Voice("c'8 d'8 e'8 f'8") abjad.slur(voice[:]) abjad.beam(voice[1:2], beam_lone_notes=True) assert format(voice) == abjad.String.normalize( r""" \new Voice { c'8 ( d'8 [ ] e'8 f'8 ) } """ ) note = voice[1] voice.remove(note) assert format(voice) == abjad.String.normalize( r""" \new Voice { c'8 ( e'8 f'8 ) } """ ) "Note is now d'8 [ ]" assert format(note) == "d'8\n[\n]" assert abjad.inspect(voice).wellformed() assert abjad.inspect(note).wellformed()
def test_Container_remove_01(): """ Containers remove leaves correctly. Leaf abjad.detaches from parentage. Leaf returns after removal. """ voice = abjad.Voice("c'8 d'8 e'8 f'8") abjad.slur(voice[:]) abjad.beam(voice[1:2], beam_lone_notes=True) assert format(voice) == abjad.String.normalize( r""" \new Voice { c'8 ( d'8 [ ] e'8 f'8 ) } """ ) note = voice[1] voice.remove(note) assert format(voice) == abjad.String.normalize( r""" \new Voice { c'8 ( e'8 f'8 ) } """ ) "Note is now d'8 [ ]" assert format(note) == "d'8\n[\n]" assert abjad.inspect(voice).wellformed() assert abjad.inspect(note).wellformed()
def test_Container_pop_01(): """ Containers pop leaves correctly. Popped leaves abjad.detach from parent. """ voice = abjad.Voice("c'8 d'8 e'8 f'8") abjad.slur(voice[:]) abjad.beam(voice[1:2], beam_lone_notes=True) assert format(voice) == abjad.String.normalize( r""" \new Voice { c'8 ( d'8 [ ] e'8 f'8 ) } """ ), print(format(voice)) result = voice.pop(1) assert format(voice) == abjad.String.normalize( r""" \new Voice { c'8 ( e'8 f'8 ) } """ ), print(format(voice)) assert abjad.inspect(voice).wellformed() "Result is now d'8 [ ]" assert abjad.inspect(result).wellformed() assert format(result) == "d'8\n[\n]"
def test_Mutation_fuse_10(): tuplet_1 = abjad.Tuplet((2, 3), "c'8") tuplet_2 = abjad.Tuplet((2, 3), "c'4") voice = abjad.Voice([tuplet_1, tuplet_2, abjad.Note("c'4")]) leaves = abjad.select(voice).leaves() abjad.slur(leaves) assert format(voice) == abjad.String.normalize( r""" \new Voice { \tweak edge-height #'(0.7 . 0) \times 2/3 { c'8 ( } \tweak edge-height #'(0.7 . 0) \times 2/3 { c'4 } c'4 ) } """ ), print(format(voice)) tuplets = voice[:2] abjad.mutate(tuplets).fuse() assert format(voice) == abjad.String.normalize( r""" \new Voice { \times 2/3 { c'8 ( c'4 } c'4 ) } """ ), print(format(voice)) assert abjad.inspect(voice).wellformed()
def test_Mutation_fuse_10(): tuplet_1 = abjad.Tuplet((2, 3), "c'8") tuplet_2 = abjad.Tuplet((2, 3), "c'4") voice = abjad.Voice([tuplet_1, tuplet_2, abjad.Note("c'4")]) leaves = abjad.select(voice).leaves() abjad.slur(leaves) assert format(voice) == abjad.String.normalize(r""" \new Voice { \tweak edge-height #'(0.7 . 0) \times 2/3 { c'8 ( } \tweak edge-height #'(0.7 . 0) \times 2/3 { c'4 } c'4 ) } """), print(format(voice)) tuplets = voice[:2] abjad.mutate(tuplets).fuse() assert format(voice) == abjad.String.normalize(r""" \new Voice { \times 2/3 { c'8 ( c'4 } c'4 ) } """), print(format(voice)) assert abjad.inspect(voice).wellformed()
def make_desordre_cell(pitches): """ Makes a Désordre cell. """ notes = [abjad.Note(pitch, (1, 8)) for pitch in pitches] notes = abjad.Selection(notes) abjad.beam(notes) abjad.slur(notes) clef = abjad.Dynamic("f") abjad.attach(clef, notes[0]) dynamic = abjad.Dynamic("p") abjad.attach(dynamic, notes[1]) # make the lower voice lower_voice = abjad.Voice(notes) lower_voice.name = "RH Lower Voice" command = abjad.LilyPondLiteral(r"\voiceTwo") abjad.attach(command, lower_voice) n = int(math.ceil(len(pitches) / 2.0)) chord = abjad.Chord([pitches[0], pitches[0] + 12], (n, 8)) articulation = abjad.Articulation(">") abjad.attach(articulation, chord) # make the upper voice upper_voice = abjad.Voice([chord]) upper_voice.name = "RH Upper Voice" command = abjad.LilyPondLiteral(r"\voiceOne") abjad.attach(command, upper_voice) # combine them together container = abjad.Container([lower_voice, upper_voice]) container.is_simultaneous = True # make all 1/8 beats breakable leaves = abjad.select(lower_voice).leaves() for leaf in leaves[:-1]: bar_line = abjad.BarLine("") abjad.attach(bar_line, leaf) return container
def make_desordre_cell(pitches): """ Makes a Désordre cell. """ notes = [abjad.Note(pitch, (1, 8)) for pitch in pitches] notes = abjad.Selection(notes) abjad.beam(notes) abjad.slur(notes) clef = abjad.Dynamic('f') abjad.attach(clef, notes[0]) dynamic = abjad.Dynamic('p') abjad.attach(dynamic, notes[1]) # make the lower voice lower_voice = abjad.Voice(notes) lower_voice.name = 'RH Lower Voice' command = abjad.LilyPondLiteral(r'\voiceTwo') abjad.attach(command, lower_voice) n = int(math.ceil(len(pitches) / 2.)) chord = abjad.Chord([pitches[0], pitches[0] + 12], (n, 8)) articulation = abjad.Articulation('>') abjad.attach(articulation, chord) # make the upper voice upper_voice = abjad.Voice([chord]) upper_voice.name = 'RH Upper Voice' command = abjad.LilyPondLiteral(r'\voiceOne') abjad.attach(command, upper_voice) # combine them together container = abjad.Container([lower_voice, upper_voice]) container.is_simultaneous = True # make all 1/8 beats breakable leaves = abjad.select(lower_voice).leaves() for leaf in leaves[:-1]: bar_line = abjad.BarLine('') abjad.attach(bar_line, leaf) return container
def make_desordre_cell(pitches): """ Makes a Désordre cell. """ notes = [abjad.Note(pitch, (1, 8)) for pitch in pitches] notes = abjad.Selection(notes) abjad.beam(notes) abjad.slur(notes) abjad.attach(abjad.Dynamic("f"), notes[0]) abjad.attach(abjad.Dynamic("p"), notes[1]) # make the lower voice lower_voice = abjad.Voice(notes) lower_voice.name = "RH_Lower_Voice" command = abjad.LilyPondLiteral(r"\voiceTwo") abjad.attach(command, lower_voice) n = int(math.ceil(len(pitches) / 2.0)) chord = abjad.Chord([pitches[0], pitches[0] + 12], (n, 8)) abjad.attach(abjad.Articulation(">"), chord) # make the upper voice upper_voice = abjad.Voice([chord]) upper_voice.name = "RH_Upper_Voice" command = abjad.LilyPondLiteral(r"\voiceOne") abjad.attach(command, upper_voice) # combine them together voices = [lower_voice, upper_voice] container = abjad.Container(voices, simultaneous=True) # make all 1/8 beats breakable leaves = abjad.select(lower_voice).leaves() for leaf in leaves[:-1]: bar_line = abjad.BarLine("") abjad.attach(bar_line, leaf) return container
def test_Mutation_split_08(): """ Cyclically splits measure in score. """ staff = abjad.Staff(r"abj: | 2/8 c'8 d'8 || 2/8 e'8 f'8 |") leaves = abjad.select(staff).leaves() abjad.beam(leaves[:2]) abjad.beam(leaves[-2:]) abjad.slur(leaves) assert format(staff) == abjad.String.normalize( r""" \new Staff { { \time 2/8 c'8 [ ( d'8 ] } { \time 2/8 e'8 [ f'8 ) ] } } """ ), print(format(staff)) measures = staff[:1] result = abjad.mutate(measures).split( [abjad.Duration(1, 16)], cyclic=True, tie_split_notes=True ) assert format(staff) == abjad.String.normalize( r""" \new Staff { { \time 2/8 c'16 [ ( ~ } { c'16 } { d'16 ~ } { d'16 ] } { \time 2/8 e'8 [ f'8 ) ] } } """ ), print(format(staff)) assert abjad.inspect(staff).wellformed() assert len(result) == 4
def test_Container_extend_08(): """ Extend container with partial and spanned contents of other container. Covered span comes with components from donor container. """ voice_1 = abjad.Voice("c'8 d'8") abjad.beam(voice_1[:]) voice_2 = abjad.Voice("c'8 d'8 e'8 f'8") abjad.beam(voice_2[:]) abjad.slur(voice_2[-2:]) assert format(voice_2) == abjad.String.normalize( r""" \new Voice { c'8 [ d'8 e'8 ( f'8 ) ] } """ ), print(format(voice_2)) voice_1.extend(voice_2[-2:]) assert format(voice_1) == abjad.String.normalize( r""" \new Voice { c'8 [ d'8 ] e'8 ( f'8 ) ] } """ ), print(format(voice_1)) assert abjad.inspect(voice_1).wellformed() assert format(voice_2) == abjad.String.normalize( r""" \new Voice { c'8 [ d'8 } """ ), print(format(voice_2)) assert abjad.inspect(voice_2).wellformed()
def test_Mutation_split_01(): """ Cyclically splits note in score. """ staff = abjad.Staff() staff.append(abjad.Container("c'8 d'8")) staff.append(abjad.Container("e'8 f'8")) leaves = abjad.select(staff).leaves() abjad.beam(leaves[:2]) abjad.beam(leaves[-2:]) abjad.slur(leaves) assert format(staff) == abjad.String.normalize( r""" \new Staff { { c'8 [ ( d'8 ] } { e'8 [ f'8 ) ] } } """ ), print(format(staff)) notes = staff[0][1:2] result = abjad.mutate(notes).split([abjad.Duration(3, 64)], cyclic=True) assert format(staff) == abjad.String.normalize( r""" \new Staff { { c'8 [ ( d'32. ~ d'32. ~ d'32 ] } { e'8 [ f'8 ) ] } } """ ), print(format(staff)) assert abjad.inspect(staff).wellformed() assert len(result) == 3
def test_mutate_split_13(): """ Splits cyclically. """ voice = abjad.Voice([abjad.Container("c'8 d'8 e'8 f'8 g'8 a'8 b'8 c''8")]) leaves = abjad.select(voice).leaves() abjad.beam(leaves) abjad.slur(leaves) assert abjad.lilypond(voice) == abjad.String.normalize(r""" \new Voice { { c'8 [ ( d'8 e'8 f'8 g'8 a'8 b'8 c''8 ) ] } } """), print(abjad.lilypond(voice)) note = voice[0] abjad.mutate.split( note, [abjad.Duration(1, 8), abjad.Duration(3, 8)], cyclic=True) assert abjad.lilypond(voice) == abjad.String.normalize(r""" \new Voice { { c'8 [ ( } { d'8 e'8 f'8 } { g'8 } { a'8 b'8 c''8 ) ] } } """), print(abjad.lilypond(voice)) assert abjad.wf.wellformed(voice)
def test_Mutation_split_18(): """ Splits cyclically. """ voice = abjad.Voice([abjad.Container("c'8 d'8 e'8 f'8 g'8 a'8 b'8 c''8")]) leaves = abjad.select(voice).leaves() abjad.beam(leaves) abjad.slur(leaves) assert format(voice) == abjad.String.normalize( r""" \new Voice { { c'8 [ ( d'8 e'8 f'8 g'8 a'8 b'8 c''8 ) ] } } """ ), print(format(voice)) note = voice[0] result = abjad.mutate(note).split( [abjad.Duration(1, 8), abjad.Duration(3, 8)], cyclic=True ) assert format(voice) == abjad.String.normalize( r""" \new Voice { { c'8 [ ( } { d'8 e'8 f'8 } { g'8 } { a'8 b'8 c''8 ) ] } } """ ), print(format(voice)) assert abjad.inspect(voice).wellformed()
def test_Container__split_by_duration_04(): """ Split in-score container at split offset with non-power-of-two denominator. Does not tie leaves after split. """ staff = abjad.Staff() staff.append(abjad.Container("c'8 d'8")) staff.append(abjad.Container("e'8 f'8")) leaves = abjad.select(staff).leaves() abjad.beam(leaves[:2]) abjad.beam(leaves[-2:]) abjad.slur(leaves) assert format(staff) == abjad.String.normalize( r""" \new Staff { { c'8 [ ( d'8 ] } { e'8 [ f'8 ) ] } } """ ), print(format(staff)) halves = staff[0]._split_by_duration( abjad.Duration(1, 5), tie_split_notes=True ) assert format(staff) == abjad.String.normalize( r""" \new Staff { { c'8 [ ( } { \times 4/5 { d'16. ~ d'16 ] } } { e'8 [ f'8 ) ] } } """ ), print(format(staff)) assert abjad.inspect(staff).wellformed()
def test_mutate_split_02(): """ Cyclically splits consecutive notes in score. """ staff = abjad.Staff([abjad.Container("c'8 d'"), abjad.Container("e'8 f'")]) for container in staff: time_signature = abjad.TimeSignature((2, 8)) abjad.attach(time_signature, container[0]) leaves = abjad.select(staff).leaves() abjad.beam(leaves[:2]) abjad.beam(leaves[-2:]) abjad.slur(leaves) assert abjad.lilypond(staff) == abjad.String.normalize(r""" \new Staff { { \time 2/8 c'8 [ ( d'8 ] } { \time 2/8 e'8 [ f'8 ) ] } } """), print(abjad.lilypond(staff)) result = abjad.mutate.split(leaves, [abjad.Duration(3, 32)], cyclic=True) assert abjad.lilypond(staff) == abjad.String.normalize(r""" \new Staff { { \time 2/8 c'16. [ ( ~ c'32 d'16 ~ d'16 ] } { \time 2/8 e'32 [ ~ e'16. f'16. ~ f'32 ) ] } } """), print(abjad.lilypond(staff)) assert abjad.wf.wellformed(staff) assert len(result) == 6
def test_Mutation_fuse_08(): """ Fuses fixed-multiplier tuplets with same multiplier in score. """ tuplet_1 = abjad.Tuplet(abjad.Multiplier(2, 3), "c'8 d'8 e'8") abjad.beam(tuplet_1[:]) tuplet_2 = abjad.Tuplet(abjad.Multiplier(2, 3), "c'8 d'8 e'8 f'8 g'8") abjad.slur(tuplet_2[:]) voice = abjad.Voice([tuplet_1, tuplet_2]) assert format(voice) == abjad.String.normalize( r""" \new Voice { \times 2/3 { c'8 [ d'8 e'8 ] } \tweak edge-height #'(0.7 . 0) \times 2/3 { c'8 ( d'8 e'8 f'8 g'8 ) } } """ ), print(format(voice)) tuplets = voice[:] abjad.mutate(tuplets).fuse() assert format(voice) == abjad.String.normalize( r""" \new Voice { \tweak edge-height #'(0.7 . 0) \times 2/3 { c'8 [ d'8 e'8 ] c'8 ( d'8 e'8 f'8 g'8 ) } } """ ), print(format(voice)) assert abjad.inspect(voice).wellformed()
def test_mutate_split_05(): """ Cyclically splits measure in score. """ staff = abjad.Staff([abjad.Container("c'8 d'"), abjad.Container("e'8 f'")]) for container in staff: time_signature = abjad.TimeSignature((2, 8)) abjad.attach(time_signature, container[0]) leaves = abjad.select(staff).leaves() abjad.beam(leaves[:2]) abjad.beam(leaves[-2:]) abjad.slur(leaves) assert abjad.lilypond(staff) == abjad.String.normalize(r""" \new Staff { { \time 2/8 c'8 [ ( d'8 ] } { \time 2/8 e'8 [ f'8 ) ] } } """), print(abjad.lilypond(staff)) measures = staff[:1] result = abjad.mutate.split(measures, [abjad.Duration(1, 16)], cyclic=True) assert abjad.lilypond(staff) == abjad.String.normalize(r""" \new Staff { { \time 2/8 c'16 [ ( ~ } { c'16 } { d'16 ~ } { d'16 ] } { \time 2/8 e'8 [ f'8 ) ] } } """), print(abjad.lilypond(staff)) assert abjad.wf.wellformed(staff) assert len(result) == 4
def test_Mutation_split_08(): """ Cyclically splits measure in score. """ staff = abjad.Staff(r"abj: | 2/8 c'8 d'8 || 2/8 e'8 f'8 |") leaves = abjad.select(staff).leaves() abjad.beam(leaves[:2]) abjad.beam(leaves[-2:]) abjad.slur(leaves) assert format(staff) == abjad.String.normalize(r""" \new Staff { { \time 2/8 c'8 [ ( d'8 ] } { \time 2/8 e'8 [ f'8 ) ] } } """), print(format(staff)) measures = staff[:1] result = abjad.mutate(measures).split( [abjad.Duration(1, 16)], cyclic=True, tie_split_notes=True, ) assert format(staff) == abjad.String.normalize(r""" \new Staff { { \time 2/8 c'16 [ ( ~ } { c'16 } { d'16 ~ } { d'16 ] } { \time 2/8 e'8 [ f'8 ) ] } } """), print(format(staff)) assert abjad.inspect(staff).wellformed() assert len(result) == 4
def test_Container___setitem___08(): r""" Replaces note in one score with container from another score. """ notes = [ abjad.Note("c'8"), abjad.Note("d'8"), abjad.Note("e'8"), abjad.Note("f'8"), abjad.Note("g'8"), abjad.Note("a'8"), abjad.Note("b'8"), ] voice_1 = abjad.Voice(notes[:3]) abjad.beam(voice_1[:]) assert abjad.lilypond(voice_1) == abjad.String.normalize(r""" \new Voice { c'8 [ d'8 e'8 ] } """), print(abjad.lilypond(voice_1)) voice_2 = abjad.Voice(notes[3:]) abjad.mutate.wrap(voice_2[1:3], abjad.Container()) leaves = abjad.select(voice_2).leaves() leaves = abjad.select(voice_2[1]).leaves() abjad.slur(leaves) assert abjad.lilypond(voice_2) == abjad.String.normalize(r""" \new Voice { f'8 { g'8 ( a'8 ) } b'8 } """), print(abjad.lilypond(voice_2)) voice_1[1] = voice_2[1] assert abjad.lilypond(voice_1) == abjad.String.normalize(r""" \new Voice { c'8 [ { g'8 ( a'8 ) } e'8 ] } """), print(abjad.lilypond(voice_1)) assert abjad.wf.wellformed(voice_1) assert abjad.lilypond(voice_2) == abjad.String.normalize(r""" \new Voice { f'8 b'8 } """), print(abjad.lilypond(voice_2)) assert abjad.wf.wellformed(voice_2)
def test_Mutation_split_02(): """ Cyclically splits consecutive notes in score. """ staff = abjad.Staff(r"abj: | 2/8 c'8 d'8 || 2/8 e'8 f'8 |") leaves = abjad.select(staff).leaves() abjad.beam(leaves[:2]) abjad.beam(leaves[-2:]) abjad.slur(leaves) assert format(staff) == abjad.String.normalize(r""" \new Staff { { \time 2/8 c'8 [ ( d'8 ] } { \time 2/8 e'8 [ f'8 ) ] } } """), print(format(staff)) result = abjad.mutate(leaves).split( [abjad.Duration(3, 32)], cyclic=True, ) assert format(staff) == abjad.String.normalize(r""" \new Staff { { \time 2/8 c'16. [ ( ~ c'32 d'16 ~ d'16 ] } { \time 2/8 e'32 [ ~ e'16. f'16. ~ f'32 ) ] } } """), print(format(staff)) assert abjad.inspect(staff).wellformed() assert len(result) == 6
def make_bartok_score(): """ make the Bartok example score. """ # make score skeleton score = abjad.Score() piano_staff = abjad.StaffGroup(lilypond_type="PianoStaff") upper_staff = abjad.Staff([]) lower_staff = abjad.Staff([]) piano_staff.append(upper_staff) piano_staff.append(lower_staff) score.append(piano_staff) # make upper measures upper_measures = [] upper_measures.append(abjad.Container()) upper_measures.append(abjad.Container()) upper_measures.append(abjad.Container()) upper_measures.append(abjad.Container()) upper_measures.append(abjad.Container()) lower_measures = copy.deepcopy(upper_measures) upper_staff.extend(upper_measures) lower_staff.extend(lower_measures) # add leaves to upper measures upper_measures[0].extend("a'8 g'8 f'8 e'8") abjad.attach(abjad.TimeSignature((2, 4)), upper_measures[0][0]) upper_measures[1].extend("d'4 g'8 f'8 e'8 d'8") abjad.attach(abjad.TimeSignature((3, 4)), upper_measures[1][0]) upper_measures[2].extend("c'8 d'16 e'16 f'8 e'8") abjad.attach(abjad.TimeSignature((2, 4)), upper_measures[2][0]) upper_measures[3].append("d'2") upper_measures[4].append("d'2") # add leaves to lower measures lower_measures[0].extend("b4 d'8 c'8") lower_measures[1].extend("b8 a8 af4 c'8 bf8") lower_measures[2].extend("a8 g8 fs8 g16 a16") # make parallel music for measure 4 upper_voice = abjad.Voice("b2", name="upper voice") command = abjad.LilyPondLiteral(r"\voiceOne") abjad.attach(command, upper_voice) lower_voice = abjad.Voice("b4 a4", name="lower voice") command = abjad.LilyPondLiteral(r"\voiceTwo") abjad.attach(command, lower_voice) lower_measures[3].extend([upper_voice, lower_voice]) lower_measures[3].is_simultaneous = True # make parallel music for measure 5 upper_voice = abjad.Voice("b2", name="upper voice") command = abjad.LilyPondLiteral(r"\voiceOne") abjad.attach(command, upper_voice) lower_voice = abjad.Voice("g2", name="lower voice") command = abjad.LilyPondLiteral(r"\voiceTwo") abjad.attach(command, lower_voice) lower_measures[4].extend([upper_voice, lower_voice]) lower_measures[4].is_simultaneous = True # add bass clef clef = abjad.Clef("bass") leaf = abjad.inspect(lower_staff).leaf(0) abjad.attach(clef, leaf) # add dynamics dynamic = abjad.Dynamic("pp") abjad.attach(dynamic, upper_measures[0][0]) dynamic = abjad.Dynamic("mp") abjad.attach(dynamic, upper_measures[1][1]) dynamic = abjad.Dynamic("pp") abjad.attach(dynamic, lower_measures[0][1]) dynamic = abjad.Dynamic("mp") abjad.attach(dynamic, lower_measures[1][3]) # add final bar line score.add_final_bar_line() # select leaves for attaching spanners to upper_leaves = abjad.select(upper_staff).leaves() lower_leaves = abjad.select(lower_staff).leaves() # attach beams abjad.beam(upper_leaves[:4]) abjad.beam(lower_leaves[1:5]) abjad.beam(lower_leaves[6:10]) # attach slurs abjad.slur(upper_leaves[:5]) abjad.slur(upper_leaves[5:]) abjad.slur(lower_leaves[1:6]) # attach hairpins abjad.hairpin("<", upper_leaves[-7:-2]) abjad.hairpin(">", upper_leaves[-2:]) # attach a ritardando with markup start_text_span = abjad.StartTextSpan(left_text=abjad.Markup("ritard.")) abjad.text_spanner(upper_leaves[-7:], start_text_span=start_text_span) # tie notes abjad.tie(upper_leaves[-2:]) # tie more notes note_1 = lower_staff[-2]["upper voice"][0] note_2 = lower_staff[-1]["upper voice"][0] notes = abjad.select([note_1, note_2]) abjad.tie(notes) # return the score return score
def test_Container__split_by_duration_04(): """ Split in-score container at split offset with non-power-of-two denominator. Does not tie leaves after split. """ staff = abjad.Staff() staff.append(abjad.Container("c'8 d'8")) staff.append(abjad.Container("e'8 f'8")) leaves = abjad.select(staff).leaves() abjad.beam(leaves[:2]) abjad.beam(leaves[-2:]) abjad.slur(leaves) assert format(staff) == abjad.String.normalize(r""" \new Staff { { c'8 [ ( d'8 ] } { e'8 [ f'8 ) ] } } """), print(format(staff)) halves = staff[0]._split_by_duration(abjad.Duration(1, 5), tie_split_notes=True) assert format(staff) == abjad.String.normalize(r""" \new Staff { { c'8 [ ( } { \times 4/5 { d'16. ~ d'16 ] } } { e'8 [ f'8 ) ] } } """), print(format(staff)) assert abjad.inspect(staff).wellformed()
def test_Mutation_split_02(): """ Cyclically splits consecutive notes in score. """ staff = abjad.Staff(r"abj: | 2/8 c'8 d'8 || 2/8 e'8 f'8 |") leaves = abjad.select(staff).leaves() abjad.beam(leaves[:2]) abjad.beam(leaves[-2:]) abjad.slur(leaves) assert format(staff) == abjad.String.normalize( r""" \new Staff { { \time 2/8 c'8 [ ( d'8 ] } { \time 2/8 e'8 [ f'8 ) ] } } """ ), print(format(staff)) result = abjad.mutate(leaves).split([abjad.Duration(3, 32)], cyclic=True) assert format(staff) == abjad.String.normalize( r""" \new Staff { { \time 2/8 c'16. [ ( ~ c'32 d'16 ~ d'16 ] } { \time 2/8 e'32 [ ~ e'16. f'16. ~ f'32 ) ] } } """ ), print(format(staff)) assert abjad.inspect(staff).wellformed() assert len(result) == 6
def test_mutate_split_01(): """ Cyclically splits note in score. """ staff = abjad.Staff() staff.append(abjad.Container("c'8 d'8")) staff.append(abjad.Container("e'8 f'8")) leaves = abjad.select(staff).leaves() abjad.beam(leaves[:2]) abjad.beam(leaves[-2:]) abjad.slur(leaves) assert abjad.lilypond(staff) == abjad.String.normalize(r""" \new Staff { { c'8 [ ( d'8 ] } { e'8 [ f'8 ) ] } } """), print(abjad.lilypond(staff)) notes = staff[0][1:2] result = abjad.mutate.split(notes, [abjad.Duration(3, 64)], cyclic=True) assert abjad.lilypond(staff) == abjad.String.normalize(r""" \new Staff { { c'8 [ ( d'32. ~ d'32. ~ d'32 ] } { e'8 [ f'8 ) ] } } """), print(abjad.lilypond(staff)) assert abjad.wf.wellformed(staff) assert len(result) == 3
def test_Mutation_split_11(): """ Force-splits consecutive measures in score. """ staff = abjad.Staff(r"abj: | 2/8 c'8 d'8 || 2/8 e'8 f'8 |") leaves = abjad.select(staff).leaves() abjad.beam(leaves[:2]) abjad.beam(leaves[-2:]) abjad.slur(leaves) assert format(staff) == abjad.String.normalize( r""" \new Staff { { \time 2/8 c'8 [ ( d'8 ] } { \time 2/8 e'8 [ f'8 ) ] } } """ ), print(format(staff)) measures = staff[:] result = abjad.mutate(measures).split( [abjad.Duration(1, 32), abjad.Duration(3, 32), abjad.Duration(5, 32)], cyclic=False, tie_split_notes=False, ) assert format(staff) == abjad.String.normalize( r""" \new Staff { { \time 2/8 c'32 [ ( } { c'16. } { d'8 ] } { \time 2/8 e'32 [ } { e'16. f'8 ) ] } } """ ), print(format(staff)) assert abjad.inspect(staff).wellformed() assert len(result) == 4
def test_Container__split_by_duration_02(): """ Split one container in score. Adds tie after split. """ staff = abjad.Staff() staff.append(abjad.Container("c'8 d'8")) staff.append(abjad.Container("e'8 f'8")) leaves = abjad.select(staff).leaves() abjad.beam(leaves[:2]) abjad.beam(leaves[-2:]) abjad.slur(leaves) assert format(staff) == abjad.String.normalize( r""" \new Staff { { c'8 [ ( d'8 ] } { e'8 [ f'8 ) ] } } """ ), print(format(staff)) halves = staff[0]._split_by_duration( abjad.Duration(1, 32), tie_split_notes=True ) assert format(staff) == abjad.String.normalize( r""" \new Staff { { c'32 [ ( ~ } { c'16. d'8 ] } { e'8 [ f'8 ) ] } } """ ), print(format(staff)) assert abjad.inspect(staff).wellformed()
def test_Mutation_split_11(): """ Force-splits consecutive measures in score. """ staff = abjad.Staff(r"abj: | 2/8 c'8 d'8 || 2/8 e'8 f'8 |") leaves = abjad.select(staff).leaves() abjad.beam(leaves[:2]) abjad.beam(leaves[-2:]) abjad.slur(leaves) assert format(staff) == abjad.String.normalize(r""" \new Staff { { \time 2/8 c'8 [ ( d'8 ] } { \time 2/8 e'8 [ f'8 ) ] } } """), print(format(staff)) measures = staff[:] result = abjad.mutate(measures).split( [abjad.Duration(1, 32), abjad.Duration(3, 32), abjad.Duration(5, 32)], cyclic=False, tie_split_notes=False, ) assert format(staff) == abjad.String.normalize(r""" \new Staff { { \time 2/8 c'32 [ ( } { c'16. } { d'8 ] } { \time 2/8 e'32 [ } { e'16. f'8 ) ] } } """), print(format(staff)) assert abjad.inspect(staff).wellformed() assert len(result) == 4
def test_Container___setitem___08(): r""" Replaces note in one score with container from another score. """ notes = [ abjad.Note("c'8"), abjad.Note("d'8"), abjad.Note("e'8"), abjad.Note("f'8"), abjad.Note("g'8"), abjad.Note("a'8"), abjad.Note("b'8"), ] voice_1 = abjad.Voice(notes[:3]) abjad.beam(voice_1[:]) assert format(voice_1) == abjad.String.normalize( r""" \new Voice { c'8 [ d'8 e'8 ] } """ ), print(format(voice_1)) voice_2 = abjad.Voice(notes[3:]) abjad.mutate(voice_2[1:3]).wrap(abjad.Container()) leaves = abjad.select(voice_2).leaves() leaves = abjad.select(voice_2[1]).leaves() abjad.slur(leaves) assert format(voice_2) == abjad.String.normalize( r""" \new Voice { f'8 { g'8 ( a'8 ) } b'8 } """ ), print(format(voice_2)) voice_1[1] = voice_2[1] assert format(voice_1) == abjad.String.normalize( r""" \new Voice { c'8 [ { g'8 ( a'8 ) } e'8 ] } """ ), print(format(voice_1)) assert abjad.inspect(voice_1).wellformed() assert format(voice_2) == abjad.String.normalize( r""" \new Voice { f'8 b'8 } """ ), print(format(voice_2)) assert abjad.inspect(voice_2).wellformed()