2014-07-07 3:40 GMT+02:00 Dan Eble <[email protected]>: > I’ve been using the following functions for a while (maybe since 2.12?) but > now I’m trying to update to 2.18 and they’ve stopped working. I suppose the > problem is directly related to this warning: > > warning: cannot find property type-check for `visibleBarNumbers' > (translation-type?). perhaps a typing error? > warning: skipping assignment > > but I’m not sure what to do about that. Any ideas? \barNumber adds the > current or next bar number to a set (visibleBarNumbers) which is later > checked by the BarNumber break-visibility callback. Numbers in the set are > printed. > > 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) () > (define (set-properties ctx) > (let () > > ; this special formatter is necessary for string->number to > ; work in the visibility callback below > (define (bar-number-formatter barnum measure-pos alt-number ctx) > (number->string barnum)) > > (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-set-property! ctx 'barNumberFormatter bar-number-formatter) > (ly:context-pushpop-property ctx 'BarNumber 'break-visibility > bar-number-break-visibility-callback) > )) > > (context-spec-music (make-apply-context set-properties) 'Score)) > > Thanks, > — > Dan
Hi, could you add an example how you use it? I've still 2.12.3 installed and could do some testing. All I can say right now is, that 'visibleBarNumbers is not a valid context-property and it wasn't in 2.12.3 as well. Cheers, Harm _______________________________________________ lilypond-devel mailing list [email protected] https://lists.gnu.org/mailman/listinfo/lilypond-devel
