Key cancellation form in lilypond

83 Views Asked by At

I have key changing example:

\score {
\relative c'' {
  \key bes \major
  g1
  \key g \major
  g1
}
}

It produces:

enter image description here

But i would like to have another template for this: first 2 becars, then staff bar, then sharp. Like this:

enter image description here

This is just another tradition. Does it possible in lilypond ?


Possible solutions

One solution is to force key to c major, add empty bar and only then change key to g major. (Thanks to "@mack" from #[email protected])

\relative c'' {
  \key bes \major
  g1

  \key c \major \bar ""
  s16
  \bar "|"

  \key g \major 
  g1
}

Unfortunately, there is extra space between bar and becars:

enter image description here


2

There are 2 best solutions below

0
Kapustin Alexander On

This override solve my problem:

 \override Score.BreakAlignment.break-align-orders=
  #(vector '(
             left-edge
             staff-ellipsis
             cue-end-clef
             ambitus
             breathing-sign
             signum-repetitionis
             clef
             cue-clef
             key-cancellation
             staff-bar
             key-signature
             time-signature
             custos)
           '(left-edge
                  staff-ellipsis
                  cue-end-clef
                  ambitus
                  breathing-sign
                  signum-repetitionis
                  clef
                  cue-clef
                  key-cancellation
                  staff-bar
                  key-signature
                  time-signature
                  custos)
           '(
             left-edge
             staff-ellipsis
             ambitus
             breathing-sign
             signum-repetitionis
             clef
             key-cancellation
             key-signature
             time-signature
             staff-bar
             cue-clef
             custos))
0
Elements In Space On

To fix the possible solution in your question:

  1. Make the spacer rest into a grace note, i.e. \grace {s16}.

  2. Use \once\hide Score.BarLine instead of \bar "". This is better because it hides rather than omits the barline; there will still be some space around the cancellation of the key signature.
    If you use \bar "" with a more densely packed bar then the cancellation of the key signature can overlap with the notes.

\relative c'' {
    \key g \minor
        g1 |
        
    \once\hide Score.BarLine
    \key c \major
        \grace {s16} 
    \bar "|"
    
    \key g \major
        g1 |
}

Key signature cancellation appears before the barline without unnecessary spacing