Hi Eric,
Am 09.09.25 um 01:29 schrieb Eric Benson:
I would like to add a footnote at the bottom of a score, something like
The F note in measure 29 is sometimes sung as G instead.
However, the score is often transposed to a different key, so I don't
want to "hard-code" the note name in the footnote. I would like it to
be transposed to the correct key. For example, in this case the score
is written in Ab, but it is transposed to Eb, so the footnote should read
The C note in measure 29 is sometimes sung as D instead.
Is there a simple way to do this with LilyPond? The NoteNames context
controls printing of note names, but I don't really want to print it,
I just want to pass it as a string in markup.
Basically, we need a way to turn a LilyPond pitch into an English note
name for markup. For this, we can create a markup-function wrapper
around the internal functions used for ChordNames or NoteNames.
%%%%%%%%%%%%%
\version "2.25.23"
#(define-markup-command (noteName layout props mus) (ly:music?)
;; accept mus as music instead of pitch
;; in order to allow for transposition
(let*
((pitch (first (music-pitches mus)))
(alt (ly:pitch-alteration pitch)))
(interpret-markup
layout
props
(markup #:concat
((note-name->string pitch)
(if (zero? alt)
empty-markup
(alteration->text-accidental-markup alt)))))))
base-tonic = d
transposed-tonic = e
trans = \transpose #base-tonic #transposed-tonic \etc
\trans
\relative {
\key #base-tonic \dorian
\time 6/8
\partial 8
d'8
f4 g8 a8. b16 a8
g4 e8 c4
}
\markup { Note that the \noteName { \trans b } is sung as \noteName {
\trans bes } in some traditions. }
%%%%%%%%%%%%%
Lukas