# Transposition with Enharmonic Changes (Part 1)

Transpositions work simply and reliably in LilyPond. I can enclose any music expression or any staff or the complete score in a \transpose command and that’s all. The nice thing about that is that I don’t change the music but use it in a modified way. I’m free to use it again in another key (transpose my scores to multiple keys), and any change in the original music will be propagated automatically to all uses of it.

Sometimes you have to do some more work though (but that’s not LilyPond’s fault but inherent in the musical task), namely when you encounter music that has distant key relations.
Consider the following phrases from Schumann’s Widmung op. 25.1:

Schumann: Widmung op. 25/1 (excerpts), original key

The initial and main key of the song is a flat major, but the middle section is written in e major. Imagine you’d have to transpose the song down to g major (have you ever experienced the impact a semitone can have on a singer’s performance?) – the middle section would end up in d sharp major, a theoretical and barely readable key signature with nine sharps (of course the example only shows the melody and leaves out the much more complex piano part):

Literally transposed a minor second down (a flat to g, e to d sharp)

Could you immediately read that without getting confused about half or whole steps? So how would you deal with this situation? You have to change the middle section enharmonically. Fortunately this is quite easy with LilyPond too. You can enclose the middle section of the music with \transpose e fes { ... } and get:

Middle section enharmonically changed

This doesn’t immediately seem to make sense, but when the song as a whole is now transposed a minor second down – using the command \transpose as g { ... } – the middle section ends up to be in the much more readable e flat major:

Transposition one semitone down, with the second phrase enharmonically changed

You can put this enharmonic transposition either directly inside each of your musical expressions (that will usually contain the voice, the right hand and the left hand each). But you can also (and preferably) split the music expressions into three, concatenate them to a new complete expression, and apply the enharmonic change at this stage, like in the following example:

music = \relative as' {
\key as \major
% music 1
\key e \major
% music 2
\key as \major
% music 3
}

% becomes

beginning = \relative c'' {
\key as \major
% music 1
}
middlesection = \relative gis' {
\key e major
% music 2
}
end = \relative c'' {
\key as \major
% music 3
}

music = {
\beginning
\transpose e fes \middlesection
\end
}

\score {
\new Staff \transpose as g \music
\layout {}
}

The \transpose as g { ... } expression used in the \score block still transposes the whole song from a flat to g major, but the middlesection has been enharmonically changed so that this part is now transposed from f flat to e flat major instead of from e to d sharp.

One thing to point out again is that all these operations are uses of the original music, therefore it takes very little to adapt the set-up for different needs. What would happen to the middle section if you wanted to print the song in g flat major? Or in A major?

In part 2 of this little tutorial I will show you a way to deal with this task in a more flexible way and to make even better use of the modularity of the text based input structure of LilyPond.