Kieren MacMillan <kieren_macmil...@sympatico.ca> writes: > Hi David, > >> Something like > > This is great! > > …except in the *exact* circumstance I actually need it for: > > %%%% SNIPPET BEGINS > \version "2.19.64" > > #(define (moment->string mom) > (if (zero? (ly:moment-grace mom)) > (number->string (ly:moment-main mom)) > (format "~sG~a" (ly:moment-main mom) (ly:moment-grace mom)))) > > currentmom = > -\tweak text > #(lambda (grob) > (let* ((loc (grob::rhythmic-location grob))) > (if (pair? loc) > #{ \markup \with-color #red #(format "~a@~a" (car loc) > (moment->string (cdr loc))) #} > ""))) > -"" > > \layout { > \context { > \Score > \remove "Timing_translator" > \remove "Default_bar_line_engraver" > } > \context { > \Staff > \consists "Timing_translator" > \consists "Default_bar_line_engraver" > } > } > > { c d\currentmom f g } > %%%% SNIPPET ENDS > > Any way to get the moment of the current context when Timing has been moved > from Score?
That's more tricky since "rhythmic-location" is recorded in PaperColumn/NonMusicalPaperColumn items that only exist per-Score. You could try moving Paper_column_engraver along with the other engravers you move but I would be surprised if this does not cause a lot of havoc. So maybe do this entirely differently?
\version "2.19.65" #(define (moment->string mom) (if (zero? (ly:moment-grace mom)) (number->string (ly:moment-main mom)) (format "~sG~a" (ly:moment-main mom) (ly:moment-grace mom)))) Current_moment_engraver = #(make-engraver (acknowledgers ((text-script-interface self grob origin) (let ((ctx (ly:translator-context self))) (if (equal? (ly:grob-property grob 'text) "@") (set! (ly:grob-property grob 'text) #{ \markup \with-color #red #(format "~a@~a" (ly:context-property ctx 'currentBarNumber) (moment->string (ly:context-property ctx 'measurePosition))) #})))))) #(ly:register-translator Current_moment_engraver 'Current_moment_engraver '((description . "\ This engraver replaces text scripts with a text of @code{@@} with a red currentBarNumber@measurePosition indicator."))) \new Staff \with { \consists "Current_moment_engraver" } { c d-"@" f g }
Of course, here is to you not actually ever wanting to output just "@". You'd consist this engraver where it can be expected to see useful values of currentBarNumber/measurePosition, so likely in the same contexts where you move your Timing_translator. No idea whether this will behave sensibly in the context of timing changes such as \partial . -- David Kastrup
_______________________________________________ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user