lilypond-user
[Top][All Lists]
Advanced

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

Re: [Question] How to increment the current bar number


From: Torsten Hämmerle
Subject: Re: [Question] How to increment the current bar number
Date: Sun, 2 Sep 2018 12:21:09 -0700 (MST)

David Kastrup wrote
> Malte Meyn <

> lilypond@

> > writes:
> 
>> You have to get the Score context somehow. This can be done by using
>> \applyContext. I don’t know what context the procedure then is called
>> with (maybe the current Bottom?)
> 
> The current "whatever".  Since you already had R1*3 descend to Bottom,
> that would be Bottom.


How about using ly:context-property-where-defined?
As in:


%%%%%%%%%%%%%%%
\version "2.19.82"

increaseBarNumber =
#(define-music-function (par loc addm) (integer?)
   (make-apply-context
    (lambda (context)
      (let* ((where (ly:context-property-where-defined context
'currentBarNumber))
             (cbn (ly:context-property where 'currentBarNumber)))
        (ly:context-set-property! where 'currentBarNumber (+ addm cbn))))))


testmusic = \relative {
  c'4 d e f g a b c d e f g a b c2 R1*3
  c4 b a g f e d c b a g f e d c2
}

\score {
  <<
    \new PianoStaff <<
      \new Staff { R1*22 }
      \new Staff{
        \testmusic
        <>^"↓ increase barnumber by 100"
        \increaseBarNumber #100
        \testmusic
      }
    >>
    \new Staff { \testmusic \testmusic }
  >>
}%%%%%%%%%%%%%%%

All the best,
Torsten





--
Sent from: http://lilypond.1069038.n5.nabble.com/User-f3.html



reply via email to

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