What is the best way to automatically transpose a LilyPond source file into multiple keys?
You can refer to the melody variable and have it transposed in the desired keys:
melody = \relative c' { c8 e c e g4 g } \score { \transpose c d \melody } \score { \transpose c e \melody } % etc.
If you want to output the transpositions as separate files, embed them into \book blocks.
If you want to create two copies of the same fragment, one transposed and one not, you can use \displayLilyMusic
. For example,
{
\displayLilyMusic \transpose c a, { c4 e g a bes }
}
will display
{ a,4 cis e fis g }
Copy this output and paste it wherever you want.