2011/1/16 James Lowe <james.l...@datacore.com>: > Hello, > > -----Original Message----- > From: Graham King <lilyp...@tremagi.org.uk> > Date: Sun, 16 Jan 2011 21:11:25 +0000 > To: "lilypond-user@gnu.org" <lilypond-user@gnu.org> > Subject: How to do simple arithmetic on bar numbers? > >>I'm preparing a modern-notation edition of a piece of choral renaissance >>polyphony, in which the maxima at the end of each section is notated as >>a neomensural "\maxima*n/m" (where, for each part, n,m are chosen to >>cause all the parts to end the section together). >> >>Example lilypond code and the result are attached. >> >>Bar-numbering is attached to the top part in the score so, when that >>part's maxima starts early and other parts are still moving, the other >>parts sometimes have "extra" bars of music. As a result, I have to >>reset the bar numbering manually afterwards (see line 27 of the example >>attached): >> >> \set Staff.currentBarNumber = #4 >> >>Rather than specifying a static bar number, how could the following >>pseudocode be programmed? >> >> \set Staff.currentBarNumber = Staff.currentBarNumber + x >> >>where, in this example, x = 1 >> >>As you can tell, I'm not a Scheme programmer! Thanks for any help you >>can offer. >>- > > > I'm not a scheme programmer either but we do have a snippet > > http://lsr.dsi.unimi.it/LSR/Snippet?id=333 > > That might give you some clues. > > I am also guessing that you could use a similar method that we document > for 'Upbeats' (see Notation Reference) where we can use > > \set Timing.measurePosition blahblahblah (instead of \partial X) > > to denote a position in a single measure but for your specific case use > > \set Timing.internalBarNumber or \set Timing.currentlBarNumber somehow. > > Look in the Internal reference for Timing_translator. > > I'm throwing these ideas out so that if you cannot figure something out, > someone else more knowledgeable that I in the internals might. > > James > >
the same thing that the snippet does, but only for bar number, and with a parameter (the number to add, in case it isn't 1) could look like this addtobarnumber = #(define-music-function (P L m) (integer?) #{ \applyContext #(lambda (voice) (let ((staff (ly:context-property-where-defined voice 'currentBarNumber)) (n (ly:context-property voice 'currentBarNumber))) (ly:context-set-property! staff 'currentBarNumber (+ $m n)))) #}) %% example { \override Score.BarNumber #'break-visibility = #'#(#t #t #t) \key c \major c''1 c'1 \addtobarnumber #3 c''1 c'1 } I don't know how it will work but try it out. Jakob > > > > internalBarNumber > > > >> > > > _______________________________________________ > lilypond-user mailing list > lilypond-user@gnu.org > http://lists.gnu.org/mailman/listinfo/lilypond-user > _______________________________________________ lilypond-user mailing list lilypond-user@gnu.org http://lists.gnu.org/mailman/listinfo/lilypond-user