# Lilypond: Putting left hand notes on treble clef - one more question

Similar to my earlier question - How to put Left hand notes on the treble clef

But this still has me stumped -

This is what I am trying to achieve:

This is what I am getting:

My right hand is:

\repeat volta 2 {
\time 4/4
r4^"8. Cartwheels" c4 e4 g4|
\hideStaffSwitch
\change Staff = "left"
R1
\change Staff = "right"
|
r4 c,4 e4 g4 |
s2 c,2 | R1 \bar "|."
}

My left hand is:

\repeat volta 2 {
\stemUp
\showStaffSwitch
c'4_5 r4 r2
\change Staff = "right"
c''1_2
\change Staff = "left"
|
c,,4_5 r4 r2
\change Staff = "right"
\stemDown
c''2
\change Staff = "left"
r1
c,,1-5
}

My questions are:

1. How can we get those nicely curved-dashed staff change lines in lilypond?

2. How can the staff change be shown to begin immediately after the c4 note on the bass clef in measure one - instead of the r2? If I do the switch starting after the c4 - the c1 full note comes on to the treble clef right in the middle of measure 1!

3. How should the second measure be written - Where should the rest in the second measure be placed? In the left hand part after switching back having played the c1 OR do a staff switch in the right hand part->go to the bass clef and put in an R1 and switch back to the right hand staff ... I tried the former, but it did not look right and I got some warnings, I tried the latter and now it looks OK as in the picture - but it does not feel OK :-) (why should the right hand do a rest on the bass clef)

4. Why are we getting an extra measure at the end of the left hand part?

• Something you may want to decide for yourself is whether you want to follow the top notation exactly or offer a more "correct" way of doing things. As I see it, the top option is notated for beginners and treats some rests idiosyncratically; a more correct notation is what you can see in Elements in Space's answer. Commented Nov 29, 2021 at 13:49
• @Richard I would not say it’s more correct. This thing does not really specify a staff switch, but rather taking notes from one hand into the other hand. So the high c is not actually part of the lower voice, which would be implied the other way. Rather it is very common in piano music to simply annotate notes that should be taking into the other hand by m.s. or m.d. (or like here L.H., R.H.).
– Lazy
Commented Nov 29, 2021 at 20:03

I don't know how to make the staff-switch voice follower line to be curves, but I think I can answer some of your other questions:

• The rest in the second measure should stay in the treble clef, but go down a bit to accommodate the high note of the left-hand voice. This can be achieved by getting rid of the staff switches in the right hand and placing \once\voiceTwo before this rest instead. Similarly, the s2 in the fourth bar of the right-hand should be a visible rest r2 with a \once\voiceTwo before it, to move it down a little.

• The r1 in the second last bar of the left-hand should be an r2, this is causing the extra half bar at the end.

• To make the staff-switch line dashed, use:
\override VoiceFollower #'style = #'dashed-line

You should get something like this:

As mentioned, I am not sure how to make the staff-switch lines to be curves, but if you can figure out how to get curves, it should prevent the line from colliding with the rest in the second bar.

I don't really understand your question 2.
You could just move the staff switch to before the rests in the first bar of the left-hand (so the rest go into up the top of the treble clef), this doesn't look great. But having the staff-switch line before the rests just seems confusing — the rests belong to the voice.

# Alternative Approach:

For this particular piece of music, I think it is worth considering an interpretation that there is only one voice. This voice crosses staves and is played by both hands.

Thinking about the music this way warrants the use of \autoChange (or \autochange if you are using a version older that 2.21). This makes the score much cleaner; eliminating the need for rests. The coding is much simpler too, and the dashed lines are easy to implement with a phrasing slur.

\new PianoStaff
<<
\new Staff = "up" {
\clef "treble"
}
\new Staff = "down" {
\clef "bass"
\phrasingSlurDashed
\autoChange b {
\repeat volta 2 {
c4$$_5 c'-1 e'-3 g'-5 | c''1$$_2^\markup{\italic"L.H."} |
c4$$c' e' g' | c''2$$^\markup{\italic"L.H."} c' |
c1 |
}
}
}
>>

• thank you! ... one question - the rest in the second measure is visible in the bass clef in the original picture ... but you mentioned in the beginning of the answer that it should stay in the treble clef - did you mean the other way around? Commented Nov 29, 2021 at 13:49
• Also, in measure four, the original shows just one R1 in the bass clef - does that belong to RH or LH? In the picture that you posted - there are two R2s - one in between the two staves, and one in the bass clef. Logically - what you have posted seems correct, is the fourth measure of the original picture incorrect? Okay - this one is answered by Richard's comment on the question, I think. Commented Nov 29, 2021 at 13:51
• @saraf — Oh, I didn't really look much at the original image this time. I got my image as I intended, but it just doesn't agree with the image you provided. I was thinking of each hand as a voice, that must have note (or rest) at all times (which is reflected in your code structure). But your original image appears to be thinking each clef as a voice. Commented Nov 29, 2021 at 14:09
• @saraf (I don't know why it's organised differently to your previous question.) If you do want to get the same thing as the original image, it is much easier to code, (just do one staff at a time and don't use and staff switches at all) but then I don't know how you'll be able to get switch lines. Commented Nov 29, 2021 at 14:21
• Okay ... got the answer to the first comment of mine ... "the rest in the second measure is visible in the bass clef in the original picture ... but you mentioned in the beginning of the answer that it should stay in the treble clef - did you mean the other way around?" ... the answer is that logically - the rest ACTUALLY IS for the treble hand, but for unknown/stylistic reasons - the original author has put it in the bass clef. Commented Nov 29, 2021 at 14:39

The extra measure come from you specifying r1 in the left hand after the second cross staff c. You have an extra half note everything starting at this point is shifted.

To get the cross-staff c and the rest you can simply create a new Voice in the left hand containing the rest.

For the curved lines I’d suggest using tweaked Phrasing slurs, something like

#(define right-arrow-and-lh-over-to-slur
(grob-transformer 'stencil (lambda (grob orig)
(let* ((cpts (ly:grob-property grob 'control-points))
(raw-arrow (grob-interpret-markup grob (markup #:arrow-head Y DOWN #t)))
(arr-ext (ly:stencil-extent raw-arrow Y))
(arr-neg-height (- (car arr-ext) (cdr arr-ext)))
(corrected-arrow (ly:stencil-translate-axis raw-arrow arr-neg-height Y))
(arrow (ly:stencil-translate corrected-arrow right-coord))
(lh-raw (grob-interpret-markup grob (markup #:fontsize -2 #:italic "L.H. over")))
(lh-cent (ly:stencil-aligned-to (ly:stencil-aligned-to lh-raw X CENTER) Y DOWN))
(middle-coord (cons (/ (+ (car middle-left-coord) (car middle-right-coord)) 2) (/ (+ (cdr middle-left-coord) (cdr middle-right-coord)) 2)))
(lh (ly:stencil-translate lh-cent middle-coord)))
(display middle-coord)
orig arrow lh)))))

right = \repeat volta 2 {
\time 4/4
r4 c'4-1 e'4 g'4|
\change Staff = "left"
R1
\change Staff = "right"
|
r4 c'4 e'4 g'4 |
s2 c'2-\tweak parent-alignment-X #CENTER ^\markup\smaller\smaller\italic\center-align "R.H." | R1 \bar "|."
}

left = \repeat volta 2 {
\clef bass
\phrasingSlurDashed
\override PhrasingSlur.thickness = #0.6
\override PhrasingSlur.stencil = #right-arrow-and-lh-over-to-slur
\shape #'((-0.4 . 3) (-1 . 9) (0 . 4) (0.3 . 1.7)) PhrasingSlur
c4_5^$$r4 r2 \change Staff = "right" c''1-\tweak Y-offset -1.5 -\tweak whiteout 1 _2$$-\tweak parent-alignment-X #CENTER _\markup\smaller\smaller\italic\center-align "L.H."
\change Staff = "left"
|
\shape #'((-0.4 . 3) (-1 . 9) (0 . 4) (0.3 . 1.7)) PhrasingSlur
c4_5$$r4 r2 << { \change Staff = "right" c''2$$-\tweak Y-offset -1.5 -\tweak whiteout 1 _2-\tweak parent-alignment-X #0.6 _\markup\smaller\smaller\italic\center-align "L.H."
\change Staff = "left"
}
\new Voice R1
>>
c1-5
}

\new PianoStaff <<
\new Staff = "right" \right
\new Staff = "left" \left
>>

which then results in something like this:

• Thanks for this! :-) Looks like I'm going to have to learn Guile programming! Which book would be a good start? Commented Nov 30, 2021 at 6:42
• @saraf Guile is basically the GNU implementation of scheme (hence the name). That being said, you more or less only need some basic knowledge of scheme/guile here. Rather you’d need some understanding how Lilypond and the scheme interface to lilypond works. Helpful resources are lilypond.org/doc/v2.23/Documentation/internals/scheme-functions the documentation of available scheme functions, and of course extending-lilypond.readthedocs.io/en/latest the documentation on extending lilypond. Also asking questions on the user mailing list [email protected] is a good idea.
– Lazy
Commented Nov 30, 2021 at 7:35
• @saraf Also of course all changes to the PhrasingSlur can be applied to specific Phrasing Slurs by using \once\override (or \temporary\override and \revert) or \tweak.
– Lazy
Commented Nov 30, 2021 at 18:03