[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: custom multiple bar number markup function
From: |
Thomas Morley |
Subject: |
Re: custom multiple bar number markup function |
Date: |
Mon, 10 Dec 2018 21:40:40 +0100 |
Am Mo., 10. Dez. 2018 um 11:37 Uhr schrieb Thomas Morley
<address@hidden>:
>
> Am Mo., 10. Dez. 2018 um 06:18 Uhr schrieb Flaming Hakama by Elaine
> <address@hidden>:
>
> > I'm basically unsure about every step here:
> >
> > Is there such a thing as "the default measure number markup function"?
>
> Yes, look into engraver-init.ly, there you'll find for "Score":
> barNumberFormatter = #robust-bar-number-function
> barNumberFormatter is a context-property, which is set to the
> procedure 'robust-bar-number-function'
>
> robust-bar-number-function is defined in translation-functions.scm
>
> >
> > Can I specify another function to be used instead of the
> > default measure number markup function, and if so, how?
>
> Yes - see below
>
> > Can I invoke this new measure number markup function on an as-needed basis--
> > not replace the default measure number markup function, since I would use
> > that
> > everywhere other than the places I explicitly specify to use the new one?
>
> You would need to replace the default by the customized function and
> re-enable the default afterwards.
>
> >
> > Can I supply this function with a number-type argument?
>
> Sure.
>
> > Within my new measure number markup function, how can I access the current
> > measure number?
>
> It's internally delivered, see the the 'barnum'-argument of
> 'robust-bar-number-function'
>
> > Within my new measure number markup function, how can I add numbers?
>
> Simple addition
>
> > Within my new measure number markup function How can I turn a number into
> > markup?
>
> Convert into string.
>
> > Here is pseudocode, of what I thought the function might look like.
> > It doesn't work because, among other things,
> > * I don't know how to convert a number to a markup.
>
> See above
>
> > * I don't know how to override the default measure number markup function.
>
> Set the context-property 'barNumberFormatter' to the new procedure.
>
> > * The syntax of "let" is also confusing (I have to enclose everything
> > in another set of parens just to have scope where the variable is defined?)
>
> Well, I'd recommend to work through a guile/scheme tutorial.
>
> \version "2.19.82"
>
> #(define (double-bar-number increase-amount)
> (lambda (barnum measure-pos alt-number context)
> #{
> \markup
> \override #'(baseline-skip . 2)
> \center-column {
> #(number->string (+ increase-amount barnum))
> #(robust-bar-number-function barnum measure-pos alt-number context)
> }
> #}))
Likely better to use the default procedure for both, making for:
#(define (double-bar-number increase-amount)
(lambda (barnum measure-pos alt-number context)
#{
\markup
\override #'(baseline-skip . 2)
\center-column {
#(robust-bar-number-function
(+ increase-amount barnum) measure-pos alt-number context)
#(robust-bar-number-function
barnum measure-pos alt-number context)
}
#}))
>
> \layout {
> \context {
> \Score
> \override BarNumber.break-visibility = ##(#f #t #t)
> }
> }
>
> % bass part
> \score {
> \relative c {
> \clef bass
> c1 | 1 | 1 | 1 | \break
> \set Score.barNumberFormatter = #(double-bar-number 4)
> \repeat volta 2 {
> \bar "[|:"
> b1 | 1 | 1 | 1
> \bar ":|]"
> } \break
> \set Score.barNumberFormatter = #robust-bar-number-function
> \set Score.currentBarNumber = #13
> e1 | 1 | 1 | 1 |
> }
> }
>
>
> Cheers,
> Harm