%%% SNIPPET BEGINS %%% if proc is a procedure evaluate (proc grob), else return proc as value #(define (eval-if-proc proc grob) (if (procedure? proc) (proc grob) proc)) %%% retrieves overrides from grob.details.path.key where key is some key function or else from %%% grob.path.default or default parameter if not exists #(define (override-by-details tag path) (grob-transformer path (lambda (grob orig) (let* ((key (tag grob)) (tweak (ly:assoc-get key (ly:assoc-get path (ly:grob-property grob 'details) '()) 'pass)) (default (ly:assoc-get 'default (ly:assoc-get path (ly:grob-property grob 'details) '()) orig))) (if (equal? tweak 'pass) default tweak))))) %%% articulation type as tag #(define (articulation-type grob) (string->symbol (ly:prob-property (ly:grob-property grob 'cause) 'articulation-type))) \layout { \context { \Score \override Script.font-size = #(override-by-details articulation-type 'font-size) \override Script.color = #(override-by-details articulation-type 'color) % This override is only nescessary as somehow if font-size is a procedure it is not evaluated automatically, % so we need to manually call (ly:grob-property grob 'font-size) once. \override Script.stencil = #(lambda (grob) (ly:grob-property grob 'font-size) (ly:script-interface::print grob)) \override Script.stencil = #(override-by-details articulation-type 'stencil) } } \score { { \textLengthOn \override Script.details.font-size.tenuto = #2 \override Script.details.font-size.accent = #-5 \override Script.details.color.tenuto = #red \override Script.details.color.marcato = #blue c'4->^"-5" c'4--^"+2,red" c'4-\tweak #'font-size #-2 -- ^"manual tweak -2" c'-^^"blue" c'-\tweak #'color #green -^^"manual tweak green" s4*3 | c'8-- c'-> c'-! c'-^ \temporary\override Script.details.font-size.default = #4 c'8-- c'-> c'-! c'-^ \temporary\override Script.details.color.default = #yellow c'8-- c'-> c'-! c'-^ \revert Script.details.font-size.default \revert Script.details.color.default c'8-- c'-> c'-! c'-^ \override Script.details.color.tenuto = #green c'8-- c'-> c'-! c'-^ \override Script.details.stencil.fermata = ##f c2\fermata\espressivo } } %%% SNIPPET ENDS