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?

Dubl
  • 87
  • 4
  • 1
    Related : [What's this L symbol in piano notation called?](https://music.stackexchange.com/questions/76126/whats-this-l-symbol-in-piano-notation-called/123794#123794) – Elements in Space Aug 02 '22 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 Aug 02 '22 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.) – Elements in Space Aug 02 '22 at 15:21

1 Answers1

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

Elements in Space
  • 10,785
  • 2
  • 23
  • 67
  • 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 Aug 02 '22 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. – Elements in Space Aug 03 '22 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 Aug 03 '22 at 21:31
  • I can update the question with an updated example if that would be helpful. – Dubl Aug 03 '22 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. – Elements in Space Aug 04 '22 at 05:37
  • Thanks for taking a look. I guess I copied that over wrong, you are right that it should be on a different note. As far as the scheme code, I was following [this](https://lilypond.org/doc/v2.22/Documentation/extending/new-markup-command-definition#a-complete-example) example from the documentation. Either way, I may open another question to see if anyone else might know how to fix this. Thanks again for all your help! – Dubl Aug 04 '22 at 19:36