def test_reposition_dynamics_11(): staff = abjad.Staff(r"c'1 d'1 e'1 r1\mf r1\ff f'1 r1 g'1") abjad.attach(abjad.Dynamic('niente', hide=True), staff[0]) abjad.attach(abjad.Dynamic('niente', hide=True), staff[7]) abjad.attach(abjad.StartHairpin('o<'), staff[0]) abjad.attach(abjad.StartHairpin('>o'), staff[4]) abjad.attach(abjad.StopHairpin(), staff[7]) auxjad.mutate(staff[:]).reposition_dynamics() assert format(staff) == abjad.String.normalize(r""" \new Staff { c'1 - \tweak circled-tip ##t \< d'1 e'1 r1 \mf r1 f'1 \ff - \tweak circled-tip ##t \> r1 \! g'1 } """)
def apply_scratch(selections): start_dynamic = abjad.Dynamic("sfp") stop_dynamic = abjad.Dynamic("ff") scratch_text = abjad.Markup( r"""\override #'(style . "box") \override #'(box-padding . 0.5) \italic \box \whiteout \small "scratch" """, literal=True, ) start_scratch_span = abjad.StartTextSpan( left_text=scratch_text, style="solid-line-with-hook", ) abjad.tweak(start_scratch_span).padding = 2 abjad.tweak(start_scratch_span).staff_padding = 3 stop_scratch_span = abjad.StopTextSpan() scratch_dynamic = abjad.Dynamic("f") ties = abjad.select(selections).logical_ties(pitched=True) for i, tie in enumerate(ties): if len(tie) < 2: abjad.attach(start_dynamic, tie[0]) else: if i % 2 == 0: abjad.attach(start_dynamic, tie[0]) abjad.attach(abjad.StartHairpin("<"), tie[0]) abjad.attach(stop_dynamic, tie[-1]) else: next_leaf = abjad.get.leaf(tie[-1], 1) abjad.attach(start_scratch_span, tie[0]) abjad.attach(scratch_dynamic, tie[0]) abjad.attach(stop_scratch_span, next_leaf)
def test_lilypondparsertools_LilyPondParser__spanners__Hairpin_03(): r'''Dynamics can terminate hairpins. ''' maker = abjad.NoteMaker() target = abjad.Staff(maker([0] * 3, [(1, 4)])) hairpin = abjad.Hairpin(descriptor='<') abjad.attach(hairpin, target[0:2]) hairpin = abjad.Hairpin(descriptor='>') abjad.attach(hairpin, target[1:]) dynamic = abjad.Dynamic('p') abjad.attach(dynamic, target[1]) dynamic = abjad.Dynamic('f') abjad.attach(dynamic, target[-1]) assert format(target) == abjad.String.normalize(r''' \new Staff { c'4 \< c'4 \p \> c'4 \f } ''') string = r"\new Staff \relative c' { c \< c \p \> c \f }" parser = abjad.lilypondparsertools.LilyPondParser() result = parser(string) assert format(target) == format(result) and target is not result
def add_attachments(self, selections): runs = abjad.select(selections).runs() ties = abjad.select(selections).logical_ties(pitched=True) for run in runs: if len(run) > 1: abjad.attach(abjad.Dynamic(self.starting_dynamic), run[0]) abjad.attach(abjad.Dynamic(self.ending_dynamic), run[-1]) abjad.attach(abjad.DynamicTrend(self.trend), run[0]) else: dynamic = next(self._cyc_dynamics) abjad.attach(abjad.Dynamic(dynamic), run[0]) for tie in ties: if len(tie) == 1: abjad.attach(abjad.Articulation(self.articulation), tie.head)
def add_attachments(self, selections): runs = abjad.select(selections).runs() ties = abjad.select(selections).logical_ties(pitched=True) for run in runs: if self.clef != None: abjad.attach( abjad.Clef(self.clef), run[0] ) #doesn't seem to always work, redo entire attachment handler? if len(run) > 1: leaves = abjad.select(run).leaves() if self.starting_dynamic != None: abjad.attach(abjad.Dynamic(self.starting_dynamic), leaves[0]) if self.hairpin != None: abjad.attach(abjad.StartHairpin(self.hairpin), leaves[0]) if self.ending_dynamic != None: abjad.attach(abjad.Dynamic(self.ending_dynamic), leaves[-1]) abjad.attach( abjad.StartHairpin('--'), leaves[-1] ) #makes ending with a logical tie weird. If problematic: reduce indentation by 1 if self.text_list != None: if len(self.text_list) > 1: self._apply_text_and_span_lr(run) else: self._apply_text_and_span_l_only(run) else: leaves = abjad.select(run).leaves() dynamic = next(self._cyc_dynamics) if self.starting_dynamic != None: if self.ending_dynamic != None: abjad.attach(abjad.Dynamic(dynamic), leaves[0]) else: abjad.attach(abjad.Dynamic(self.starting_dynamic), leaves[0]) if self.starting_dynamic == None: if self.ending_dynamic != None: abjad.attach(abjad.Dynamic(self.ending_dynamic), leaves[0]) abjad.attach(abjad.StartHairpin('--'), leaves[0]) if self.text_list != None: self._apply_text_and_span_l_only(run) for tie in ties: if len(tie) == 1: if self.articulation_list != None: articulation = self._cyc_articulations abjad.attach(abjad.Articulation(next(articulation)), tie[0]) return selections
def rosatize(self): # transposing up an octave and add dynamic for Rosa Guitar Trio for staff in self.skeleton: first_leaf = abjad.inspect(staff).leaf(0) abjad.attach(abjad.Dynamic('pp'), first_leaf) for note in abjad.iterate(staff).components(prototype=abjad.Note): note.written_pitch += 12
def test_lilypondproxytools_LilyPondGrobNameManager___setattr___12(): r'''Override LilyPond abjad.DynamicText grob. ''' staff = abjad.Staff("c'8 d'8 e'8 f'8") beam = abjad.Beam() abjad.attach(beam, staff[:]) dynamic = abjad.Dynamic('f') abjad.attach(dynamic, staff[0]) spanner = abjad.Spanner() abjad.override(spanner).dynamic_text.thickness = 3 abjad.attach(spanner, staff[:]) assert format(staff) == abjad.String.normalize(r''' \new Staff { \override DynamicText.thickness = #3 c'8 \f [ d'8 e'8 \revert DynamicText.thickness f'8 ] } ''') assert abjad.inspect(staff).is_well_formed()
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__spanners__Hairpin_01(): maker = abjad.NoteMaker() target = abjad.Staff(maker([0] * 5, [(1, 4)])) hairpin = abjad.Hairpin(descriptor='<') abjad.attach(hairpin, target[:3]) hairpin = abjad.Hairpin(descriptor='>') abjad.attach(hairpin, target[2:]) dynamic = abjad.Dynamic('ppp') abjad.attach(dynamic, target[-1]) assert format(target) == abjad.String.normalize(r''' \new Staff { c'4 \< c'4 c'4 \! \> c'4 c'4 \ppp } ''') parser = abjad.lilypondparsertools.LilyPondParser() result = parser(format(target)) assert format(target) == format(result) and target is not result
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 test_LilyPondParser__spanners__Hairpin_06(): """ With direction. """ maker = abjad.NoteMaker() target = abjad.Staff(maker([0] * 5, [(1, 4)])) start_hairpin = abjad.StartHairpin("<", direction=abjad.Up) abjad.attach(start_hairpin, target[0]) stop_hairpin = abjad.StopHairpin() abjad.attach(stop_hairpin, target[2]) hairpin = abjad.StartHairpin(">", direction=abjad.Down) abjad.attach(hairpin, target[2]) dynamic = abjad.Dynamic("ppp") abjad.attach(dynamic, target[-1]) assert format(target) == abjad.String.normalize(r""" \new Staff { c'4 ^ \< c'4 c'4 \! _ \> c'4 c'4 \ppp } """) parser = abjad.parser.LilyPondParser() result = parser(format(target)) assert format(target) == format(result) and target is not result
def make_desordre_cell(pitches): """ Makes a Désordre cell. """ notes = [abjad.Note(pitch, (1, 8)) for pitch in pitches] notes = abjad.Selection(notes) beam = abjad.Beam() abjad.attach(beam, notes) slur = abjad.Slur() abjad.attach(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 add_attachments(self, selections): runs = abjad.select(selections).runs() ties = abjad.select(selections).logical_ties(pitched=True) for run in runs: if len(run) > 1: leaves = abjad.select(run).leaves() abjad.attach(abjad.Dynamic(self.starting_dynamic), leaves[0]) abjad.attach(abjad.StartHairpin(self.hairpin_indicator), leaves[0]) abjad.attach(abjad.Dynamic(self.ending_dynamic), leaves[-1]) abjad.attach(abjad.StartHairpin("--"), leaves[-1]) else: leaves = abjad.select(run).leaves() dynamic = next(self._cyc_dynamics) abjad.attach(abjad.Dynamic(dynamic), leaves[0]) abjad.attach(abjad.StartHairpin("--"), leaves[0]) for tie in ties: if len(tie) == 1: abjad.attach(abjad.Articulation(self.articulation), tie[0]) return selections
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 apply_spectrum_tremolo(selections): trem_handler(selections) ties = abjad.select(selections).logical_ties(pitched=True) non_last_ties = ties[:-1] dynamics = spectrum_dynamics(r=len(ties)) for i, tie in enumerate(non_last_ties): leaf = abjad.select(tie).leaf(0) dynamic_string = dynamics[i] dynamic = abjad.Dynamic(dynamic_string) next_dynamic_string = dynamics[i + 1] next_dynamic = abjad.Dynamic(next_dynamic_string) if dynamic.ordinal < next_dynamic.ordinal: hairpin = abjad.StartHairpin("<") else: hairpin = abjad.StartHairpin(">") abjad.attach(dynamic, leaf) abjad.attach(hairpin, leaf) first_leaf = abjad.select(selections).leaf(0, pitched=True) final_leaf = abjad.select(selections).leaf(-1, pitched=True) abjad.attach(abjad.Dynamic(dynamics[-1]), final_leaf) abjad.attach(tasto_markup, first_leaf)
def test_remove_repeated_dynamics_03(): staff = abjad.Staff([ abjad.Note("c'2"), abjad.Chord("<d' f'>2"), abjad.Tuplet((2, 3), "g2 a2 b2"), ]) abjad.attach(abjad.Dynamic('ppp'), staff[0]) abjad.attach(abjad.Dynamic('ppp'), staff[1]) abjad.attach(abjad.Dynamic('ppp'), staff[2][0]) assert abjad.lilypond(staff) == abjad.String.normalize(r""" \new Staff { c'2 \ppp <d' f'>2 \ppp \times 2/3 { g2 \ppp a2 b2 } } """) auxjad.mutate.remove_repeated_dynamics(staff[:]) assert abjad.lilypond(staff) == abjad.String.normalize(r""" \new Staff { c'2 \ppp <d' f'>2 \times 2/3 { g2 a2 b2 } } """)
def test_LilyPondParser__indicators__Dynamic_01(): target = abjad.Staff("c2 c2 c2 c2 c2 c2") dynamic = abjad.Dynamic("ppp") abjad.attach(dynamic, target[0]) dynamic = abjad.Dynamic("mp") abjad.attach(dynamic, target[1]) dynamic = abjad.Dynamic("rfz") abjad.attach(dynamic, target[2]) dynamic = abjad.Dynamic("mf") abjad.attach(dynamic, target[3]) dynamic = abjad.Dynamic("spp") abjad.attach(dynamic, target[4]) dynamic = abjad.Dynamic("ff") abjad.attach(dynamic, target[5]) string = r"""\new Staff { c2\ppp c\mp c2\rfz c\mf c2\spp c\ff }""" parser = abjad.parser.LilyPondParser() result = parser(string) assert abjad.lilypond(target) == abjad.lilypond( result) and target is not result for x in result: dynamics = abjad.get.indicators(x, abjad.Dynamic) assert len(dynamics) == 1
def test_scoretools_Inspection_get_effective_09(): staff = abjad.Staff("c'8 d'8 e'8 f'8") dynamic = abjad.Dynamic('f') abjad.attach(dynamic, staff[2]) assert format(staff) == abjad.String.normalize(r''' \new Staff { c'8 d'8 e'8 \f f'8 } ''') assert abjad.inspect(staff).get_effective(abjad.Dynamic) is None assert abjad.inspect(staff[0]).get_effective(abjad.Dynamic) is None assert abjad.inspect(staff[1]).get_effective(abjad.Dynamic) is None assert abjad.inspect(staff[2]).get_effective( abjad.Dynamic) == abjad.Dynamic('f') assert abjad.inspect(staff[3]).get_effective( abjad.Dynamic) == abjad.Dynamic('f')
def make_bound_hairpin_score_03(self): r'''Make 200-note voice with p-to-f bound crescendo spanner on every 100 notes. 2.12 (r9726) initialization: 267,417 function calls 2.12 (r9726) LilyPond format: 116,534 function calls ''' import abjad voice = abjad.Voice(200 * abjad.Note("c'16")) for part in abjad.sequence(voice[:]).partition_by_counts( [100], cyclic=True, ): crescendo = abjad.Hairpin('<') abjad.attach(crescendo, part) dynamic = abjad.Dynamic('p') abjad.attach(dynamic, part[0]) dynamic = abjad.Dynamic('r') abjad.attach(dynamic, part[-1]) return voice
def add_attachments(self, music): # THIS IS HOW WE ADD DYNAMICS AND ACCENTS for run in abjad.select(music).leaves(pitched=True).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]) first_leaf = next(abjad.iterate(music).leaves()) abjad.attach(self.clef, first_leaf) return music
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 make_bound_hairpin_score_01(self): """ Make 200-note voice with p-to-f bound crescendo spanner on every 4 notes. 2.12 (r9726) initialization: 279,448 function calls 2.12 (r9726) LilyPond format: 124,517 function calls """ import abjad voice = abjad.Voice(200 * abjad.Note("c'16")) for part in abjad.Sequenc(voice[:]).partition_by_counts( [4], cyclic=True, ): crescendo = abjad.Hairpin('<') abjad.attach(crescendo, part) dynamic = abjad.Dynamic('p') abjad.attach(dynamic, part[0]) dynamic = abjad.Dynamic('r') abjad.attach(dynamic, part[-1]) return voice
def dynamics(self, dynamics: dict, material_name=None): """ :param dynamics: dict (key: str, value: abjad.Selection) :param material_name: str """ if material_name is None: selectable = self.container else: selectable = self.select_material(self.container, material_name=material_name) for key, select in dynamics.items(): selection = select(selectable) if abjad.Dynamic.is_dynamic_name(key): if isinstance(selection, abjad.Leaf): abjad.attach(abjad.Dynamic(key), selection) else: for _ in selection: abjad.attach(abjad.Dynamic(key), _) elif isinstance(selection[0], abjad.Selection): for sel in selection: abjad.hairpin(key, sel) else: abjad.hairpin(key, selection)
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.Staccato(), ] leaf_dyn_maker = auxjad.LeafDynMaker() notes = leaf_dyn_maker(pitches, durations, dynamics, articulations) staff = abjad.Staff(notes) assert format(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_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 _handle_dynamics(self): voice = self._score[f"{self.instrument_name}_Music_Voice"] leaves = abjad.select(voice).leaves() if not leaves: return music_durations = [abjad.inspect(_).duration() for _ in leaves] maker = rmakers.multiplied_duration(abjad.Skip) dynamics_skips = maker(music_durations) dynamics_voice = self._score[f"{self.instrument_name}_Dynamics_Voice"] dynamics_voice.extend(dynamics_skips) for expression in self.dynamics: index = expression[0] string = expression[1] leaf = dynamics_voice[index] if string in ("<", ">"): indicator = abjad.LilyPondLiteral("\\" + string, "after") elif string == "-|": indicator = abjad.LilyPondLiteral(r"\<", "after") stencil = abjad.Scheme("constante-hairpin") abjad.override(leaf).hairpin.stencil = stencil elif string == "<!": indicator = abjad.LilyPondLiteral(r"\<", "after") stencil = abjad.Scheme("abjad-flared-hairpin") abjad.override(leaf).hairpin.stencil = stencil elif string == "!>": indicator = abjad.LilyPondLiteral(r"\>", "after") stencil = abjad.Scheme("abjad-flared-hairpin") abjad.override(leaf).hairpin.stencil = stencil else: indicator = abjad.Dynamic(string) abjad.attach(indicator, leaf) if len(expression) == 3: staff_padding = expression[2] string = r"\override DynamicLineSpanner.staff-padding =" string += f" {staff_padding}" command = abjad.LilyPondLiteral(string) abjad.attach(command, leaf) last_leaf = dynamics_voice[-1] prototype = abjad.LilyPondLiteral if not abjad.inspect(last_leaf).has_indicator(prototype): if not abjad.inspect(last_leaf).has_indicator(abjad.Dynamic): indicator = abjad.LilyPondLiteral(r"\!", "after") abjad.attach(indicator, last_leaf)
def attach_clicks(selections): cyc_clicks = evans.CyclicList( [ "XSB(c.2 clicks per second)", "XSB(c.3 clicks/s)", "XSB(c.4)", "XSB(c.5)", "XSB(c.6)", "XSB(c.7)", "XSB(c.8)", "slow bow", "norm.", "quasi noise", ], forget=False, ) for leaf in abjad.Selection(selections).leaves(): text = cyc_clicks(r=1)[0] mark = abjad.Markup(fr"\upright {{ {text} }}", direction=abjad.Up) span = abjad.StartTextSpan( left_text=mark, style="dashed-line-with-arrow", ) abjad.tweak(span).padding = 6.75 abjad.attach(span, leaf) abjad.attach(abjad.StopTextSpan(), leaf) first_leaf = abjad.Selection(selections).leaf(0) abjad.attach(abjad.Dynamic("fff"), first_leaf) abjad.detach(abjad.StopTextSpan(), first_leaf) final = abjad.StartTextSpan( left_text=abjad.Markup(r"\upright { quasi noise }"), style="invisible-line", ) abjad.tweak(final).padding = 6.75 final_leaf = abjad.Selection(selections).leaf(-1) start_span_indicator = [ _ for _ in abjad.get.indicators(final_leaf) if isinstance(_, abjad.StartTextSpan) ] abjad.detach(start_span_indicator[0], final_leaf) abjad.attach(final, final_leaf) abjad.attach(abjad.StopTextSpan(), abjad.get.leaf(final_leaf, 1))
def make_score_with_indicators_03(self): r'''Make 200-note staff with dynamic on every note. 2.12 (r9704) initialization: 53,450,195 function calls (!!) 2.12 (r9710) initialization: 2,124,500 function calls 2.12 (r9724) initialization: 2,122,591 function calls 2.12 (r9704) LilyPond format: 533,927 function calls 2.12 (r9710) LilyPond format: 91,280 function calls 2.12 (r9724) LilyPond format: 96,806 function calls ''' import abjad staff = abjad.Staff(200 * abjad.Note("c'16")) selector = abjad.select().leaves() for note in selector(staff): dynamic = abjad.Dynamic('f') abjad.attach(dynamic, note) return staff
def attach_material(selections): ties = abjad.Selection(selections).logical_ties() first_leaf = abjad.Selection(ties).leaf(0) center_leaf = abjad.Selection(ties[len(ties) // 2]).leaf(0) last_leaf = abjad.Selection(ties).leaf(-1) cyc_dynamics = evans.CyclicList(["p", "f"], forget=False) cyc_hairpins = evans.CyclicList(["<", ">"], forget=False) for tie in ties: dynamic = abjad.Dynamic(cyc_dynamics(r=1)[0]) abjad.attach(dynamic, tie[0]) for tie in ties[:-1]: hairpin = abjad.StartHairpin(cyc_hairpins(r=1)[0]) abjad.attach(hairpin, tie[0]) start = abjad.StartTextSpan( left_text=abjad.Markup(r"\upright norm."), style="dashed-line-with-arrow", ) middle = abjad.StartTextSpan( left_text=abjad.Markup(r"\upright msp."), right_text=abjad.Markup(r"\markup \upright st."), style="dashed-line-with-arrow", ) middle_stop = abjad.StopTextSpan() final_stop = abjad.StopTextSpan() abjad.tweak(start).staff_padding = 2 abjad.tweak(middle).staff_padding = 2 abjad.attach(start, first_leaf) abjad.attach(middle_stop, center_leaf) abjad.attach(middle, center_leaf) abjad.attach(final_stop, last_leaf) for leaf in abjad.Selection(selections).leaves(): literal_1 = abjad.LilyPondLiteral( r"\once \override Staff.Tie.transparent = ##t", format_slot="before", ) abjad.attach(literal_1, leaf) literal_2 = abjad.LilyPondLiteral( r"\once \override Dots.staff-position = #1.75", format_slot="before", ) abjad.attach(literal_2, leaf)
def make_score_with_indicators_02(self): """ Make 200-note staff with dynamic on every 4th note. 2.12 (r9704) initialization: 4,632,761 function calls 2.12 (r9710) initialization: 327,280 function calls 2.12 (r9726) initialization: 325,371 function calls 2.12 (r9704) LilyPond format: 220,277 function calls 2.12 (r9710) LilyPond format: 84,530 function calls 2.12 (r9726) LilyPond format: 90,056 function calls """ import abjad staff = abjad.Staff(200 * abjad.Note("c'16")) for part in abjad.sequence(staff[:]).partition_by_counts([4], cyclic=True): dynamic = abjad.Dynamic("f") abjad.attach(dynamic, part[0]) return staff