6

I am missing something basic, I spent hours searching for docs for no avail. Sometimes LilyPond can be really frustrating.

Look at this picture:

overlapping ppp

Obviously, ppp overlaps with the bar line. According to documentation, I tried using DynamicText.extra-spacing-width, but it has zero effect. Here's the code:

\version "2.22.1"
\language "italiano"

common = {
    \key sol \minor
    \time 4/4
    \tempo "Largo [Широко]"
}

right = \relative do'' {
    \key sol \major
    sol8 (fad re mi sol fad re4) |
    sol8 (fad re mib sol fad re4)
}

left = \relative do' {
    \key sol \major
    sol,8 (re' si' re,) sol, (re' do' re,) |
    sol, (re' sib' re,) sol, (re' do' re,) |
}

dynamics = {
    s1 |
    \override DynamicText.extra-spacing-width = #'(-1 . 1)
    s8 \ppp s8 s8 s8 s8 s8 s4
}

\score {
    \new PianoStaff <<
        \new Staff = "right" \right
        \new Dynamics \dynamics
        \new Staff = "left" { \clef bass \left }
    >>
}

If I move \override ... right in the front of \ppp, it doesn't overlap, but LilyPond complains then with "Unattached AbsoluteDynamicEvent".

2 Answers 2

4

I run into this a lot. I find that using an X-offset works:

dynamics = {
    s1 |
    \override DynamicText.X-offset = 0
    s8 \ppp s8 s8 s8 s8 s8 s4
}
1
  • Very intuitive :)
    – facetus
    Jul 30, 2021 at 16:32
4

This looks like a bug to me. For extra-spacing-width to work, both of the objects that should avoid each other must have some width and some height. You can visualize the "skylines" that LilyPond uses for distancing using

#(ly:set-option 'debug-skylines)
\layout {
  \context {
    \Score
    \override PaperColumn.stencil = #ly:separation-item::print
    \override NonMusicalPaperColumn.stencil = #ly:separation-item::print
  }
}

(it's expected that the ones from the lower staff are vertically off by some amount; horizontal skylines are built before line breaking, when we only have an estimation of the distance between the two staves).

This gives:

skylines

You can see that the problem is the SpanBar not receiving skylines; this is because it has no height, so the interval on which it is considered to collide is not known.

For now a workaround seems to be

\layout {
  \context {
    \Score
    \override SpanBar.Y-extent = #axis-group-interface::height
    \override SpanBar.meta.object-callbacks.pure-Y-common =
      #ly:axis-group-interface::calc-pure-y-common
    \override SpanBar.meta.object-callbacks.pure-relevant-grobs =
      #ly:axis-group-interface::calc-pure-relevant-grobs
  }
}

(there must be a reason why it is not in the current code, so be aware that it could have bad effects in cases that I have no considered).

4
  • Would this same SpanBar issue explain the problem is this question?: LilyPond: parenthesized hairpin.
    – Aaron
    Aug 1, 2021 at 7:52
  • 1
    Not fully. Spanners do not participate in horizontal spacing the same way as items with skylines, only via minimum-distance and minimum-distance-after-break as far as I can see. At least, my pending merge request gitlab.com/lilypond/lilypond/-/merge_requests/842 does not solve the case\version "2.23.4" \layout { \context { \Score \override BarLine.bar-extent = #'(-10 . 10) \override Parentheses.font-size = 10 } } \new StaffGroup << { c1\parenthesize\< 1\! } { c1 1 } >> Aug 1, 2021 at 13:52
  • I don't understand practically anything in this post. I don't understand the code, the term "skylines", how to interpret the picture, and what is SpanBar.
    – facetus
    Aug 5, 2021 at 5:59
  • 1
    Ok, - SpanBar is the grob that draws the part of the bar line between staves. To understand, try \version "2.22.1" \new StaffGroup \with { \override SpanBar.color = red } << { c1 } { c1 } >> - Skylines are outlines of objects. They are used to resolve collisions. You can view them as pieces of metal in the score, with space between them; LilyPond could compress the score until the pieces are touching each other. This applies to horizontal and vertical spacing. - The code is not supposed to be understandable. It's a horrible low-level hack. Aug 5, 2021 at 21:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.