5

I am trying to add a half bracket with "r.h." next to it in my score, indicating that notes inside the bracket are to be played with the right hand. Here is an example measure from the Fugue No. 1 in C Major from the Well-Tempered Clavier Book I:

\language "english"

#(define-markup-command (piano-hand-bar-down layout props text) (markup?)
  #:properties ((bar-length 6))
  "Draw a piano hand half-bracket."
  (interpret-markup layout props
    #{
      \markup { \tiny \italic { #text } \path #0.1 #`(
        (moveto -1 ,bar-length)
        (lineto -2 ,bar-length)
        (lineto -2 0)
      )}
    #}))

#(define-markup-command (piano-hand-bar-up layout props text) (markup?)
  #:properties ((bar-length 6))
  "Draw a piano hand half-bracket."
  (interpret-markup layout props
    #{
      \markup { \tiny \italic { #text } \path #0.1 #`(
        (moveto -1 ,(- 1 bar-length))
        (lineto -2 ,(- 1 bar-length))
        (lineto -2 1)
      )}
    #}))

\parallelMusic fugueOneVoiceOne,fugueOneVoiceTwo,fugueOneDynamics,fugueOneVoiceThree,fugueOneVoiceFour {
  r2 r8 g'-3 a-4 b-3 | % 15
  d'8-2 g-5~ g16 a-5 g-4 f-3 e8-2 e-1 fs-2 g-2~ |
  s2 s8 \crescTextCresc s16\< s16\! s4 |
  b8-1
      -\tweak extra-offset #'(1 . -3.9)
      -\markup \override #'(bar-length . 7)
      { \piano-hand-bar-up "r.h." }
      e-3 a,-1 d4-1 g,8-1 d'4-1 |
  r8 g,-5 a-3 b-1 c8.-3 d32-2 c-3 b8-4 e-1 |
}

\header {
  title = "Test Piece"
}

\new PianoStaff <<
  \set PianoStaff.connectArpeggios = ##t
  \new Staff = "up" {
    <<
        \new Voice = "first" \relative {
            \voiceOne
            \fugueOneVoiceOne
        }
        \new Voice = "second" \relative {
            \voiceTwo
            \fugueOneVoiceTwo
        }
    >>
  }
  \new Dynamics {
    \fugueOneDynamics
  }
  \new Staff = "down" {
    \clef "bass"
    <<
        \new Voice = "third" \relative {
            \voiceThree
            \fugueOneVoiceThree
        }
        \new Voice = "fourth" \relative {
            \voiceFour
            \fugueOneVoiceFour
        }
    >>
  }
>>

This seems to do the job, and is fairly easy to place wherever needed. However, the staves are moved apart a significant amount, which is to accommodate the mark before it is moved by the extra-offset tweak. Here is the output without the mark:

Music without the mark

...and with the mark:

enter image description here

Does anyone know of a good way to place the symbol without affecting the rest of the layout? Or a better way to add this symbol to begin with?

3
  • 1
    Related : What's this L symbol in piano notation called? Commented Aug 2, 2022 at 14:32
  • Thanks for that link! It has some good suggestions, although it wouldn't be as useful in a situation where you need to play with hands crossed. With the code I have above, you can include the "l.h." or "r.h." as needed to indicate which hand should be used for the bracketed notes.
    – Dubl
    Commented Aug 2, 2022 at 14:48
  • 1
    Yeah, I left that link there more for other users looking for various ways to get the incomplete L-shaped half brackets to work in LilyPond. (It also links that post back to this one.) Commented Aug 2, 2022 at 15:21

1 Answer 1

5

To get that nice markup to ignore the "collision" with the upper staff, use an override of the outside-staff-prioirty as below:

...
\once \override TextScript.outside-staff-priority = ##f
b8-1
    -\tweak extra-offset #'(1 . 0.6)
    -\markup \override #'(bar-length . 7)
        { \piano-hand-bar-up "r.h." }
...

Another thing you might want to do, is to hide the half bar rest for the top voice (change r2 to s2), as it's not necessary. Then use \oneVoice and \voiceTwo to set the stem direction etc. like this:

...
s2 r8 g'-3 a-4 b-3 | % 15
\oneVoice d'8-2 g-5~ g16 a-5 g-4 f-3 
    \voiceTwo e8-2 e-1 fs-2 g-2~ |
...

If you use both of these suggestions you'll get the following, which is nice and compact: Test Piece with both suggestions applied

6
  • 1
    Thanks, that looks great! I thought there might be some property that I could set to make that work. I think the removal of that rest is also a major improvement over the old score from IMSLP that I copied this from. Thanks for all your suggestions!
    – Dubl
    Commented Aug 2, 2022 at 16:03
  • 1
    @Dubl - Actually if the piece is a strict four part counterpoint (which it is in this case - because Bach), it makes sense to keep that rest visible. Commented Aug 3, 2022 at 15:39
  • So now that I've played around with it some more, your suggestions work perfectly for the case above. If I were to add another one to the same measure, using the \piano-hand-bar-down function instead, it ends up not working anymore to eliminate that extra space. Would you have any ideas about fixing that case?
    – Dubl
    Commented Aug 3, 2022 at 21:31
  • I can update the question with an updated example if that would be helpful.
    – Dubl
    Commented Aug 3, 2022 at 21:32
  • @Dubl - I've had another look at this, and I've noticed something odd. The code above is actually applying the markup to the wrong note; it should be applying the half bracket to the E (not the B-flat). So you might want to fix that first. There are some other weird things going on with the scheme code for the markup definition. I'm not much good with scheme, but someone else might be able to help. Commented Aug 4, 2022 at 5:37

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