8

With Lilypond, is it possible to move the "sustain off" allways by a fixed offset?

I can tweak it with -\tweak X-offset 1 like this:

\relative c' { c8 c c\sustainOn c-\tweak X-offset 1\sustainOff c c c c }

enter image description here

Question: can I obtain the X-offset of all my sustainOff without having to add the tweak everytime?

2 Answers 2

7

You can redefine the sustain off at the top of your code:

sustainOff =
    #( define-event-function () ()
        #{
            -\tweak X-offset #1  %%%  Adjusts this number 
            -#(make-span-event 'SustainEvent STOP)
        #}
    )

\relative c' { c8 c c\sustainOn c\sustainOff c c c c }

lilypond output with sustain off redefined

4
  • Awesome! I searched through the internal program code and had this idea, because I’m pretty sure I did this to something else (much simpler), but I wouldn’t have come up with something this neat. OOC, if you do a \sustainOn on the note following the Off, it collides with the mark. Without this tweak, LilyPond automatically resizes width between notes to prevent that from happening. Any ideas for preserving that behavior?
    – Neal
    Mar 31, 2021 at 14:01
  • If you put the \sustainOff and \sustainOn on the same note LilyPond spaces them appropriately (but ignores the tweak for some reason). Mar 31, 2021 at 14:31
  • Personally I usually use \set Staff.pedalSustainStyle = #'mixed, which also works pretty well. But this doesn't use the pretty asterisk. Mar 31, 2021 at 14:35
  • 1
    Worth pointing out that the use of a support function and "refactoring" this way is highly recommended any time you have a repeated need for a particular effect. This is taught (I hope!!!) in most intro-software programming courses. Mar 31, 2021 at 15:15
2

One possible solution is to have a dedicated Dynamics staff for just the pedal markings. Instead of including the pedals in, say, the left-hand notation, you can include them separately. One positive to this, in my opinion, is that the pedal markings are all notated at a uniform distance from the staff, as opposed to them being engraved at several distances from the staff.

Using this separate pedal staff, a simple \override SustainPedal.X-offset = #3 (or whatever distance you want) should do the trick.

\version "2.20.0"
\language "english"

right = \relative c'' {
  c4 c c c |
  c c c c |
}

left = \relative c' {
  c4 c c c |
  c c c c |
}

pedal = {
  \override SustainPedal.X-offset = #3
  s4\sustainOn s\sustainOff s4 s |
  s s\sustainOn s\sustainOff s |
}

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

enter image description here

3
  • 1
    I think the question is about only the "off." I think your solution affects both the "on" and "off."
    – Neal
    Mar 31, 2021 at 12:31
  • @Neal Oh, dang it...you're right, of course. I'll think about this and see if I have a better idea.
    – Richard
    Mar 31, 2021 at 12:46
  • (Elements in Space beat me to that better idea. Upvote their answer!)
    – Richard
    Mar 31, 2021 at 21:55

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.