lilypond-devel
[Top][All Lists]
Advanced

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

Re: automatic setting of `currentBarNumber'


From: Nicolas Sceaux
Subject: Re: automatic setting of `currentBarNumber'
Date: Sat, 24 Jan 2009 13:20:43 +0100

Le 23 janv. 09 à 07:19, Werner LEMBERG a écrit :

#(define lastBarNumber 10)

 \score {
   \relative {
     c1 | d1 | e1 | f1 |
   \applyContext
     #(lambda (x)
       (set! lastBarNumber (ly:context-property x 'currentBarNumber)))
 }

The procedure argument of \applyContext is applied when the music is
interpreted. However, you want to use lastBarNumber when the following
score is parsed, which happens before the first score is interpreted:

\score {
  \relative {
    \set Score . currentBarNumber = #lastBarNumber
    ...
  }
}

currentBarNumber must be an integer, so the value is computed at parsing
time. If it could be a procedure, which evaluation would be delayed at
music interpretation time, then it would be possible. That requires
modifying LilyPond code (unless I'm missing something).

For a possible solution, see the attached patch.

Attachment: bar-number-proc.patch
Description: Binary data




\version "2.12.1"

#(define bar-number-proc #f)
#(define set-previous-bar-number! #f)

#(let ((previous-bar-number 0))
  (set! bar-number-proc
        (lambda (num) (+ num previous-bar-number -1)))
  (set! set-previous-bar-number!
        (lambda (num) (set! previous-bar-number num))))

\score {
  \relative {
    \bar "" c1 |\break d1 |\break e1 |\break f1 |
    \applyContext
    #(lambda (x)
(set-previous-bar-number! (ly:context-property x 'currentBarNumber)))
  }
}

\score {
  \relative {
    \set Score . currentBarNumberProc = #bar-number-proc
    \bar "" c1 |\break d1 |\break e1 |\break f1 |
  }
}


reply via email to

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