Hello Peter, > 🧩 The Key Challenge > • I want to insert each label directly in sync with the chord symbol. > • Ideally, I’d like to overlay a semi-transparent, large, colored text > (e.g., in red at 50% opacity). > • The chord symbol should remain fully visible and untouched, and the > overlay should not shift or interfere with chord spacing. > • I want to avoid placing text manually on notes (e.g., using ^\markup on > melody pitches), as that’s impractical for longer lead sheets. > • I’d prefer a solution where I can write something like:
You could always implement a custom `'stencil` callback for chordnames. This example extends the stencil of the chord name by annotations that can be passed in via `details.annotations.placement` where `placement can be left, right, up, down or center: %%% #(define annotated-chord-symbol (grob-transformer 'stencil (lambda (grob orig) (let* ((det (ly:grob-property grob 'details)) (annot (assoc-get 'annotations det '())) (ext (list (ly:stencil-extent orig X) (ly:stencil-extent orig Y))) (annot-stcs (map (lambda (key direction axis) (let ((annot (assoc-get key annot #f))) (if (string? annot) (set! annot (markup #:general-align (- 1 axis) 0 #:general-align axis (- direction) annot))) (and annot (ly:stencil-translate-axis (ly:stencil-translate-axis (grob-interpret-markup grob annot) (interval-bound (list-ref ext axis) direction) axis) (interval-center (list-ref ext (- 1 axis))) (- 1 axis))))) '(left right up down) (list LEFT RIGHT UP DOWN) (list X X Y Y))) (annot-center (assoc-get 'center annot #f)) (annot-center (if (string? annot-center) (markup #:center-align #:vcenter annot-center) annot-center)) (annot-center-stc (and annot-center (ly:stencil-translate (grob-interpret-markup grob annot-center) (cons (interval-center (first ext)) (interval-center (second ext))))))) (apply ly:stencil-add (filter (lambda (x) x) (cons* orig annot-center-stc annot-stcs))))))) \layout { \context { \ChordNames \override ChordName.stencil = #annotated-chord-symbol } } \chords { c1 \tweak details.annotations.left "left" \tweak details.annotations.right "right" \tweak details.annotations.up "up" \tweak details.annotations.down "down" \tweak details.annotations.center "M" g1 } %%% Of course that can be adapted to your liking, but this allows you to do say: %%% withDeg = #(define-music-function (deg music) (markup? ly:music?) #{ \tweak details.annotations.center \markup\with-dimensions-from\null\center-align\vcenter \with-color #"#ff000090" \fontsize #6 #deg #music #}) \chords { \withDeg "I" c1 } %%% to create an overlayed large scale degree that does not affect spacing and is transparent red (note that transparency only works out using SVG or cairo backend, as postscript does not have a concept of transparency). Cheers, Tina
signature.asc
Description: This is a digitally signed message part.