lilypond-user
[Top][All Lists]
Advanced

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

Re: automatic setting of `currentBarNumber'


From: Joe Neeman
Subject: Re: automatic setting of `currentBarNumber'
Date: Fri, 23 Jan 2009 10:21:08 -0800

On Tue, 2009-01-20 at 21:03 +0100, Werner LEMBERG wrote:
> The following problem:
> 
>   \score {
>     \relative {
>       c1 | c1 | c1 | c1 |        % Bars 1-4
>   }
> 
>   \score {
>     \relative {
>       c1 | c1 | c1 | c1 |        % Bars 5-8
>   }
> 
> I know how to manually set `currentBarNumber' in the second \score
> block:
> 
>   \set Score.currentBarNumber = #5
> 
> However, I want to have this set automatically; for example, if I
> later decide to insert two bars into the first \score block, the
> starting bar number for the second \score block should be updated
> accordingly.
> 
> It's rather straightforward to store the value of `currentBarNumber'
> in a Scheme variable (the number `10' is just a dummy value):
> 
>   #(define lastBarNumber 10)
> 
>   \score {
>     \relative {
>       c1 | d1 | e1 | f1 |
>     \applyContext
>       #(lambda (x)
>         (set! lastBarNumber (ly:context-property x 'currentBarNumber)))
>   }
> 
> However, I wasn't able to make lilypond use the computed value.  I
> tried both `\set' and `\applyContext' (using
> `ly:context-set-property!') without success.

It works for me if I put things in separate books (ie. I set
lastBarNumber in one book and read it in the next book), but not if I
put things in separate scores. I don't really know how the handling of
books differs from the handling of scores, so I'm not sure why.

Joe






reply via email to

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