def edit_second_violin_voice(score, durated_reservoir): """ Edits second violin voice. """ voice = score['Second Violin Voice'] descents = durated_reservoir['Second Violin'] last_descent = abjad.Selection(descents[-1]) copied_descent = abjad.mutate(last_descent).copy() copied_descent = list(copied_descent) copied_descent[-1].written_duration = abjad.Duration(1, 1) copied_descent.append(abjad.Note('a2')) for leaf in copied_descent: articulation = abjad.Articulation('accent') abjad.attach(articulation, leaf) articulation = abjad.Articulation('tenuto') abjad.attach(articulation, leaf) voice.extend(copied_descent) final_sustain = [] for _ in range(32): final_sustain.append(abjad.Note('a1.')) final_sustain.append(abjad.Note('a2')) final_sustain = abjad.Selection(final_sustain) articulation = abjad.Articulation('accent') abjad.attach(articulation, final_sustain[0]) articulation = abjad.Articulation('tenuto') abjad.attach(articulation, final_sustain[0]) voice.extend(final_sustain) abjad.tie(final_sustain) voice.extend('r4 r2.')
def test_LilyPondParser__indicators__Articulation_03(): maker = abjad.NoteMaker() target = abjad.Container( maker(["c''", "c''", "b'", "c''"], [(1, 4), (1, 4), (1, 2), (1, 1)])) articulation = abjad.Articulation("staccato") abjad.attach(articulation, target[0]) articulation = abjad.Articulation("mordent") abjad.attach(articulation, target[1]) articulation = abjad.Articulation("turn") abjad.attach(articulation, target[2]) articulation = abjad.Articulation("fermata") abjad.attach(articulation, target[3]) assert format(target) == abjad.String.normalize(r""" { c''4 - \staccato c''4 - \mordent b'2 - \turn c''1 - \fermata } """) string = r"""{ c''4\staccato c''\mordent b'2\turn c''1\fermata }""" parser = abjad.parser.LilyPondParser() result = parser(string) assert format(target) == format(result) and target is not result for x in result: assert 1 == len(abjad.inspect(x).indicators(abjad.Articulation))
def apply_bowing_marks(score): """ Applies bowing marks to score. """ # apply alternating upbow and downbow for first two sounding bars # of the first violin for measure in score['First Violin Voice'][6:8]: for i, chord in enumerate( abjad.iterate(measure).components(abjad.Chord)): if i % 2 == 0: articulation = abjad.Articulation('downbow') abjad.attach(articulation, chord) else: articulation = abjad.Articulation('upbow') abjad.attach(articulation, chord) # create and apply rebowing markup rebow_markup = abjad.Markup.concat([ abjad.Markup.musicglyph('scripts.downbow'), abjad.Markup.hspace(1), abjad.Markup.musicglyph('scripts.upbow'), ]) markup = copy.copy(rebow_markup) abjad.attach(markup, score['First Violin Voice'][64][0]) markup = copy.copy(rebow_markup) abjad.attach(markup, score['Second Violin Voice'][75][0]) markup = copy.copy(rebow_markup) abjad.attach(markup, score['Viola Voice'][86][0])
def edit_cello_voice(score, durated_reservoir): """ Edits cello voice. """ voice = score['Cello Voice'] descents = durated_reservoir['Cello'] logical_tie = abjad.inspect(voice[-1]).logical_tie() for leaf in logical_tie.leaves: parent = abjad.inspect(leaf).parentage().parent index = parent.index(leaf) parent[index] = abjad.Chord(['e,', 'a,'], leaf.written_duration) selection = voice[-len(descents[-1]):] unison_descent = abjad.mutate(selection).copy() voice.extend(unison_descent) for chord in unison_descent: index = abjad.inspect(chord).parentage().parent.index(chord) parent[index] = abjad.Note(chord.written_pitches[1], chord.written_duration) articulation = abjad.Articulation('accent') abjad.attach(articulation, parent[index]) articulation = abjad.Articulation('tenuto') abjad.attach(articulation, parent[index]) voice.extend('a,1. ~ a,2') voice.extend('b,1 ~ b,1. ~ b,1.') voice.extend('a,1. ~ a,1. ~ a,1. ~ a,1. ~ a,1. ~ a,2') voice.extend('r4 r2.')
def edit_cello_voice(score, durated_reservoir): """ Edits cello voice. """ voice = score["Cello Voice"] descents = durated_reservoir["Cello"] logical_tie = abjad.select(voice[-1]).logical_tie() for leaf in logical_tie.leaves: parent = abjad.inspect(leaf).parentage().parent index = parent.index(leaf) parent[index] = abjad.Chord(["e,", "a,"], leaf.written_duration) selection = voice[-len(descents[-1]):] unison_descent = abjad.mutate(selection).copy() voice.extend(unison_descent) for chord in unison_descent: index = abjad.inspect(chord).parentage().parent.index(chord) parent[index] = abjad.Note(chord.written_pitches[1], chord.written_duration) articulation = abjad.Articulation("accent") abjad.attach(articulation, parent[index]) articulation = abjad.Articulation("tenuto") abjad.attach(articulation, parent[index]) voice.extend("a,1. ~ a,2") voice.extend("b,1 ~ b,1. ~ b,1.") voice.extend("a,1. ~ a,1. ~ a,1. ~ a,1. ~ a,1. ~ a,2") voice.extend("r4 r2.")
def v1(m): accumulator( ("v1", 5), baca.dynamic("mp"), baca.markup( r"\stirrings-still-twelve-et-conflicts-with-viola-markup", abjad.Tweak(r"- \tweak padding 1.5"), ), baca.pitch("<F4 A4>"), library.urtext_spanner("urtext (ds) -|", 8), ) accumulator( ("v1", [(12, 23), (30, 59)]), baca.pitch("Bqf5"), ) accumulator( ("v1", (24, 27)), baca.flat_glissando("Bqf5"), ) accumulator( ("v1", (28, 29)), baca.flat_glissando("<F#4 Dqf5>"), baca.hairpin( "pp -- !", abjad.Tweak(r"- \tweak to-barline ##t"), selector=lambda _: baca.select.rleaves(_), ), baca.markup( r"\stirrings-still-seven-plus-nine-of-e-markup", abjad.Tweak(r"- \tweak padding 1.5"), ), baca.tasto_spanner(abjad.Tweak(r"- \tweak staff-padding 5.5"), ), library.clouded_pane_spanner("clouded pane (beacon) -|", 8), ) accumulator( ("v1", (36, 59)), baca.suite( baca.new( baca.tie(lambda _: baca.select.lleaf(_, 0)), measures=56, ), baca.articulations([ abjad.Articulation("baca-damp"), abjad.Articulation("baca-double-diamond"), abjad.Articulation("baca-damp"), None, ], ), baca.new( baca.note_head_style_harmonic( selector=lambda _: baca.select.pleaves(_)), map=lambda _: abjad.select.get(baca.select.plts(_), [3], 4), ), ), ) accumulator( ("v1", (71, 76)), baca.tuplet_bracket_down(), baca.tuplet_bracket_staff_padding(1.25), )
def va(m): accumulator( ("va", 5), baca.dynamic("mp"), baca.markup( r"\stirrings-still-nine-plus-seven-of-b-markup", abjad.Tweak(r"- \tweak padding 1.5"), ), baca.pitch("<Aqf3 C#4>"), library.clouded_pane_spanner("clouded (partial: stopped) -|", 8), ) accumulator( ("va", [(12, 23), (30, 59)]), baca.pitch("Bqf3"), ) accumulator( ("va", (24, 27)), baca.flat_glissando("Bqf3"), ) accumulator( ("va", (28, 29)), baca.flat_glissando("<B2 Aqs3>"), baca.hairpin( "pp -- !", abjad.Tweak(r"- \tweak to-barline ##t"), selector=lambda _: baca.select.rleaves(_), ), baca.markup( r"\stirrings-still-eleven-plus-three-of-e-markup", abjad.Tweak(r"- \tweak padding 1.5"), ), baca.tasto_spanner(abjad.Tweak(r"- \tweak staff-padding 5.5"), ), library.clouded_pane_spanner("clouded pane (beacon) -|", 8), ) accumulator( ("va", (36, 59)), baca.suite( baca.new( baca.tie(lambda _: baca.select.lleaf(_, 0)), measures=56, ), baca.articulations([ abjad.Articulation("baca-damp"), abjad.Articulation("baca-double-diamond"), abjad.Articulation("baca-double-diamond"), abjad.Articulation("baca-damp"), None, ], ), baca.new( baca.note_head_style_harmonic( selector=lambda _: baca.select.pleaves(_)), map=lambda _: abjad.select.get(baca.select.plts(_), [4], 5), ), ), ) accumulator( ("va", (71, 76)), baca.tuplet_bracket_staff_padding(0.5), )
def _attach_direction(direction, last_direction, tie): if direction is None or direction == last_direction: return ordinal = abjad.OrdinalConstant('y', 1, 'Down') if direction == 'in': articulation = abjad.Articulation('rtoe', ordinal) abjad.attach(articulation, tie.head) elif direction == 'out': articulation = abjad.Articulation('ltoe', ordinal) abjad.attach(articulation, tie.head)
def test_scoretools_Inspection_get_indicator_04(): note = abjad.Note("c'8") articulation = abjad.Articulation('staccato') abjad.attach(articulation, note) articulation = abjad.Articulation('marcato') abjad.attach(articulation, note) statement = 'inspect(note).get_indicator(abjad.Articulation)' assert pytest.raises(Exception, statement)
def test_mutate__fuse_leaves_by_immediate_parent_09(): """ Fuse leaves in logical tie with same immediate parent, with an indicator at the end of the logical tie after fusing. """ staff = abjad.Staff(r"d'8 c'8 ~ c'32 r16 r16 r16 r4") indicators = (abjad.TimeSignature((3, 4)), abjad.StartBeam()) for indicator in indicators: abjad.attach(indicator, staff[0]) indicators = ( abjad.BeforeGraceContainer("b'16"), abjad.Articulation("staccato"), abjad.Articulation("accent"), abjad.StopBeam(), ) for indicator in indicators: abjad.attach(indicator, staff[1]) logical_tie = abjad.get.logical_tie(staff[1]) result = abjad.mutate._fuse_leaves_by_immediate_parent(logical_tie) assert abjad.lilypond(staff) == abjad.String.normalize( r""" \new Staff { \time 3/4 d'8 [ \grace { b'16 } c'8 - \staccato - \accent ~ c'32 ] r16 r16 r16 r4 } """ ), print(abjad.lilypond(staff)) assert abjad.wf.wellformed(staff) assert len(result) == 1
def test_scoretools_Note___copy___05(): r'''Deepcopy orphan note. ''' note = abjad.Note("c'4") articulation = abjad.Articulation('staccato') abjad.attach(articulation, note) grace = abjad.GraceContainer("d'16") abjad.attach(grace, note) abjad.override(note).note_head.color = 'red' assert format(note) == abjad.String.normalize( r''' \grace { d'16 } \once \override NoteHead.color = #red c'4 -\staccato ''' ) new_note = copy.deepcopy(note) assert not new_note is note assert format(new_note) == format(note)
def _add_dynamics_and_articulations(self, logical_ties: list[abjad.LogicalTie], dynamics_: list[Union[str, abjad.Dynamic, ]], articulations_: list[Union[ str, abjad.Articulation, ]], omit_repeated_dynamics: bool, ) -> None: r'Adds dynamics and articulations to logical ties.' previous_dynamic = None for logical_tie, dynamic, articulation in zip(logical_ties, dynamics_, articulations_, ): if (dynamic is not None and (not omit_repeated_dynamics or dynamic != previous_dynamic)): abjad.attach(abjad.Dynamic(dynamic), logical_tie.head) previous_dynamic = dynamic if articulation is not None: if isinstance(articulation, str): abjad.attach(abjad.Articulation(articulation), logical_tie.head, ) else: abjad.attach(articulation, logical_tie.head)
def get_attachment(self, attachment_name): if attachment_name in self.articulations_inventory: return abjad.Articulation(name=attachment_name) elif attachment_name in self.dynamics_inventory: return abjad.Dynamic(name=attachment_name) elif attachment_name in self.slurs_inventory: return abjad.Slur() elif attachment_name == "\<": return abjad.Crescendo() elif attachment_name == "\>": return abjad.Decrescendo() elif attachment_name in self.stem_tremolos_inventory: tremolo_flags = int(attachment_name[1:]) return abjad.indicatortools.StemTremolo(tremolo_flags) elif attachment_name in self.tremolos_inventory: tremolo_count = int(attachment_name[8:]) return abjad.indicatortools.Tremolo(beam_count=tremolo_count, is_slurred=True) elif attachment_name == "~": return abjad.spannertools.Tie() elif attachment_name == "8va": return abjad.spannertools.OctavationSpanner(start=1) elif attachment_name in self.colors_inventory: # return lambda x : abjad.agenttools.LabelAgent(x).color_leaves(attachment_name) pass elif not attachment_name in self.stop_spanners_inventory: if attachment_name[0] == "\\": return abjad.indicatortools.LilyPondCommand( attachment_name[1:]) else: return abjad.Markup(attachment_name, direction=Up)
def test_lilypondparsertools_LilyPondParser__indicators__Markup_03(): r'''Articulations following markup block are (re)lexed correctly after returning to the "notes" lexical state after popping the "markup lexical state. ''' target = abjad.Staff([abjad.Note(0, (1, 4)), abjad.Note(2, (1, 4))]) markup = abjad.Markup('hello', abjad.Up) abjad.attach(markup, target[0]) articulation = abjad.Articulation('.') abjad.attach(articulation, target[0]) assert format(target) == abjad.String.normalize(r''' \new Staff { c'4 -\staccato ^ \markup { hello } d'4 } ''') string = r'''\new Staff { c' ^ \markup { hello } -. d' }''' parser = abjad.lilypondparsertools.LilyPondParser() result = parser(string) assert format(target, 'lilypond') == format(result, 'lilypond') and \ target is not result assert 1 == len(abjad.inspect(result[0]).get_markup())
def test_Note___copy___05(): """ Deepcopy orphan note. """ note = abjad.Note("c'4") articulation = abjad.Articulation("staccato") abjad.attach(articulation, note) grace = abjad.BeforeGraceContainer("d'16") abjad.attach(grace, note) abjad.override(note).NoteHead.color = "#red" assert abjad.lilypond(note) == abjad.String.normalize(r""" \grace { d'16 } \once \override NoteHead.color = #red c'4 - \staccato """) new_note = copy.deepcopy(note) assert new_note is not note assert abjad.lilypond(new_note) == abjad.lilypond(note)
def test_LilyPondParser__indicators__Markup_03(): """ Articulations following markup block are (re)lexed correctly after returning to the "notes" lexical state after popping the "markup lexical state. """ target = abjad.Staff([abjad.Note(0, (1, 4)), abjad.Note(2, (1, 4))]) markup = abjad.Markup("hello", direction=abjad.Up) abjad.attach(markup, target[0]) articulation = abjad.Articulation(".") abjad.attach(articulation, target[0]) assert abjad.lilypond(target) == abjad.String.normalize(r""" \new Staff { c'4 - \staccato ^ \markup { hello } d'4 } """) string = r"""\new Staff { c' ^ \markup { hello } -. d' }""" parser = abjad.parser.LilyPondParser() result = parser(string) assert abjad.lilypond(target) == abjad.lilypond( result) and target is not result assert 1 == len(abjad.get.markup(result[0]))
def test_mutate__fuse_leaves_by_immediate_parent_10(): """ Fuse leaves in logical tie with same immediate parent, with an indicator at every leaf of the logical tie after fusing. """ staff = abjad.Staff(r"c'16 ~ c'16 ~ c'16 ~ c'16 ~ c'16 r16 r16 r16 r4 r4") indicators = ( abjad.BeforeGraceContainer("b'16"), abjad.Clef("alto"), abjad.TimeSignature((3, 4)), abjad.Articulation("staccato"), abjad.Articulation("accent"), abjad.StemTremolo(16), ) for indicator in indicators: abjad.attach(indicator, staff[0]) logical_tie = abjad.get.logical_tie(staff[0]) result = abjad.mutate._fuse_leaves_by_immediate_parent(logical_tie) assert abjad.lilypond(staff) == abjad.String.normalize( r""" \new Staff { \grace { b'16 } \time 3/4 \clef "alto" c'4 :16 - \staccato - \accent ~ c'16 :16 r16 r16 r16 r4 r4 } """ ), print(abjad.lilypond(staff)) assert abjad.wf.wellformed(staff) assert len(result) == 1
def test_LeafDynMaker_08(): pitches = [ 0, "d'", 'E4', abjad.NumberedPitch(5), abjad.NamedPitch("g'"), abjad.NamedPitch('A4'), ] durations = [ (1, 32), '2/32', abjad.Duration('3/32'), abjad.Duration(0.125), abjad.Duration(5, 32), abjad.Duration(6 / 32), ] dynamics = [ 'p', abjad.Dynamic('f'), ] articulations = [ '>', abjad.Articulation('-'), abjad.Articulation('.'), ] maker = auxjad.LeafDynMaker() notes = maker(pitches, durations, dynamics, articulations) staff = abjad.Staff(notes) assert abjad.lilypond(staff) == abjad.String.normalize(r""" \new Staff { c'32 \p - \accent d'16 \f - \tenuto e'16. - \staccato f'8 g'8 ~ g'32 a'8. } """)
def test_scoretools_Inspection_get_indicator_02(): note = abjad.Note("c'8") articulation = abjad.Articulation('staccato') abjad.attach(articulation, note) assert abjad.inspect(note).get_indicator( abjad.Articulation) is articulation
def test_scoretools_Inspection_has_indicator_02(): staff = abjad.Staff("c'2 d'2") articulation = abjad.Articulation('staccato') abjad.attach(articulation, staff[0]) assert abjad.inspect(staff[0]).has_indicator(abjad.Articulation) assert not abjad.inspect(staff[1]).has_indicator(abjad.Duration)
def test_get_has_indicator_02(): staff = abjad.Staff("c'2 d'2") articulation = abjad.Articulation("staccato") abjad.attach(articulation, staff[0]) assert abjad.get.has_indicator(staff[0], abjad.Articulation) assert not abjad.get.has_indicator(staff[1], abjad.Duration)
def v2(m): accumulator( ("v2", 5), baca.dynamic("mp"), baca.markup( r"\stirrings-still-twelve-et-conflicts-with-viola-markup", abjad.Tweak(r"- \tweak padding 1.5"), ), baca.pitch("<E4 G#4>"), library.urtext_spanner("urtext (ds) -|", 8), ) accumulator( ("v2", [(12, 23), (30, 59)]), baca.pitch("Bb4"), ) accumulator( ("v2", (24, 27)), baca.flat_glissando("Bb4"), ) accumulator( ("v2", (28, 29)), baca.alternate_bow_strokes(), baca.damp_spanner(abjad.Tweak(r"- \tweak staff-padding 8"), ), baca.hairpin( "mp -- !", abjad.Tweak(r"- \tweak to-barline ##t"), selector=lambda _: baca.select.rleaves(_), ), baca.half_clt_spanner(abjad.Tweak(r"- \tweak staff-padding 5.5"), ), baca.pitch("F5"), ) accumulator( ("v2", (36, 59)), baca.suite( baca.new( baca.tie(lambda _: baca.select.lleaf(_, 0)), measures=56, ), baca.articulations([ abjad.Articulation("baca-damp"), abjad.Articulation("baca-damp"), abjad.Articulation("baca-double-diamond"), ], ), ), )
def test_lilypondparsertools_LilyPondParser__indicators__Articulation_02(): target = abjad.Staff([abjad.Note("c'", (1, 4))]) articulation = abjad.Articulation('marcato', abjad.Up) abjad.attach(articulation, target[0]) articulation = abjad.Articulation('stopped', abjad.Down) abjad.attach(articulation, target[0]) articulation = abjad.Articulation('tenuto') abjad.attach(articulation, target[0]) articulation = abjad.Articulation('staccatissimo') abjad.attach(articulation, target[0]) articulation = abjad.Articulation('accent') abjad.attach(articulation, target[0]) articulation = abjad.Articulation('staccato') abjad.attach(articulation, target[0]) articulation = abjad.Articulation('portato') abjad.attach(articulation, target[0]) r''' \new Staff { c'4 ^\marcato _\stopped -\tenuto -\staccatissimo -\accent -\staccato -\portato } ''' string = r'''\new Staff { c'4 ^^ _+ -- -| -> -. -_ }''' parser = abjad.lilypondparsertools.LilyPondParser() result = parser(string) assert format(target) == format(result) and \ target is not result assert 7 == len( abjad.inspect(result[0]).get_indicators(abjad.Articulation))
def test_LilyPondParser__indicators__Articulation_02(): target = abjad.Staff([abjad.Note("c'", (1, 4))]) articulation = abjad.Articulation("marcato", direction=abjad.Up) abjad.attach(articulation, target[0]) articulation = abjad.Articulation("stopped", direction=abjad.Down) abjad.attach(articulation, target[0]) articulation = abjad.Articulation("tenuto") abjad.attach(articulation, target[0]) articulation = abjad.Articulation("staccatissimo") abjad.attach(articulation, target[0]) articulation = abjad.Articulation("accent") abjad.attach(articulation, target[0]) articulation = abjad.Articulation("staccato") abjad.attach(articulation, target[0]) articulation = abjad.Articulation("portato") abjad.attach(articulation, target[0]) string = r"""\new Staff { c'4 ^^ _+ -- -! -> -. -_ }""" parser = abjad.parser.LilyPondParser() result = parser(string) assert abjad.lilypond(target) == abjad.lilypond( result) and target is not result assert 7 == len(abjad.get.indicators(result[0], abjad.Articulation))
def test_LilyPondParser__misc__chord_repetition_02(): target = abjad.Staff( [ abjad.Chord([0, 4, 7], (1, 8)), abjad.Chord([0, 4, 7], (1, 8)), abjad.Chord([0, 4, 7], (1, 4)), abjad.Chord([0, 4, 7], (3, 16)), abjad.Chord([0, 4, 7], (1, 16)), abjad.Chord([0, 4, 7], (1, 4)), ] ) dynamic = abjad.Dynamic("p") abjad.attach(dynamic, target[0]) articulation = abjad.Articulation("staccatissimo") abjad.attach(articulation, target[2]) markup = abjad.Markup("text", direction=abjad.Up) abjad.attach(markup, target[3]) articulation = abjad.Articulation("staccatissimo") abjad.attach(articulation, target[-1]) assert abjad.lilypond(target) == abjad.String.normalize( r""" \new Staff { <c' e' g'>8 \p <c' e' g'>8 <c' e' g'>4 - \staccatissimo <c' e' g'>8. ^ \markup { text } <c' e' g'>16 <c' e' g'>4 - \staccatissimo } """ ) string = r"""\new Staff { <c' e' g'>8\p q q4-! q8.^"text" q16 q4-! }""" parser = abjad.parser.LilyPondParser() result = parser(string) assert abjad.lilypond(target) == abjad.lilypond(result) and target is not result
def add_attachments(self, score): selection = abjad.select(score).components(abjad.Voice) for voice in selection: phrase_selection = abjad.select(voice).leaves().runs() for phrase in phrase_selection: if len(phrase) > 1: slur = abjad.Slur() abjad.attach(slur, phrase) accent = abjad.Articulation('accent') abjad.attach(accent, phrase[0]) return score
def add_attachments(music): # THIS IS HOW WE ADD DYNAMICS AND ACCENTS for run in abjad.select(music).leaves().runs(): if not isinstance(run[0], (abjad.Note, abjad.Chord)): continue abjad.attach(abjad.Articulation('accent'), run[0]) if 1 < len(run): abjad.attach(abjad.Hairpin('p < f'), run) else: abjad.attach(abjad.Dynamic('ppp'), run[0]) return music
def full_bows(selections): bowings = evans.CyclicList(["downbow", "upbow"], forget=False) for run in abjad.Selection(selections).runs(): for tie in abjad.Selection(run).logical_ties(): articulation = abjad.Articulation(bowings(r=1)[0]) abjad.attach(articulation, tie[0]) mark = abjad.Markup( fr"\markup {{ {rotations(r=1)[0]} }}", direction=abjad.Up, ) abjad.attach(mark, abjad.Selection(run).logical_tie(0)[0])
def edit_viola_voice(score, durated_reservoir): """ Edits viola voice. """ voice = score['Viola Voice'] descents = durated_reservoir['Viola'] for leaf in descents[-1]: articulation = abjad.Articulation('accent') abjad.attach(articulation, leaf) articulation = abjad.Articulation('tenuto') abjad.attach(articulation, leaf) last_descent = abjad.Selection(descents[-1]) copied_descent = abjad.mutate(last_descent).copy() for leaf in copied_descent: if leaf.written_duration == abjad.Duration(4, 4): leaf.written_duration = abjad.Duration(8, 4) else: leaf.written_duration = abjad.Duration(4, 4) voice.extend(copied_descent) bridge = abjad.Note('e1') articulation = abjad.Articulation('tenuto') abjad.attach(articulation, bridge) articulation = abjad.Articulation('accent') abjad.attach(articulation, bridge) voice.append(bridge) final_sustain_rhythm = [(6, 4)] * 21 + [(1, 2)] maker = abjad.NoteMaker() final_sustain_notes = maker(['e'], final_sustain_rhythm) articulation = abjad.Articulation('accent') abjad.attach(articulation, final_sustain_notes[0]) articulation = abjad.Articulation('tenuto') abjad.attach(articulation, final_sustain_notes[0]) voice.extend(final_sustain_notes) abjad.tie(final_sustain_notes) voice.extend('r4 r2.')
def test_lilypondparsertools_LilyPondParser__misc__chord_repetition_02(): target = abjad.Staff([ abjad.Chord([0, 4, 7], (1, 8)), abjad.Chord([0, 4, 7], (1, 8)), abjad.Chord([0, 4, 7], (1, 4)), abjad.Chord([0, 4, 7], (3, 16)), abjad.Chord([0, 4, 7], (1, 16)), abjad.Chord([0, 4, 7], (1, 4)) ]) dynamic = abjad.Dynamic('p') abjad.attach(dynamic, target[0]) articulation = abjad.Articulation('staccatissimo') abjad.attach(articulation, target[2]) markup = abjad.Markup('text', abjad.Up) abjad.attach(markup, target[3]) articulation = abjad.Articulation('staccatissimo') abjad.attach(articulation, target[-1]) assert format(target) == abjad.String.normalize(r''' \new Staff { <c' e' g'>8 \p <c' e' g'>8 <c' e' g'>4 -\staccatissimo <c' e' g'>8. ^ \markup { text } <c' e' g'>16 <c' e' g'>4 -\staccatissimo } ''') string = r'''\new Staff { <c' e' g'>8\p q q4-| q8.^"text" q16 q4-| }''' parser = abjad.lilypondparsertools.LilyPondParser() result = parser(string) assert format(target) == format(result) and target is not result