Slur shapes and transposed parts: Use tags!

Many contemporary music scores are engraved in concert pitch for easier reading. Parts for transposing instruments must (obviously) be transposed. This may cause slurs and ties to be shaped differently between the score and the parts. In most cases, LilyPond’s d default slur and tie positioning will be attractive enough. If so, there’s no particular problem: LilyPond will calculate the slur/tie shape based on the notes actually being processed at the time.

It does present a problem if the default shape needs to be modified using the \shape command. \shape specifies the alteration in terms of moving the Bezier curve’s control points away from their default positions:

\shape #'((dx0 . dy0) (dx1 . dy1) (dx2 . dy2) (dx3 . dy3)) Slur

To make a downward slur deeper, for instance, you would push the
middle control points down:

\shape #'((0 . 0) (0 . -1) (0 . -1) (0 . 0)) Slur

If transposition should cause the slur to flip upward, this modification will flatten the curve instead. This is quite likely to look wrong, perhaps even unreadable.

I recently ran into this problem in one bar of a trio d’anches that I’m close to finishing. This bar contains a melodic phrase that spans 2.5 octaves in the space of five notes before leaping down a major tenth, under a slur. (Note that the notes themselves are contained in a music variable, and the score only refers to the variable. This is standard practice for any LilyPond project where a score and parts must be generated. It makes it possible to enter the notes once, and lay them out in a score or in parts as needed.)

music = \relative c' {
  \tupletSpan 1*6/8
  \tuplet 4/3 {
    cis4 f,! ( d' e cis' b'2 g,4 )
  }
  \tupletSpan \default
}

{ \time 12/8 \music }
(click to enlarge)

(click to enlarge)

The slur is pretty close, although it makes me a little physically uncomfortable to look at it. There is not enough space above the B, and the shape also disguises the sharp downward leap in the last note.

To fix it, push the third control point up (positive Y offset), and the last control point down.

music = \relative c' {
  \tupletSpan 1*6/8
  \tuplet 4/3 {
    cis4
    \shape #'((0 . 0) (0 . 0) (0 . 1.2) (0 . -0.5)) Slur
    f,! ( d' e cis' b'2 g,4 )
  }
  \tupletSpan \default
}

{ \time 12/8 \music }
(click to enlarge)

(click to enlarge)

What happens if we use that music in a transposed part, however?

music = \relative c' {
  \tupletSpan 1*6/8
  \tuplet 4/3 {
    cis4
    \shape #'((0 . 0) (0 . 0) (0 . 1.2) (0 . -0.5)) Slur
    f,! ( d' e cis' b'2 g,4 )
  }
  \tupletSpan \default
}

{ \time 12/8 \transpose a c' \music }
(click to enlarge)

(click to enlarge)

Now, the slur begins below the top of the stem and just to the right, and it ends quite a bit closer to the notehead than the concert-pitch version. These differences mean that the default curve for A clarinet is much more pronounced. The \shape alteration for concert pitch increases the curvature even further, making the transposed slur look exceptionally “loopy.”

So we need more curvature than the default for concert pitch, and less curvature of the transposed part.

But, in the \shape examples in the LilyPond manuals, it appears that \shape must appear right before the note that initiates the slur or tie to be affected. That is, in normal usage, you can have only one \shape per slur or tie. In this case, the music variable needs to specify both shape modifications, and the music expression that uses the variable should be able to choose which one to use at the time of engraving.

LilyPond has a mechanism to choose between versions of some content: tags. A portion of music (a music expression) can be enclosed in curly braces and associated with a name using the \tag command. If the music variable is used without any tag references, all of the tagged expressions will be kept. Other commands, \keepWithTag and \removeWithTag, can cause certain tagged expressions to be ignored.

music = { \tag #'tagName { ... music expression ... } }

% Elsewhere, in the score
\keepWithTag #'tagName \music

It might not seem to apply to this case, because most uses of \tag will include real music in the expression. Here, all the notes are the same; it would be redundant to put notes inside the tags. Ideally, the tags would include only the content that is different: namely, the \shape alterations. But is that legal? Will it break the \shape calls to put them inside a tag, while the slur itself is outside?

In fact, it is legal. \shape inserts \once \override commands into the expression. These are considered “music,” and may legally appear alone in a tagged expression. The final expression that LilyPond renders includes the override, followed immediately by the slur to affect: no problem.

So the surprisingly simple solution is to write both \shape alterations, each with a different \tag. Then, use \keepWithTag or \removeWithTag to choose which of the \shape calls will be used in this context.

music = \relative c' {
  \tupletSpan 1*6/8
  \tuplet 4/3 {
    cis4
    \tag #'scoreOnly { \shape #'((0 . 0) (0 . 0) (0 . 1.2) (0 . -0.5)) Slur }
    \tag #'partOnly { \shape #'((-0.5 . 1.5) (0 . 0) (0 . 0) (0 . 1.0)) Slur }
    f,! ( d' e cis' b'2 g,4 )
  }
  \tupletSpan \default
}

\markup \bold "Score in concert pitch"
\score {
  \new Staff { \time 12/8 \keepWithTag #'scoreOnly \music }
}

\markup \column { \vspace #1 \bold "Part, transposed for clarinet in A" }
\score {
  \new Staff { \time 12/8 \transpose a c' \keepWithTag #'partOnly \music }
}

example-5.preview

More on tags: Using tags

More on shape: Modifying shapes

3 thoughts on “Slur shapes and transposed parts: Use tags!

  1. Phil Holmes

    I think it would make this a bit more real life to add a key signature: it gets rid of the unnecessary accidentals if you add \key d \major to the music.

    Reply
  2. Elaine Alt

    Thanks for the example. I am working my way towards using tags, but have not bitten the bullet yet.

    However, with all this tweaking, I am left wondering why the slur conflicts with the tuple brace in all cases? Is this not the most un-beautiful part of this snippet?

    Especially since the rhythm could be easily written–and arguably more clearly–with dotted eighth notes rather than a tuplet in the first place!

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *