5

Consider the following scores below. I would have thought Lilypond would apply a consistent transposition to the notes without the need to reformat the interval notations.

The first stave is the phrase in the original key as intended. I then apply a transpose down one semitone on the next stave and find the relative intervals are being interpreted differently.

The third and fourth staves demonstrate that without a \relative marking, the intervals would have behaved similar to the transposed version.

I am not sure if this is a bug in the Lilypond system, or if there is some reason why \transpose does not just apply an predictable pitch change when using a \relative marking?

Can anyone advise how I can use transpose to just shift my music in a consistent way?

global= {
  \time 4/4
  \key g \major
}

\version "2.16.2"
{
    \relative c''{
        bes'4-^ g16 ees8. bes'4-^ fis16 d8. 
    }
}

\version "2.16.2"
{
    \relative c''{
         \transpose  c b {
            bes'4-^ g16 ees8. bes'4-^ fis16 d8.
        }
    }
}

\version "2.16.2"
{
    bes'4-^ g16 ees8. bes'4-^ fis16 d8. 
}

\version "2.16.2"
{
     \transpose  c b {
        bes'4-^ g16 ees8. bes'4-^ fis16 d8.
    }   
}

image of above compilation

  • 1
    Gordon: It looks like you have two accounts open, and that's why you can't edit your post (which you can do when you're on the same account). Consider using the Contact link on the bottom of the page to have your accounts merged. – Richard Apr 27 '18 at 3:32
8

It was actually designed to work this way. From the documentation:

Music inside a \transpose block is absolute unless a \relative is included in the block.

So instead of having transpose within the relative block, you want to switch it:

\version "2.16.2"
{
    \transpose c b, {
         \relative c'' {
            bes'4-^ g16 ees8. bes'4-^ fis16 d8.
        }
    }
}

enter image description here

Note that, since the pitches are absolute, you may have to specify \transpose c b, instead of just \transpose c b. (This may depend on how you organize your score.)

  • Thanks - putting \relative inside the \transpose is the fix I was after. – Gordon Rouse Apr 25 '18 at 6:05
6

I’d like to offer a suggestion for future endeavors: you may find it easier to use variables to control certain aspects of your melody—transposition, in this case. While you may gain an understanding of how they operate together through the snippet you posted, you may avoid some degree of trial-and-error altogether by making use of some of the suggestions the authors make in the Learning document.

Here’s how we can look at the piece you posted:

Certainly, your version statement is required only once in the .ly input file. (Side note: 2.18.2 is the most recent stable version; is there a reason your code indicates a previous version, 2.16.2?)

Then, you have your global statement cleanly set—although, I recommend placing them in the order in which they appear on the page (personal preference):

global = {
  \key g \major
  \time 4/4
}

Next, your melody, using \relative mode:

melody = \relative c'' {
  bes'4-^ g16 ees8. bes'4-^ fis16 d8.
}

At this point, you have two self-contained variables that are ready for use:

\global
\melody

Putting the score together is simple:

\score {
  \new Staff { \global \melody }
}

which tells LilyPond to make one staff with two variables, one following immediately after the other.

Therefore, to your question of how to shift your music in a consistent way, I offer the following:

\score {
  \new Staff \transpose c a, { \global \melody }
}

\score {
  \new Staff { \global \transpose c fis, \melody }
}

The first of these two examples tells LilyPond to transpose both variables—the one with the key and time signatures and the one with the actual music. The second tells LilyPond to transpose only the melody, leaving the key and time signatures alone.

You can handle changes like these with greater ease when your music is put together in a way that can facilitate it.

Showing transpositions easily controllable in LilyPond

  • This is a really helpful exposition on variables and cleaning up one's LilyPond score; great answer! – Richard Apr 26 '18 at 14:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.