Am I missing a basic LilyPond command/directive--something
built-in that takes music as input and returns note names as text?
Such a functionality would seem to be useful in all kinds of
annotations/quotations. I know about \displayMusic but its output
only goes to the console/output stream and can't be routed to
markup, correct?
As for my effort to code my own music-to-text/markup function:
apologies, but I left off the function name when I copied the code
over. See correction below.
Also, I've since tried closing the " let* ( " block at the very
end, rather than after the third binding, but that errors out too.
notenamer =
#(define-scheme-function
(pitchin)
(ly:music?)
(let* (
(note-datum (car (ly:music-property pitchin 'elements)))
(pitch-datum (ly:music-property note-datum 'pitch))
(out-notename (ly:pitch-notename pitch-datum)))
#{ \markup
\bold
$out-notename
#}
))
Steve Cummings wrote on 11/18/2019 5:23
PM:
Though I remain baffled by Scheme and its use in LilyPond, my
hope is to build one or more functions/procedures that would
transpose input music and for each chord display the transposed
chord's note names, with control over the way the names are
represented (as in Cb or F# instead of ces and fis).
Here, I'm just asking for help with one part of the
function-to-be: how to turn notes in LilyPond music into note
names as text (schematic of the complete imagined function
below).
Here's what I've tried so far, in LilyPond 2.19.8x, based
closely on working procedures found on this list. Once this is
running right for single notes I'll (hope to) get it to loop
through all input music.
#(define-scheme-function
(pitchin)
(ly:music?)
(let* (
(note-datum (car (ly:music-property pitchin 'elements)))
(pitch-datum (ly:music-property note-datum 'pitch))
(out-notename (ly:pitch-notename pitch-datum)))
#{ \markup
\bold
$out-notename
#}
))
I
get "syntax error, unexpected NUMBER_IDENTIFIER" on the
$out-notename line when calling notenamer with a note
wrapped in braces, as in:
\notenamer {a}
Without the braces around the music, the error is "In
procedure car in _expression_ (car (ly:music-property pitchin
#)): Wrong type (expecting pair): ()
Results are the same if I do "define-music-function" instead of
"define-scheme-function."
Many thanks for your attention and help,
Steve
PS: I have a working NoteNames reformatter but it seems to
require listing in a substitution table the specific notes of
each and every chord in each transposition. A custom function
would allow display of the chord note names in a columnar stack
so if these markups were used as text scripts they wouldn't
either take too much space or collide with the names of adjacent
notes. Alternatively, chord note names could be placed beneath
ChordNames.