4

I am trying to reproduce a piano score in LilyPond. It has a straight dash line between a grace note in one staff and a chord in another. I tried using \change Staff, but it either breaks the grace notes, or notes horizontal position, or makes the chord in another staff look small as grace notes.

The picture shows the desired effect.

MWE (without the dash line):

\version "2.20.0"
\language "italiano"

\score {
  \new PianoStaff <<
    \new Staff = "RH" \relative do' {
        \time 3/4
        mi'16 la mi re
        \appoggiatura {
            re32 % need a line from this re down to the second chord in the LH
            mi
        } re8 mi re4
    }
    \new Staff = "LH" \relative do' {
        \time 3/4
        \clef bass
        <fa, la mi'> <fa la re> <<
        {
            re'8 do
        } \\
        {
            <fa, la>4
        }
        >>
    }
  >>
}

desired effect

3

This is quite fiddly. I'd do below. There really might well be an easier way to do this. Line created with VoiceFollower which is used for part writing like fugues and the voice changing staves.

Need to create hidden notes which give reference to start x and y, and end x and y of VoiceFollower. Changed position of VoiceFollower and appoggiatura slur to avoid collision.

Separated the main changes into two variables (makes sense anything more than a line, put it as a variable):

  • visibileAppoggiaturaSlurAdjust (I was getting confused with the hidden one so made sense call it visible), and
  • lineGoesDown (that's obvious what it's doing!)

Changed chords in same voice in LH because it just made sense.

\version "2.20.0"
\language "italiano"

visibileAppoggiaturaSlurAdjust = \shape #'((0.3 . 0.2) (0.15 . 0.15) (0 . 0.15) (0.2 . 0.2)) Slur

lineGoesDown = {
           \change Staff = "RH"
           \override VoiceFollower.style = #'dashed-line
           \override VoiceFollower.bound-details = #'((right (attach-dir . -0.5) (padding . 0)) (left (attach-dir . -1) (padding . 0)))
           \showStaffSwitch
           \hideNotes \stemDown
           \appoggiatura { \once \override Slur.stencil = ##f  re16 } 
           
           \change Staff = "LH" re,4 
           \hideStaffSwitch \unHideNotes \stemUp
}

\score {
 \new PianoStaff <<
   \new Staff = "RH" \relative do' {
       \time 3/4
       mi'16 la mi re
       \appoggiatura {
           \visibileAppoggiaturaSlurAdjust
           re32 % need a line from this re down to the second chord in the LH
           mi
       } re8 mi re4
   }
   \new Staff = "LH" {
       \time 3/4
       \clef bass
       <<
         \relative do'' {
           
           s4 
           \lineGoesDown
           re8 do |
           
         } 
         \\
         \relative do {
           
          <fa la mi'>4 <fa la re>  <fa la> |
          
         }
       >>
   }
 >>
}

Produces:

lilypond appoggiatura dashed line cross-staff


This second one produces desired output for a repeat of the second bar where there was a bug of the voicefollower being on when it should be off but would later go back on again!

\version "2.20.0"
\language "italiano"

visibileAppoggiaturaSlurAdjust = \shape #'((0.3 . 0.2) (0.15 . 0.15) (0 . 0.15) (0.2 . 0.2)) Slur

lineGoesDown = {
           \hideStaffSwitch
           \change Staff = "RH"
           
           \override VoiceFollower.style = #'dashed-line
           \override VoiceFollower.bound-details = #'((right (attach-dir . -0.5) (padding . 0)) (left (attach-dir . -1) (padding . 0)))
           \showStaffSwitch
           \hideNotes \stemDown
           \appoggiatura { \once \override Slur.stencil = ##f  re16 } 
           
           \change Staff = "LH" re,4 
           \unHideNotes \stemUp
           \once \omit VoiceFollower
          
}

\score {
 \new PianoStaff <<
   \new Staff = "RH" \relative do' {
       \time 3/4
       \repeat unfold 2 { mi'16 la mi re
       \appoggiatura {
           \visibileAppoggiaturaSlurAdjust
           re32 % need a line from this re down to the second chord in the LH
           mi
       } re8 mi re4
       }
   }
   \new Staff = "LH" {
       \time 3/4
       \clef bass
       \repeat unfold 2 {
       <<
         \relative do'' {
           
           s4 
           \lineGoesDown
            re8 do | 
           \change Staff = "RH"
           \hideStaffSwitch
          
         } 
         \\
         \relative do {
           
          <fa la mi'>4 <fa la re>  <fa la> |
          
         }
       >>
      
       }
   }
 >>
}
5
  • Thanks! LilyPond is not for the faint of heart :).
    – facetus
    Aug 31 '20 at 5:57
  • You're welcome! LP very adaptable and there's some really nice answers on Music Stack Exchange about it!
    – user70304
    Aug 31 '20 at 6:43
  • This code has a problem I cannot solve. If I use it in two bars in a row, it connects the last do8 in the LH of the first bar to the invisible re16 in the RH of the second. I removed the macro and just copy&pasted your code and started playing with the placement of \hideStaffSwitch. Nothing helps. Is it a bug in LilyPond? Or it seems like \showStaffSwitch shows the VoiceFollower for the note preceding the switch as well.
    – facetus
    Aug 31 '20 at 8:02
  • 1
    Hopefully ok now. Take a look at the 2nd code. Would need to use \change Staff = "RH" and \hideStaffSwitch, one after the other. Need to reset and force a staff switch and hide staff switch outside of the variable otherwise it just continues. Works for me
    – user70304
    Aug 31 '20 at 8:42
  • Thanks! In the real score the bars of course are different. A single \change Staff = "RH" in the end of the first block solved the issue. Weird.
    – facetus
    Aug 31 '20 at 8:59

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.