3

Consider the following notation:

The slur in the top staff looks normal to me; the end points of the slur are located above the end of the note stem.

But the second slur is less ideal, because its endpoints are located by the notehead.

Is there any kind of global override I can use such that all slurs (including phrasing slurs) look like the first one and not the second one? I expected something in the internals slur documentation, but nothing has worked so far.

I'm specifically looking for something that would correct all slurs in a score, not something that I have to tweak for each individual slur that is affected.

\version "2.20.0"

violin = \relative c'' {
  g4( a b c |
  b2 a) |
  
}

\score {
  \new Staff \violin
  \layout { }
}

%%%%%

violin = \relative c'' {
  g4( f r f |
  e)
  
}

\score {
  \new Staff \violin
  \layout { }
}
10
  • I just don't like slurs that are mixed up with the staves. Top one looks ideal. Why couldn't the second be the same idea? – Tim Feb 22 at 14:14
  • @Tim I believe that the problem comes from the lilypond's automatic computation of slur anchor points. – musicamante Feb 22 at 14:36
  • I don't know lilypond very well, but it feels strange that it automatically puts the slurs above in the second example, as it would probably be more correct to have it down (using \slurDown). In any case, they can be overridden using something like ` \override Slur.positions = #'(3 . 2)` – musicamante Feb 22 at 15:08
  • @musicamante Yes, I'm currently tweaking each individual slur. But ideally there's something global that could tweak all affected slurs at once. – Richard Feb 22 at 15:13
  • 2
    The reason that lilypond is doing such a bad job with the second slur, is because that rest is throwing it off. What is a rest doing in a slur anyway? – Elements in Space Feb 22 at 15:33
2

To accomplish this, use the stem-encompass-penalty property of the Slur and PhrasingSlur interfaces.

stem-encompass-penalty
Demerit to apply when stems collide with a slur.

from the Lilypond documentation

This avoids the stem collision, but it centers the slur endpoints to the note heads.

violin = \relative c'' {
  g4( a b c |
  b2 a) |
  g4( f r f |
  e)
  
}

\score {
  \new Staff \violin
  \layout {
    \context {
        \Voice
        \override Slur details = #'((stem-encompass-penalty . 30.0))
    }
  }
}

In order to re-align the slurs to the edge of the note-heads, use \shape.

violin = \relative c'' {
  g4( a b c |
  b2 a) |
  g4( f r f | e)  
}

\score {
  \new Staff \violin
  \layout {
    \context {
        \Voice
        \override Slur details = #'((stem-encompass-penalty . 30.0))
    }
    % align slur endpoints to the right edge of their respective note heads
    \shape #'((0.5 . 0) (0 . 0) (0 . 0) (0.5 . 0)) Slur
  }
}

LilyPond \shape documentation

7
  • Yes, this is getting closer. It does change the x-alignment of the slur, though; it pushes them slightly to the left (centered above the notehead, it seems, and not the stem). Obviously I could fix that with an x-offset... But I may wait a little to accept this, if that's alright! – Richard Jun 14 at 23:51
  • @Richard Yes, of course. If time permits, I'll look into it further. – Aaron Jun 14 at 23:55
  • I'll be looking into it further, as well. Considering some of the Lily problems that people solve here, I'm surprised it took so long to get a solution to this one. Which tells me it may be trickier than I think. – Richard Jun 14 at 23:57
  • @Richard As far as I've gotten with this, you can align the slur endpoints to either end of their respective note heads, but to align to the stems, you need to know which side of the note the stem is on (or if there is a stem at all), and I suspect this would require Scheme code. That would be the next area of investigation if the current solution isn't sufficient. – Aaron Jun 15 at 3:36
  • This is exactly my fear, unfortunately: I have several of these slurs and phrasing slurs, and I would hate to have to shape every single one of them. Ideally there could be a global override that I could do to address this. I figured I could do it with some sort of y-axis staff-padding, but I haven't been able to find anything that works yet. – Richard Jun 15 at 13:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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