\version "2.22.2" #(define (integer-or-false? x) (or (not x) (integer? x))) alt = #(define-music-function (alt_up alt_down mus) (integer-or-false? (integer-or-false? #f) ly:music?) #{ \tweak stencil #(grob-transformer 'stencil (lambda (grob orig) (if alt_up (let* ((mu (markup #:fontsize -4 #:center-align (alteration->text-accidental-markup (/ alt_up 2)))) (altstc (grob-interpret-markup grob mu)) (arttype (ly:event-property (ly:grob-property grob 'cause) 'articulation-type))) (if (equal? arttype "trill") (set! altstc (ly:stencil-translate altstc '(0.7 . 0)))) (set! orig (ly:stencil-combine-at-edge orig Y UP altstc (if (equal? arttype "trill") -0.3 0.2))))) (if alt_down (let* ((mu (markup #:fontsize -4 #:center-align (alteration->text-accidental-markup (/ alt_down 2)))) (altstc (grob-interpret-markup grob mu)) (arttype (ly:event-property (ly:grob-property grob 'cause) 'articulation-type))) (set! orig (ly:stencil-combine-at-edge orig Y DOWN altstc 0.2)))) orig)) #mus #}) \score { \relative c'' { \key c\minor c4-\alt ##f #0 ^\mordent c4-\alt #-1 ^\trill c4-\alt #0 #-1 ^\turn } } << \new Staff \with { instrumentName = "Doc" } \relative c''' { a2( \once \override TextScript.script-priority = #-100 a2-\tweak avoid-slur #'inside ^\prall^\markup { \sharp } \once \override Script.script-priority = #-100 a2)-\tweak avoid-slur #'inside ^\prall^\markup { \sharp } } \new Staff \with { instrumentName = \markup\center-column { "My" "method" } } \relative c''' { a2( a2-\tweak avoid-slur #'inside -\alt ##f #1 ^\prall a2)-\tweak avoid-slur #'inside \alt #1 ^\prall } >> << \new Staff \with { instrumentName = "Doc" } \relative c''' { \once \override TextScript.script-priority = #-100 a2^\prall^\markup { \sharp }^\markup\italic"dolce" \once \override Script.script-priority = #-100 a2^\prall^\markup { \sharp } } \new Staff \with { instrumentName = \markup\center-column { "My" "method" } } \relative c''' { a2-\tweak avoid-slur #'inside -\alt ##f #1 ^\prall ^\markup\italic"dolce" a2-\tweak avoid-slur #'inside \alt #1 ^\prall } >>