At present, I have to manually extract the lyrics from the notation plus markup that generates the music. I've been able to partially automate this with some python and vim code (not shown here), but it is still somewhat unsatisfactory.
It seems to me that the best solution would be to use LilyPond's built-in Scheme interpreter to extract the pitch names while the file is being processed. I've made some attempts to use map with ly:note-pitchname, but so far no success. This is probably because I know squat about Scheme, especially as used in LilyPond scripts.
% Moveable Do as lyrics template
% define some solfege pitchnames
% (in practice, the full set goes into "english.ly")
pitchnames = #`(
(do . ,(ly:make-pitch -1 0 NATURAL))
(re . ,(ly:make-pitch -1 1 NATURAL))
(mi . ,(ly:make-pitch -1 2 NATURAL))
)
#(ly:parser-set-note-names parser pitchnames)
% compose as though in C major
mynotes = \relative do' {\key do \major do2 re4( mi4) }
% transpose to desired key
melody = \transpose do mi { \mynotes }
% I WANT TO AUTOMATICALLY CREATE THE
% THE PITCHNAMES IN THIS BLOCK
% FROM THE CONTENTS OF \mynotes
solfa = \lyricmode {
\set ignoreMelismata = ##t % one syllable per note
do re mi
\unset ignoreMelismata % allow normal placement of other lyrics
}
% Produce score with solfege names as lyrics
\score {
<<
\new Voice = "myVoice" {
\melody
}
\new Lyrics \lyricsto "myVoice" \solfa
>>
}
Note: I've also posted this question at
StackOverflow but I'm not sure how many LilyPond gurus are active there, so it seems worthwhile to ask the same question here.
Thanks,
Mike