|
From: | Dan Eble |
Subject: | Re: one bar number per system |
Date: | Wed, 9 Sep 2009 00:57:41 -0400 |
To whom it may concern,Here is what I have come up with. It does not meet my original goal, but it is good enough for now. \barNumber forces a bar number to appear at the current or next full-measure bar line. \manualBarNumbersOn should appear at the beginning of the score to set things up.
A wart that catches my eye is taking the bar number from the grob text in bar-number-break-visibility callback.
A useful(?) enhancement would be to make the default visibility a parameter of \manualBarNumbersOn.
barNumber = #(define-music-function (parser location) () (let ((m (make-music 'ApplyContext))) (define (force-bar-number ctx)(let* ((barnum-table (ly:context-property ctx 'visibleBarNumbers)))
(if (not (hash-table? barnum-table)) ; first use in this score? (begin ; create the set of visible bar numbers (set! barnum-table (make-hash-table 16)) (ly:context-set-property! ctx 'visibleBarNumbers barnum-table))) (let* ((barnum (ly:context-property ctx 'currentBarNumber)) (measurePos (ly:context-property ctx 'measurePosition)) (measureLen (ly:context-property ctx 'measureLength)) (mid-measure (and (ly:moment<? ZERO-MOMENT measurePos) (ly:moment<? measurePos measureLen)))) (if mid-measure (set! barnum (1+ barnum))) (hash-set! barnum-table barnum #t) ))) (set! (ly:music-property m 'procedure) force-bar-number) (context-spec-music m 'Score))) manualBarNumbersOn = #(define-music-function (parser location) () (let ((musForCtx (make-music 'ApplyContext))) (define (set-callback ctx) (let () (define (bar-number-break-visibility-callback grob) (let ((barnum-table (ly:context-property ctx 'visibleBarNumbers)) (barnum (string->number (ly:grob-property grob 'text)))) (if (and (hash-table? barnum-table) (hash-ref barnum-table barnum)) end-of-line-invisible begin-of-line-visible ))) (ly:context-pushpop-property ctx 'BarNumber 'break-visibility bar-number-break-visibility-callback))) (set! (ly:music-property musForCtx 'procedure) set-callback) (context-spec-music musForCtx 'Score))) -- Dan On 2 Sep 2009, at 18:51, Dan Eble wrote:
Thanks for your replies.\bar allows a break, but does not force it. Ideally, I would like a bar number printed only after a break.If memory serves, the all-visible override didn't work in mid- measure for the upcoming full-measure bar line. (I do not have the time right now to override the next full-measure bar line by hand in 250 scores.)I have pieced together an experimental solution to build a hash of manually specified measure numbers, which is used by a custom barNumberVisibility function. It doesn't yet work for my multi- score book, because I based it on the table of contents implementation, so the list is global. I suppose I need to store the list of visible bar numbers in the Score context instead. Is that right?This will give me a bar number wherever I specify it, whether it is the first one after a break or not. It would be functional, but not exactly what I want.-- Dan On 2 Sep 2009, at 09:17, Trevor Daniels wrote:Mats Bengtsson wrote Wednesday, September 02, 2009 1:38 PMTrevor Daniels wrote:Does this not work when inserted immediately before the first full bar on the line? (I haven't actually tried it) \once \override Score.BarNumber #'break-visibility = #'#(#t #t #t)Why not write it as \once \override Score.BarNumber #'break-visibility = #all-visibleOf course, this method works, but it requires that you manually insert it where you know that there will be a line break.Yes, I know. But since Dan is already inserting \bar "" in the places where a mid-bar break is required I wondered why he could not also insert this override before the following bar. Trevor
[Prev in Thread] | Current Thread | [Next in Thread] |