Abjad / abjad

Abjad is a Python API for building LilyPond files. Use Abjad to make PDFs of music notation.
https://abjad.github.io
GNU General Public License v3.0
234 stars 41 forks source link

Fix \afterGrace + \pitchedTrill contention #1582

Closed trevorbaca closed 2 months ago

trevorbaca commented 2 months ago

LilyPond \afterGrace must lexically precede LilyPond \pitchedTrill. Versions of Abjad up to (and including) 3.19 get this wrong. This bug produces strange visual output. But LilyPond raises no error.

Consider this example:

voice = abjad.Voice("c'1")
abjad.setting(voice[0]).Score.proportionalNotationDuration = "#(ly:make-moment 1/16)"
container = abjad.IndependentAfterGraceContainer("e'8", fraction=(15, 16))
voice.append(container)
voice.append("r4")
start_trill_span = abjad.StartTrillSpan(pitch=abjad.NamedPitch("D4"))
abjad.attach(start_trill_span, voice[0])
stop_trill_span = abjad.StopTrillSpan()
abjad.attach(stop_trill_span, voice[-1])

Abjad 3.19 produces this output:

string = abjad.lilypond(voice)
print(string)
\new Voice
{
    \set Score.proportionalNotationDuration = #(ly:make-moment 1/16)
    \pitchedTrill
    \afterGrace 15/16
    c'1
    \startTrillSpan d'
    {
        e'8
    }
    r4
    \stopTrillSpan
}

agpt-3-19

Abjad 3.20 fixes the bug and produces this output instead:

\new Voice
{
    \set Score.proportionalNotationDuration = #(ly:make-moment 1/16)
    \afterGrace 15/16
    \pitchedTrill
    c'1
    \startTrillSpan d'
    {
        e'8
    }
    r4
    \stopTrillSpan
}

agpt-3-20