3

When trying to create an ossia Staff, that is used multiple times, above a PianoStaff, Lilypond does not reuse the context, but creates a new one. How can I tell Lilypond to find the existing context outside the PianoStaff?

\version "2.20.0"
<<
  \new Staff = "ossia" \with {
    \remove "Time_signature_engraver"
    \remove "Clef_engraver"
    fontSize = #-3
    \override StaffSymbol.staff-space = #(magstep -3)
    \override StaffSymbol.thickness = #(magstep -3)
    %alignAboveContext = "left"
  }
  { \stopStaff s1*5 }

  %\new PianoStaff = "piano" \with { instrumentName = "Piano" } % <<< if I add this, it does not find the context anymore
  <<
    \new Staff = "right" \relative {
      c'4 b c2
      <<
        { e4 f }
        \context Staff = "ossia" {
          \startStaff e4 e8 f \stopStaff
        }
      >> e2
      g4 a g2
      <<
        { g4 a }
        \context Staff = "ossia" { 
          %\change Staff = "ossia"
          \startStaff g4 e8 f \stopStaff
          %\change Staff = "right"
        }
      >> g2
      e4 d c2
  }
  \new Staff = "left" \relative { \clef F c1 c c c c }
  >>
>>

Without PianoStaff: Ossia Staff without PianoStaff

With PianoStaff: Ossia Staff with PianoStaff

Note: I also tried to add the ossia Staff inside the PianoStaff: that works for the ossia staff, but it centers the name of the instument wrongly: Ossia Staff inside PianoStaff

1
  • 1
    You should probably stick with the last one and mess with \override Staff.InstrumentName.extra-offset = ..., or whatever property will give you the spacing you want. – Kilian Foth Apr 15 '20 at 16:07
2

Does this work for you?

\version "2.20.0"

\new PianoStaff = "piano" \with {
  \override InstrumentName.extra-offset = #'(0 . -4)
  instrumentName = "Piano"
} <<
  \new Staff = "ossia" \with {
    \remove "Time_signature_engraver"
    \remove "Clef_engraver"
    fontSize = #-3
    \override StaffSymbol.staff-space = #(magstep -3)
    \override StaffSymbol.thickness = #(magstep -3)
    %alignAboveContext = "left"
  }
  { \stopStaff s1*5 }

  <<
    \new Staff = "right" \relative {
      c'4 b c2
      <<
    { e4 f }
    \context Staff = "ossia" {
      \startStaff e4 e8 f \stopStaff
    }
      >> e2
      g4 a g2
      <<
    { g4 a }
    \context Staff = "ossia" {
      %\change Staff = "ossia"
      \startStaff g4 e8 f \stopStaff
      %\change Staff = "right"
    }
      >> g2
      e4 d c2
    }
    \new Staff = "left" \relative { \clef F c1 c c c c }
  >>
>>
2

since I use ossia in piano scores for left and right hand, the only solution I found works with markup only

\version "2.20.0"


\include "english.ly"

#(set-default-paper-size "a4")
#(set-global-staff-size 14)



staffUpper = {\change Staff = RightHand}
staffLower = {\change Staff = LeftHand}


global = { %\easyHeadsOn
  \key c \major
  \numericTimeSignature
  \time 4/4
}

RHI = \relative c' {
  \voiceOne
  \global
  
  c4 d e f
  c4 d^\markup{\hspace #-12
             \score {
    \new Staff \with {
      \remove "Time_signature_engraver"
      \magnifyStaff #2/3
      firstClef = ##f
    }
    {\clef bass \relative c {\partial 1 c4 d f e f }}
  }} 
   e f
  c4 d e f
 
  
}  

RHII = \relative c' {
  \voiceTwo
  \global
}

LHI = \relative c, {
  \voiceThree
  \global

c4 d e f
  b,4 d4 e_\markup{\hspace #-12
             \score {
    \new Staff \with {
      \remove "Time_signature_engraver"
      \magnifyStaff #2/3
      firstClef = ##f
    }
    {\clef bass \relative c {\partial 2 c4 d f e f }}
  }}
  
     f
  c4 d e f

}

LHII = \relative c' {
  \voiceFour
  \global
} 


Dynamics = {
}


\score
{
  \new PianoStaff \with {
  }
  <<
    \new Staff="RightHand"{ \clef treble
    <<
      \new Voice = "RFirst"
      \relative c'
      \RHI
      \new Voice= "RSecond"
      \RHII
    >>}
    
    \new Staff="LeftHand" { \clef bass
    <<
      \new Voice = "LFirst"
      \relative c'
      \LHI
      \new Voice= "LSecond"
      \LHII
    >>}
  >>
  \layout { }
  \midi { }
}

Output: Ossia left and right

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.