yodofizzy
yodofizzy

Reputation: 83

Lilypond parentheses around pickup measure numbers

I am writing some music that includes pickup measures partway through the tune, and the bar numbering is important to me. It is crucial that the pickup measure is not counted in the measure counts, and that the first full measure should be counted instead.

I really like the way the first partial measure has a (1) in parentheses, to mark that it is the pickup to bar 1. I would like to figure out how to make the second line pickup measure here to similarly show as (5) to indicate it is a pickup to measure 5.


example = {
  \override  Score.BarNumber.break-visibility = ##(#t #t #t)
  \set Score.barNumberVisibility = #all-bar-numbers-visible
  \override  Score.BarNumber.break-visibility = #end-of-line-invisible
  \time 2/4
  \partial 8 e8 |
  a2 | b2 | c2 | \partial 8*3 d4. \bar "||" 
  \break
  \partial 8 e8 |
  \set Score.currentBarNumber = 5
  a2 | c2 | b2 | a2 \bar "|."
}


\book{
    \bookOutputName "mwe"   
  \score {
    \new Staff <<
        \new Voice {
          \example
        }    
    >>
  }
}

Minimal working example of current workaround

Currently I am overriding the bar numbering so that the first full measure in line 2 shows correctly as m5, but I'm wondering if there is a better way to have the pickup measure not count in the numbering, and have it display in parentheses like pickup to measure 1.

Upvotes: 2

Views: 48

Answers (2)

Elements In Space
Elements In Space

Reputation: 318

LilyPond’s default is to only displaying measure numbers at the start of a new line (AKA a new system) — that is, assuming the measure is unbroken, and it’s not the very first system.

To get mid-system measures to also display numbers, override the the break-visibility settings. This takes three arguments: end of line, unbroken, and beginning of line.

But rather than setting all three values to true and then changing the first one back to false (with end-of-line-invisible), it makes more sense to simply use:
\override Score.BarNumber.break-visibility = ##(#f #t #t)


A pickup (AKA an anacrusis) to a particular measure exists in the preceding measure. So the pickup to your measure 5 is really at the end of measure 4. So, if you’re breaking this measure up across the system break, and you want to give the partial measure a label, it really should be (4) not (5).

LilyPond understands this, and prints the correct parenthesised measure numbers for pickups when you use the command:
\set Score.barNumberVisibility = #all-bar-numbers-visible

Logically the pickup at the vey start of the piece should be (0). But for some reason/bug, LilyPond gets this wrong for the first system; it puts a (1).
(This bug probably hasn’t been ironed out yet because anacruses aren’t heaps prevalent, parenthesised number for them aren’t usually written, and it’s very rare to see a measure number at the start of a piece; the conjunction of these is an overlooked corner case.)

To remedy this is relatively straightforward though: Set the bar number to 0 for the pickup, and then set it to 1 for the first real measure.

You won’t need to be setting the measure numbers manually like this after the first measure (unless you really want to display the “wrong” numbers).


The \partial command should only be used at the very start of a piece (or a new time signature), so you should remove the other two instances.


\version "2.24.1"

{
    \set Score.barNumberVisibility = #all-bar-numbers-visible
    \override Score.BarNumber.break-visibility = ##(#f #t #t)
    
    \time 2/4
    
    \set Score.currentBarNumber = 0
        \partial 8
            e'8 |
    \set Score.currentBarNumber = 1
        a'2 | b'2 | c'2 | d'4. 
    \bar "||" \break
    
            e'8 | 
        a'2 | c'2 | b'2 | a'4.
    \bar "|."
}

Rendering of the above code.  The pickup at the start has the measure number “(0)”, the first complete measure has “1”, the second “2”, etc., the pickup preceding measure 5 in the second system is marked “(4)”, the fifth complete measure has “5”, etc.

Upvotes: 0

ksnortum
ksnortum

Reputation: 3057

Does \parenthesize do what you need?

example = {
  \override  Score.BarNumber.break-visibility = ##(#t #t #t)
  \set Score.barNumberVisibility = #all-bar-numbers-visible
  \override  Score.BarNumber.break-visibility = #end-of-line-invisible
  \time 2/4
  \partial 8 \parenthesize e8 |
  a2 | b2 | c2 | \partial 8*3 d4. \bar "||" 
  \break
  \partial 8 \parenthesize e8 |
  \set Score.currentBarNumber = 5
  a2 | c2 | b2 | a2 \bar "|."
}

Upvotes: -1

Related Questions