Jump to content

Printing bar numbers using modulo-bar-number-visible: Difference between revisions

From LilyPond wiki
m New category
m corr
Line 5: Line 5:
* <code>(modulo-bar-number-visible 3 2)</code> -&gt; prints 2,5,8
* <code>(modulo-bar-number-visible 3 2)</code> -&gt; prints 2,5,8
* <code>(modulo-bar-number-visible 4 2)</code> -&gt; prints 2,6,10
* <code>(modulo-bar-number-visible 4 2)</code> -&gt; prints 2,6,10
* <code>(modulo-bar-number-visible 3 1)</code> -&gt; prints 3,5,7
* <code>(modulo-bar-number-visible 2 1)</code> -&gt; prints 3,5,7
* <code>(modulo-bar-number-visible 5 2)</code> -&gt; prints 2,7,12
* <code>(modulo-bar-number-visible 5 0)</code> -&gt; prints 5,10,15


<lilypond version="2.24" full>
<lilypond version="2.24" full>
Line 13: Line 13:
     \Score
     \Score
     \override BarNumber.break-visibility = ##(#f #t #t)
     \override BarNumber.break-visibility = ##(#f #t #t)
     barNumberVisibility = #(modulo-bar-number-visible 3 2)
     barNumberVisibility = #(modulo-bar-number-visible 5 0)
   }
   }
}
}

Revision as of 21:25, 28 November 2025

If the remainder of the division of the current BarNumber by the first argument of modulo-bar-number-visible equals its second argument print the BarNumber.

Useful to print the BarNumber at certain distances, p.e.:

  • (modulo-bar-number-visible 3 2) -> prints 2,5,8
  • (modulo-bar-number-visible 4 2) -> prints 2,6,10
  • (modulo-bar-number-visible 2 1) -> prints 3,5,7
  • (modulo-bar-number-visible 5 0) -> prints 5,10,15

\version "2.24"

\layout {
  \context {
    \Score
    \override BarNumber.break-visibility = ##(#f #t #t)
    barNumberVisibility = #(modulo-bar-number-visible  5 0)
  }
}

\relative c' {
  c1 | d | e | f \break
  g1 | e | d | c
}

\paper { tagline = ##f }