Beispiel #1
0
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
Beispiel #2
0
    def attach(self, leaf: abjad.Chord, novent) -> None:
        note = abjad.mutate(self.abjad).copy()

        for attachment in self.added_attachments:
            abjad.attach(attachment, note)

        if self.add_glissando:
            abjad.attach(abjad.GlissandoIndicator(), note)
            self._set_glissando_layout(
                note,
                thickness=self.glissando_thickness,
                minimum_length=self.glissando_minimum_length,
            )

        self._attach_grace_not_style(note)

        if type(note) == abjad.Note:
            comparision_pitch_number = note.written_pitch.number
        else:
            comparision_pitch_number = note.note_heads[0].written_pitch.number

        if abs(comparision_pitch_number -
               leaf.note_heads[0].written_pitch.number) > 8:
            abjad.attach(abjad.LilyPondLiteral("\\grace"), note)
        else:
            abjad.attach(abjad.LilyPondLiteral("\\acciaccatura"), note)
        abjad.attach(abjad.LilyPondLiteral(format(note)), leaf)
def _notate_ornamentation(name: str) -> None:
    staff = abjad.Staff([abjad.Note("a'", 0.5), abjad.Note("f'", 0.5)])

    abjad.attach(
        abjad.LilyPondLiteral(
            "\\override Score.SpacingSpanner.strict-note-spacing = ##t",
            format_slot="before",
        ),
        staff[0],
    )
    abjad.attach(
        abjad.LilyPondLiteral("\\newSpacingSection", format_slot="before"),
        staff[0])
    abjad.attach(
        abjad.LilyPondLiteral(
            "\\override Score.SpacingSpanner.base-shortest-duration = #(ly:make-moment"
            + " 1/32)",
            format_slot="before",
        ),
        staff[0],
    )

    abjad.attach(lily.mk_no_time_signature(), staff[0])
    abjad.attach(abjad.TimeSignature((len(staff), 1)), staff[0])
    abjad.attach(abjad.Clef("treble"), staff[0])
    abjad.attach(attachments.OrnamentationUp(2)._markup, staff[0])
    abjad.attach(attachments.OrnamentationDown(3)._markup, staff[1])

    sco = abjad.Score([staff])
    lily.make_small_example(sco, name, ragged_last=True, ragged_right=True)
Beispiel #4
0
    def attach(self, leaf: abjad.Chord, novent) -> None:
        abjad.attach(abjad.LilyPondLiteral("\\once \\tiny"), leaf)
        n_heads = len(leaf.note_heads)

        if n_heads == 1:
            size = 2
            positions2attach = (0, )

        else:
            span = (leaf.note_heads[-1].written_pitch.number -
                    leaf.note_heads[0].written_pitch.number)

            if span <= 7:
                size = 5.45
                positions2attach = (int(math.ceil((n_heads / 2) - 1)), )

            else:
                size = 1.85
                positions2attach = tuple(range(n_heads))

        abjad.attach(
            abjad.LilyPondLiteral(
                "\\once \\override ParenthesesItem.font-size = #{}".format(
                    size)),
            leaf,
        )
        abjad.attach(
            abjad.LilyPondLiteral(
                "\\once \\override ParenthesesItem.padding = #0.05"),
            leaf,
        )

        for position in positions2attach:
            leaf.note_heads[position].is_parenthesized = True
def _notate_glissando(name: str) -> None:
    staff = abjad.Staff([
        abjad.Note("a'", 3 / 16),
        abjad.Note("a'", 1 / 16),
        abjad.Note("a'", 1 / 8),
        abjad.Note("a'", 1 / 8),
    ])

    abjad.attach(
        abjad.LilyPondLiteral("#(define afterGraceFraction (cons 15 16))"),
        staff[0])
    abjad.attach(
        abjad.LilyPondLiteral('\\override Flag.stroke-style = #"grace"'),
        staff[0],
    )

    for n in (0, 2):
        attachments._GlissandoAttachment._set_glissando_layout(
            staff[n + 1], minimum_length=3)
        abjad.attach(abjad.AfterGraceContainer([abjad.Note("f'", 1 / 8)]),
                     staff[n + 1])
        abjad.attach(abjad.Tie(), staff[n])
        abjad.attach(abjad.StartBeam(), staff[n])
        abjad.attach(abjad.StopBeam(), staff[n + 1])
        abjad.attach(abjad.GlissandoIndicator(), staff[n + 1])

    abjad.attach(lily.mk_no_time_signature(), staff[0])
    abjad.attach(abjad.TimeSignature((len(staff), 1)), staff[0])
    abjad.attach(abjad.Clef("treble"), staff[0])

    sco = abjad.Score([staff])
    lily.make_small_example(sco, name, ragged_last=True, ragged_right=True)
Beispiel #6
0
def illustrate_applied_brahms_melodies(
        applied_brahms_melodies: basic.SequentialEvent):
    applied_brahms_melodies = functools.reduce(operator.add,
                                               applied_brahms_melodies)
    import abjad

    from mutwo.converters.frontends import abjad as mutwo_abjad

    time_signatures = tuple(
        abjad.TimeSignature((int(event.duration * 2), 2))
        for event in applied_cantus_firmus.APPLIED_CANTUS_FIRMUS)

    abjad_converter = mutwo_abjad.SequentialEventToAbjadVoiceConverter(
        mutwo_abjad.SequentialEventToQuantizedAbjadContainerConverter(
            time_signatures),
        mutwo_pitch_to_abjad_pitch_converter=mutwo_abjad.
        MutwoPitchToHEJIAbjadPitchConverter(),
    )
    abjad_voice = abjad_converter.convert(applied_brahms_melodies)

    abjad.attach(abjad.LilyPondLiteral('\\accidentalStyle "dodecaphonic"'),
                 abjad_voice[0][0])
    abjad.attach(
        abjad.LilyPondLiteral(
            "\\override Staff.TimeSignature.style = #'single-digit"),
        abjad_voice[0][0],
    )
    abjad_score = abjad.Score([abjad.Staff([abjad_voice])])
    lilypond_file = abjad.LilyPondFile(items=[abjad_score],
                                       includes=["ekme-heji-ref-c.ily"])
    abjad.persist.as_pdf(lilypond_file, "builds/applied_brahms_melodies.pdf")
def test_scoretools_Inspection_get_indicators_01():

    staff = abjad.Staff("c'8 d'8 e'8 f'8")
    slur = abjad.Slur()
    abjad.attach(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]).get_indicators(abjad.LilyPondLiteral)
    assert command_1 in indicators
    assert command_2 in indicators
    assert len(indicators) == 2
    def process_leaf(self, leaf: abjad.Leaf) -> abjad.Leaf:
        abjad.attach(
            abjad.LilyPondLiteral(
                "\\override Staff.StaffSymbol.line-count = #1", format_slot="before"
            ),
            leaf,
        )
        abjad.attach(
            abjad.LilyPondLiteral("\\once \\hide Staff.Clef", format_slot="before"),
            leaf,
        )

        if self.density == 3:
            noise_string = Noise._make_continous_noise(self.presence, self.is_pitch)
        else:
            noise_string = Noise._make_discreet_noise(
                self.density, self.presence, self.is_periodic
            )

        lilypond_literal = abjad.LilyPondLiteral(
            r"_\markup { " + noise_string + " }", "after"
        )

        abjad.attach(
            lilypond_literal,
            leaf,
        )
        return leaf
def test_Score_add_double_bar_lines_before_time_signatures_05():
    voice_1 = abjad.Voice(
        r"\time 3/4 c''2. \time 4/4 d''1 e''1 \time 6/4 f''2. g''2.")
    voice_2 = abjad.Voice(
        r"\time 3/4 c'2. \time 4/4 d'1 e'1 \time 6/4 f'2. g'2.")
    staff_1 = abjad.Staff([voice_1, voice_2], simultaneous=True)
    abjad.attach(abjad.LilyPondLiteral(r'\voiceOne'), voice_1)
    abjad.attach(abjad.LilyPondLiteral(r'\voiceTwo'), voice_2)
    staff_2 = abjad.Staff(
        r"\time 3/4 c'2. \time 4/4 d'1 e'1 \time 6/4 f'2. g'2.")
    score = auxjad.Score([staff_1, staff_2])
    score.add_double_bar_lines_before_time_signatures()
    assert abjad.lilypond(score) == abjad.String.normalize(r"""
        \new Score
        <<
            \new Staff
            <<
                \new Voice
                {
                    \voiceOne
                    \time 3/4
                    c''2.
                    \time 4/4
                    d''1
                    e''1
                    \time 6/4
                    f''2.
                    g''2.
                }
                \new Voice
                {
                    \voiceTwo
                    \time 3/4
                    c'2.
                    \bar "||"
                    \time 4/4
                    d'1
                    e'1
                    \bar "||"
                    \time 6/4
                    f'2.
                    g'2.
                }
            >>
            \new Staff
            {
                \time 3/4
                c'2.
                \bar "||"
                \time 4/4
                d'1
                e'1
                \bar "||"
                \time 6/4
                f'2.
                g'2.
            }
        >>
        """)
Beispiel #10
0
 def _attach_centre_markup(self) -> None:
     r'Attaches the centre markup tweaks.'
     literal1 = abjad.LilyPondLiteral(
         r'\once \override TextScript.parent-alignment-X = 0')
     literal2 = abjad.LilyPondLiteral(
         r'\once \override TextScript.self-alignment-X = 0')
     abjad.attach(literal1, self)
     abjad.attach(literal2, self)
Beispiel #11
0
def post_process_electronics(electronics, score):
    # CHORD ZERO ELECTRONICS

    # ELECTRONICS
    for pitch in pitches.electronics_pitches:
        electronics.append(abjad.Note.from_pitch_and_duration(pitch, (1, 32)))
    elec_literal = r"r32*6"

    electronics.extend(elec_literal)
    abjad.attach(
        abjad.LilyPondLiteral(
            r'\hide Stem'
            # r' \override MusicBoxer.fill-color =
            r' \musicBoxerStart'
            r' \set fontSize = -3'
            r' \override Staff.StaffSymbol.staff-space = #(magstep -3)'
            r' \override Staff.StaffSymbol.thickness = #(magstep -3)'
            r' \override Staff.Clef.font-size = -3'
            r' \override Staff.TimeSignature.font-size = -3'),
        electronics[0])
    abjad.attach(
        abjad.LilyPondLiteral(r'\stopStaff'
                              r' \hide Staff.BarLine'
                              r' \hide Staff.Clef'
                              r' \hide Staff.TimeSignature'), electronics[41])
    abjad.attach(abjad.LilyPondLiteral(r'\musicBoxerEnd'), electronics[41])

    # abjad.attach(abjad.Markup("  ", direction=abjad.Up), electronics[43])

    clef3 = abjad.Clef("treble^8")
    clef3_range = abjad.pitch.PitchRange("[F6, +inf]")
    clef2 = abjad.Clef("treble")
    clef2_range = abjad.pitch.PitchRange("[E4, E5]")
    clef1 = abjad.Clef("bass")
    clef1_range = abjad.pitch.PitchRange("[E2, A3]")
    clef0 = abjad.Clef("bass_8")
    clef0_range = abjad.pitch.PitchRange("[-inf, D#2]")

    selection = abjad.select(electronics).leaves()
    # selection = selection[0::3]
    for i, leaf in enumerate(selection):
        test3 = leaf in clef3_range
        test2 = leaf in clef2_range
        test1 = leaf in clef1_range
        test0 = leaf in clef0_range
        test_note = not isinstance(leaf, abjad.Rest)
        if test_note is True and test2 is True:
            abjad.attach(clef2, selection[i])
        elif test_note is True and test3 is True:
            abjad.attach(clef3, selection[i])
        elif test_note is True and test1 is True:
            abjad.attach(clef1, selection[i])
        elif test_note is True and test0 is True:
            abjad.attach(clef0, selection[i])

    del score[1]
    return electronics
Beispiel #12
0
def make_mozart_score():
    """
    Makes Mozart score.
    """
    score_template = abjad.TwoStaffPianoScoreTemplate()
    score = score_template()
    # select the measures to use
    choices = abjad.demos.mozart.choose_mozart_measures()
    # create and populate the volta containers
    treble_volta = abjad.Container()
    bass_volta = abjad.Container()
    for choice in choices[:7]:
        treble, bass = abjad.demos.mozart.make_mozart_measure(choice)
        treble_volta.append(treble)
        bass_volta.append(bass)
    # abjad.attach indicators to the volta containers
    command = abjad.LilyPondLiteral(r"\repeat volta 2", "before")
    abjad.attach(command, treble_volta)
    command = abjad.LilyPondLiteral(r"\repeat volta 2", "before")
    abjad.attach(command, bass_volta)
    # append the volta containers to our staves
    score["RH_Voice"].append(treble_volta)
    score["LH_Voice"].append(bass_volta)
    # create and populate the alternative ending containers
    treble_alternative = abjad.Container()
    bass_alternative = abjad.Container()
    for choice in choices[7:9]:
        treble, bass = abjad.demos.mozart.make_mozart_measure(choice)
        treble_alternative.append(treble)
        bass_alternative.append(bass)
    # abjad.attach indicators to the alternative containers
    command = abjad.LilyPondLiteral(r"\alternative", "before")
    abjad.attach(command, treble_alternative)
    command = abjad.LilyPondLiteral(r"\alternative", "before")
    abjad.attach(command, bass_alternative)
    # append the alternative containers to our staves
    score["RH_Voice"].append(treble_alternative)
    score["LH_Voice"].append(bass_alternative)
    # create the remaining measures
    for choice in choices[9:]:
        treble, bass = abjad.demos.mozart.make_mozart_measure(choice)
        score["RH_Voice"].append(treble)
        score["LH_Voice"].append(bass)
    # abjad.attach indicators
    time_signature = abjad.TimeSignature((3, 8))
    leaf = abjad.inspect(score["RH_Staff"]).leaf(0)
    abjad.attach(time_signature, leaf)
    bar_line = abjad.BarLine("|.")
    leaf = abjad.inspect(score["RH_Staff"]).leaf(-1)
    abjad.attach(bar_line, leaf)
    # remove the default piano instrument and add a custom one:
    abjad.detach(abjad.Instrument, score["Piano_Staff"])
    klavier = abjad.Piano(name="Katzenklavier", short_name="kk.")
    leaf = abjad.inspect(score["Piano_Staff"]).leaf(0)
    abjad.attach(klavier, leaf)
    return score
def test_scoretools_Inspection_get_indicator_07():

    note = abjad.Note("c'8")
    command = abjad.LilyPondLiteral(r'\stemUp')
    abjad.attach(command, note)
    command = abjad.LilyPondLiteral(r'\slurUp')
    abjad.attach(command, note)

    statement = 'inspect(note).get_indicator(abjad.LilyPondLiteral)'
    assert pytest.raises(Exception, statement)
Beispiel #14
0
 def _detach_centre_markup(self) -> None:
     r'Detaches the centre markup tweaks.'
     literal1 = abjad.LilyPondLiteral(
         r'\once \override TextScript.parent-alignment-X = 0')
     literal2 = abjad.LilyPondLiteral(
         r'\once \override TextScript.self-alignment-X = 0')
     if abjad.get.indicator(self, literal1):
         abjad.detach(literal1, self)
     if abjad.get.indicator(self, literal2):
         abjad.detach(literal2, self)
Beispiel #15
0
 def _handle_markup(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)
     selections = maker(music_durations)
     skips = mccartney.select(selections).skips()
     markup_voice = self._score[f"{self.instrument_name}_Markup_Voice"]
     markup_voice.extend(skips)
     expressions = self.markup
     for i, expression in enumerate(expressions):
         index = expression[0]
         markup = expression[1]
         skip = skips[index]
         if len(expression) == 3 and isinstance(expression[2], tuple):
             abjad.attach(markup, skip)
             extra_offset = expression[2]
             x, y = extra_offset
             string = fr"\once \override TextScript.extra-offset"
             string += f" = #'({x} . {y})"
             command = abjad.LilyPondLiteral(string)
             abjad.attach(command, skip)
             continue
         if 0 < i:
             stop_text_span = abjad.StopTextSpan()
             abjad.attach(stop_text_span, skip)
         if isinstance(markup, list):
             markup = markup[0]
             style = "dashed-line-with-arrow"
         else:
             style = "invisible-line"
         start_text_span = abjad.StartTextSpan(
             left_text=markup, style=style
         )
         abjad.attach(start_text_span, skip)
         if len(expression) == 3:
             staff_padding = expression[2]
             string = (
                 fr"\override TextScript.staff-padding = {staff_padding}"
             )
             command = abjad.LilyPondLiteral(string)
             abjad.attach(command, skip)
             value = staff_padding + 0.75
             string = fr"\override TextSpanner.staff-padding = {value}"
             command = abjad.LilyPondLiteral(string)
             abjad.attach(command, skip)
     stop_text_span = abjad.StopTextSpan()
     abjad.attach(stop_text_span, skips[-1])
Beispiel #16
0
 def __call__(
     self,
     _,
     container_to_process: abjad.Container,
 ):
     first_leaf = abjad.get.leaf(container_to_process[0], 0)
     abjad.attach(
         abjad.LilyPondLiteral("\\cadenzaOn"),
         first_leaf,
     )
     abjad.attach(
         abjad.LilyPondLiteral("\\omit Staff.TimeSignature"),
         first_leaf,
     )
Beispiel #17
0
    def __call__(self):

        # Violin
        violin_staff = abjad.Staff(
            [abjad.Voice(name='Violin Voice')],
            name='Violin Staff',
            lilypond_type='ViolinStaff',
        )
        violin_tag = abjad.LilyPondLiteral(r"\tag #'violin",
                                           format_slot='before')
        abjad.attach(violin_tag, violin_staff)
        abjad.setting(violin_staff).midi_instrument = abjad.scheme.Scheme(
            'violin', force_quotes=True)

        # Viola
        viola_staff = abjad.Staff(
            [abjad.Voice(name='Viola Voice')],
            name='Viola Staff',
            lilypond_type='ViolaStaff',
        )
        viola_tag = abjad.LilyPondLiteral(r"\tag #'viola",
                                          format_slot='before')
        abjad.attach(viola_tag, viola_staff)
        abjad.setting(viola_staff).midi_instrument = abjad.scheme.Scheme(
            'viola', force_quotes=True)

        # Cello
        cello_staff = abjad.Staff(
            [abjad.Voice(name='Cello Voice')],
            name='Cello Staff',
            lilypond_type='CelloStaff',
        )
        cello_tag = abjad.LilyPondLiteral(r"\tag #'cello",
                                          format_slot='before')
        abjad.attach(cello_tag, cello_staff)
        abjad.setting(cello_staff).midi_instrument = abjad.scheme.Scheme(
            'cello', force_quotes=True)

        # Everything else
        staff_group = abjad.StaffGroup(
            [violin_staff, viola_staff, cello_staff],
            name='Trio Staff Group',
        )
        score = abjad.Score(
            [staff_group],
            name='Trio Score',
        )

        return score
Beispiel #18
0
def apply_rehearsal_marks(score):
    """
    Applies rehearsal marks to score.
    """
    bell_voice = score['Bell Voice']
    measure_indices = [
        6,
        12,
        18,
        24,
        30,
        36,
        42,
        48,
        54,
        60,
        66,
        72,
        78,
        84,
        90,
        96,
        102,
    ]
    for measure_index in measure_indices:
        command = abjad.LilyPondLiteral(r'\mark \default', 'before')
        abjad.attach(command, bell_voice[measure_index])
Beispiel #19
0
def apply_page_breaks(score):
    """
    Applies page breaks to score.
    """
    bell_voice = score['Bell Voice']
    measure_indices = [
        5,
        10,
        15,
        20,
        25,
        30,
        35,
        40,
        45,
        50,
        55,
        60,
        65,
        72,
        79,
        86,
        93,
        100,
    ]
    for measure_index in measure_indices:
        command = abjad.LilyPondLiteral(r'\break', 'after')
        abjad.attach(command, bell_voice[measure_index])
Beispiel #20
0
def clef(name):
    """
    Makes a clef before a specific leaf
    """
    clef = abjad.Clef(name)
    if isinstance(clef, abjad.Clef):
        return abjad.LilyPondLiteral(f"{format(clef, 'lilypond')}", "before")
Beispiel #21
0
def test_multipage_success():
    staff = abjad.Staff("c'1 d'1 e'1 f'1")
    for leaf in staff[:-1]:
        abjad.attach(abjad.LilyPondLiteral(r"\pageBreak", "after"), leaf)
    assert format(staff) == abjad.String.normalize(r"""
        \new Staff
        {
            c'1
            \pageBreak
            d'1
            \pageBreak
            e'1
            \pageBreak
            f'1
        }
    """)
    show = abjadext.ipython.Show()
    with unittest.mock.patch(
            "IPython.core.display.display_png") as display_mock:
        with unittest.mock.patch.object(
                show, "_run_imagemagick",
                wraps=show._run_imagemagick) as convert_mock:
            show(staff)
    assert convert_mock.call_count == 4
    assert display_mock.call_count == 4
    png_path = pathlib.Path(convert_mock.call_args_list[0][0][0])
    assert not png_path.exists()
    assert not png_path.parent.exists()
Beispiel #22
0
def ottava(num):
    """Makes ottava bracket returns lilypond literal"""
    if (num >= -2) and (num <= 2):
        return abjad.LilyPondLiteral(f"\\ottava #{num}", "before")
    else:
        return ValueError(
            f"{num} not in range: must be (range >= -2) or (range <= 2)")
def test_scoretools_Inspection_get_indicators_02():

    staff = abjad.Staff("c'8 d'8 e'8 f'8")
    slur = abjad.Slur()
    abjad.attach(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]).get_indicators()
    assert comment in items
    assert command in items
    assert len(items) == 2
Beispiel #24
0
 def calc_anchor(self):
     durs = [self.leaf.written_duration, self.anchor_dur]
     container = abjad.Container()
     pre_mult = self.leaf.written_duration - self.anchor_dur
     mult = pre_mult / self.leaf.written_duration
     if isinstance(self.leaf, abjad.Chord):
         pitches = [
             abjad.NamedPitch(_) for _ in abjad.get.pitches(self.leaf)
         ]
     elif isinstance(self.leaf, abjad.Note):
         pitches = [
             abjad.NamedPitch(_) for _ in abjad.get.pitches(self.leaf)
         ]
         pitches = pitches[0]
     else:
         pass
     maker = abjad.LeafMaker()
     new_leaves = [list_ for list_ in maker([pitches], durs)]
     indicators = abjad.get.indicators(self.leaf)
     for indicator in indicators:
         abjad.attach(indicator, new_leaves[0][0])
     self.leaf.multiplier = mult
     abjad.attach(
         abjad.LilyPondLiteral(r"""\abjad-invisible-music""",
                               format_slot="before"),
         new_leaves[1],
     )
     abjad.annotate(new_leaves[1], "type", "spanner anchor")
     container.extend(new_leaves)
     return container
Beispiel #25
0
    def comment_measure_numbers(score):
        """
        Comments measure numbers in ``score``.
        """
        import abjad

        offset_to_measure_number = {}
        for context in abjad.iterate(score).components(abjad.Context):
            if not context.simultaneous:
                break
        site = "abjad.SegmentMaker.comment_measure_numbers()"
        measures = abjad.select(context).leaves().group_by_measure()
        for i, measure in enumerate(measures):
            measure_number = i + 1
            first_leaf = abjad.select(measure).leaf(0)
            start_offset = abjad.inspect(first_leaf).timespan().start_offset
            offset_to_measure_number[start_offset] = measure_number
        for leaf in abjad.iterate(score).leaves():
            offset = abjad.inspect(leaf).timespan().start_offset
            measure_number = offset_to_measure_number.get(offset, None)
            if measure_number is None:
                continue
            context = abjad.inspect(leaf).parentage().get(abjad.Context)
            if context.name is None:
                string = (
                    f"% [{context.lilypond_type} measure {measure_number}]")
            else:
                string = f"% [{context.name} measure {measure_number}]"
            literal = abjad.LilyPondLiteral(string, "absolute_before")
            tag = abjad.Tag("COMMENT_MEASURE_NUMBERS").append(site)
            abjad.attach(literal, leaf, tag=tag)
Beispiel #26
0
 def attach(self, leaf: abjad.Chord, novent) -> None:
     abjad.attach(
         abjad.LilyPondLiteral("\\flageolet",
                               directed="up",
                               format_slot="after"),
         leaf,
     )
Beispiel #27
0
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
Beispiel #28
0
def diamond_on():
    """
    Notehead style diamond
    """
    return abjad.LilyPondLiteral(
        "\\override Staff.NoteHead.style = #'diamond",
        "before",
    )
Beispiel #29
0
def harmonic_mixed_on():
    """
    Notehead style mixed rhombic
    """
    return abjad.LilyPondLiteral(
        "\\override Staff.NoteHead.style = #'harmonic-mixed",
        "before",
    )
Beispiel #30
0
def barline(style):
    """
    Makes a literal barline
    """
    if (style == "|.") or (style == "||") or (stlye == "|!"):
        return abjad.LilyPondLiteral(f"\\bar \"{style}\"", "after")
    else:
        ValueError("choose another style of barline")