lilypond-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re[2]: Bar Numbers With Letters


From: Steph Phillips
Subject: Re[2]: Bar Numbers With Letters
Date: Tue, 24 Dec 2024 20:15:07 +0000
User-agent: eM_Client/10.1.4588.0

Okay, with a little tinkering I got the result I was looking for. Just going to send it out so anyone looking for this solution in the future has something to refer to!

```
LetteredMeasureNumber =
#(define-music-function
  (target-measure letter)
  (number? markup?)
  #{
    % 1) Force currentBarNumber to the desired number.
    \once \set Score.currentBarNumber = #target-measure

    % 2) Override the bar-number stencil once
    \once \override Score.BarNumber.stencil =
      #(lambda (grob)
         (let* ((text (ly:grob-property grob 'text))
                (m-num (ly:grob-property grob 'measure-number)))
           (grob-interpret-markup
            grob
            #{ \markup \concat { #text #letter } #})))
  #})
```

------ Original Message ------
From "Kieren MacMillan" <kieren@kierenmacmillan.info>
To "Steph Phillips" <stephbotcoder@gmail.com>
Cc "Lilypond-User Mailing List" <lilypond-user@gnu.org>
Date 12/24/2024 6:14:50 AM
Subject Re: Bar Numbers With Letters

Hi Steph,

Here’s a start on doing it directly:

%%%  SNIPPET BEGINS
\version "2.23.82"

music = \relative c' {
  \set Score.currentBarNumber = #46
  \override Score.BarNumber.break-visibility = ##(#t #t #t)
  c4 d e f
  c4 d e f |
  \set Score.currentBarNumber = #48
  c4 d e f |
  \temporary \override Score.BarNumber.stencil =
   #(lambda (grob)
     (let ((text (ly:grob-property grob 'text)))
      (grob-interpret-markup grob
       #{ \markup \concat { #text "A" } #})))
  \set Score.currentBarNumber = #48
  c4 d e f
  \set Score.currentBarNumber = #48
  c4 d e f
  \set Score.currentBarNumber = #48
  c4 d e f
  \revert Score.BarNumber.stencil
  c4 d e f
  c1 \bar "|."
}

{ \music }
%%%  SNIPPET ENDS

Obviously you’ll want to figure out how to get the letters to increment while 
the numbers aren’t incrementing, and wrap it all in a music function so you can 
simply write

%%%  SNIPPET BEGINS
\version "2.23.82"

alternativeBarNumbers = …

music = \relative c' {
  […]
  c4 d e f
  \alternativeBarNumbers
  c4 d e f
  c4 d e f
  c4 d e f
  \undo \alternativeBarNumbers
  c4 d e f
  c1 \bar "|."
}

{ \music }
%%%  SNIPPET ENDS

or similar.

Hope that helps!
Kieren.

 On Dec 24, 2024, at 7:50 AM, Kieren MacMillan <kieren@kierenmacmillan.info> 
wrote:

 Hi Steph,

 I'm looking for how to set some bar numbers in my score to have letters.
 For example:
 46, 47, 48, 48A, 48B, 48C, 49, etc...
 I've been looking at the documentation and I see how to achieve this for 
\repeat'ed bars, but this is just sequential music and so the example in the 
documentation doesn't really apply here.

 Well, you could always abuse repeats…  ;)

 %%%  SNIPPET BEGINS
 \version "2.23.82"

 music = \relative c' {
  \override Score.BarNumber.break-visibility = ##(#t #t #t)
  \set Score.alternativeNumberingStyle = #'numbers-with-letters
  \set Score.currentBarNumber = #46
  c4 d e f |
  c4 d e f
  %%  temporarily suppress VoltaBracket
  \temporary \omit Score.VoltaBracket
  \repeat volta 4 {
    %%  override the default repeat-begin barline
    \bar "|"
    %%  here’s the un-lettered measure
    c4 d e f |
    %%  rewind bar number!
    \set Score.currentBarNumber = #48
    %%  abuse alternatives to generate lettered measures
    \alternative {
      \volta 1 { c4 d e f \bar "|" }
      \volta 2 { d4 e f g \bar "|" }
      \volta 3 { e4 f g a \bar "|" }
  }}
  %%  reset so subsequent repeats display as expected
  \undo \omit Score.VoltaBracket
  c1 \bar "|."
 }

 { \music }
 %%%  SNIPPET ENDS

 I’m sure there’s a way by just overriding regular measure numbers — I just 
wanted to see if I could do it this way! LOL

 Hope that helps,
 Kieren.
______________________________________________

My work day may look different than your work day. Please do not feel obligated 
to read or respond to this email outside of your normal working hours.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]