3

Sometimes, when a piece of music has a frequently-changing time signature, the time signature is printed above the staff. In the following example, only the numerator is printed (the denominator is 4 throughout):

Example

I know that this could be achieved in LilyPond by hiding the usual time signatures and manually displaying the numbers. Is it possible to do this by modifying the time signature engraver instead?

5

You can use a variation of this snippet and use a dynamics context to display the time signatures, like in the following example:

\version "2.18.2"

\score {
  <<
  \new Dynamics {
    \time 2/4 s2
    \time 3/4 s2.
    \time 4/4 s1
  }
  \new Staff \relative c' {
    \key es \major
    \clef treble
    << { g'8[-3^\markup { \italic "sempre legato" } a b] s } \\ 
       { es,[-3\pp f g <b, d>] } >>
    << { es[-2 f-1 g a <g-1 b-4> <as-2 c-5>] } \\
       { c,[-4 d es f] s s } >>
    << { s es[-2 f g-1 a b c d]-5 } \\
       { <b,-5 d>[ c d es f g-3 a b] } >>
  } 
  >>

  \layout {
    \context {
      \Score
      \override SpacingSpanner.base-shortest-duration = #(ly:make-moment 1/32) 
    }
    \context {
      \Dynamics
      \consists "Time_signature_engraver"
      \override TimeSignature.style = #'single-digit
      \override TimeSignature.break-align-symbol = ##f
      \override TimeSignature.X-offset = #ly:self-alignment-interface::x-aligned-on-self
      \override TimeSignature.self-alignment-X = #CENTER
      \override TimeSignature.after-line-breaking = #shift-right-at-line-begin
    }
    \context {
       \Staff
       \remove "Time_signature_engraver"
    }
  }
}

The above should render as:

enter image description here


If you only want to change one single Dynamics context, you can also use

[...]

  \new Dynamics \with {
    \consists "Time_signature_engraver"
    \override TimeSignature.style = #'single-digit
    \override TimeSignature.break-align-symbol = ##f
    \override TimeSignature.X-offset = #ly:self-alignment-interface::x-aligned-on-self
    \override TimeSignature.self-alignment-X = #CENTER
    \override TimeSignature.after-line-breaking = #shift-right-at-line-begin
  } {
    \time 2/4 s2
    \time 3/4 s2.
    \time 4/4 s1
  }

[...]

And delete the stuff from \layout.

  • This is great, but settings in \layout { \context { \Dynamics } } affect every Dynamics context in this score-block. What should be done to get this effect if there is another unrelated Dynamics context, e.g. one containing dynamics or one containing piano-pedalling? – Rosie F Oct 15 at 6:20
  • You are right. You can directly put the directions into the relevant Dynamics context with \with. See my edit. – Jasper Habicht Oct 15 at 8:20

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.