On 2019-11-19 6:05 am, Stephen Cummings wrote:
Am I missing a basic LilyPond command/directive--something built-in
that takes music as input and returns note names as text?
There is the NoteNames context, but its functionality is wrapped up in
C++ code and is not easily customizable.
%%%%
\version "2.19.83"
melody = \fixed c' { e8 fis g4 <f bes>2 }
<< \new NoteNames \melody \new Staff \melody >>
%%%%
Next, the logic behind ChordNames has a number of helper functions that
are used to compose the final markup for a given chord.
%%%%
\version "2.19.83"
\markup \column \override #'(word-space . 0.1) { #@(map
(lambda (pitch) (note-name->markup pitch #f))
(list #{ d, #} #{ ees #} #{ fisis' #})) }
%%%%
Finally, you can do it manually when you need to fully customize naming:
%%%%
\version "2.19.83"
#(define (pitch->name pitch)
(vector-ref '#("Do" "Re" "Mi" "Fa" "So" "La" "Ti")
(ly:pitch-notename pitch)))
#(define (pitch->alteration pitch)
(assoc-get (ly:pitch-alteration pitch)
'((-1/2 . "-flat") (1 . "-double-sharp")) ""))
\markup \column { #@(map
(lambda (pitch) #{ \markup \concat {
$(object->string pitch) ": "
$(pitch->name pitch) $(pitch->alteration pitch) } #})
(list #{ d, #} #{ ees #} #{ fisis' #})) }
%%%%
What is important to note is that ly:pitch-notename returns a number,
not a string. It is up to the caller to map that number into a suitable
value within the desired naming system.
-- Aaron Hill