How to pass `ly:music` to a `markup-command`
I am attempting to create a lilypond markup command which will display a guitar chord fingering above the chord on a stave. The code I have so far follows:
#(define-markup-command (chord_and_fingering layout props
chord fingering) (ly:music? string?)
"…documentation…"
(interpret-markup layout props
#{ markup { center-column {
fret-diagram #(string-append "f:1;h:13;" fingering)
score {
new Staff {
clef "treble_8"
set fingeringOrientations = #'(left)
#chord bar "|."
}
layout {
override Staff.TimeSignature #'stencil = ##f
override Staff.Clef #'transparent = ##t
}
}
}}#}
))
It works okay, but I cannot figure out how to pass a music expression directly to it. That is, I can use it like this with a temporary variable:
a_C_major_chord = {
<c-3 e-2 g-0 c'-1 e'-0>1
}
a_C_major = markup {
chord_and_fingering
#a_C_major_chord
#"6-x;5-3;4-2;3-o;2-1;1-o;"
}
But would like to use it like this, without:
a_C_major = markup {
chord_and_fingering
#{<c-3 e-2 g-0 c'-1 e'-0>1}
#"6-x;5-3;4-2;3-o;2-1;1-o;"
}
This however doesn't work. Could someone tell me where I am going wrong and what is the correct syntax for this?
Thank-you for your time and help.
1 Comments
Sorted by latest first Latest Oldest Best
Well, you can use either
notemode {<c-3 e-2 g-0 c'-1 e'-0>1}
or (you were almost there)
##{<c-3 e-2 g-0 c'-1 e'-0>1#}
Remember: # throws you from LilyPond input modes into Scheme and #{ introduces stuff in LilyPond syntax into Scheme. Here you are combining both and so need ##{ at the start.
Terms of Use Privacy policy Contact About Cancellation policy © freshhoot.com2025 All Rights reserved.