Voice Contexts in Temporary Polyphonic Sections

On the lilypond-user mailing list I saw this example with the question how to bring the phrasing slur closer to the notes:

Chopin: From Nocturne op. 9,3 (click image to view source code)

From the question and the source code it was clear that the poster had doubled the whole line with another voice and applied the \hideNotes command on it. It seems many people run into this situation and are surprised that the notes are invisible but still use up space (and in this case force the phrasing slur away from the visible notes). The structure of the source code is roughly:

ais'4 gis'8
<<
{
\hideNotes
% ... hidden voice, with only the two triplets unhidden
}
\\
{
% ... visible voice, with the same notes as the other
}
>>

If I don’t hide the notes but color them in blue you’ll see what I mean – the phrasing slurs aren’t perfect, but it is clear where their position comes from.

The same with the additional voice visible and colored

In general, when you don’t want a hidden voice to influence the layout of other objects in this way, you don’t use \hideVoice but actually remove the stencils for the note heads, stems and other relevant objects. But in this case i suggested to completely remove the redundancy of the doubled voice because you only need a polyphonic section for the short triplet segment at the end. This resulted in the following structure:

ais'4 gis8 gis'4.~\>$$gis16 fis eis dis cisis dis\! e eis$$ gisis,$$ais << { % ... upper part of the triplets section } \\ { % ... lower part of the triplets section } >> This version brought the first phrasing slur in the right position (the second one still has to be shaped separately): First improvement: Remove doubled voice The original motivation for doubling the voice, I was now told, was to get the beaming as in the first example. The poster did not manage to prevent the triplets from breaking the beams. Now this apparently is an issue many users have to struggle with. Although the documentation is very clear in this regard the behaviour of Voice contexts in temporary polyphonic sections seems to be somewhat hard to digest. Therefore a real-world example like the current Chopin phrase may be a welcome opportunity to make this more transparent. All music in LilyPond lives in the context of a \Voice. You don’t always have to explicitly define it because LilyPond will in unambiguous cases create voices implicitly for you. “Voices” are similar to individual instruments or (human) voices in an ensemble: Some can play simultaneous notes but they are separate entities. Therefore some types of items can’t easily cross the borders of voice contexts, among them slurs but also beams. If you have to engrave a beam across voices you will have to use a workaround with an invisible dummy voice (yet another post idea …). Try to think of it as if you wanted to express a legato line between different members of the ensemble: while you actually can achieve this effect, it is an effect and not a genuine musical line. But fortunately we can achieve the current task without any tricks by bringing the whole group of 16th notes into one contigious voice context. The poster used what is called the “double backslash construct” in the documentation: << { % first voice } \\ { % second voice } >> As the documentation states this implicitly instantiates two voices and applies \voicOne and \voiceTwo commands to them. From what I wrote above it should now be clear that the beams from before the triplets can’t be continued within that implicitly created new voice context. But there is also another, more basic way to create a temporary polyphonic section, without the backslash and explicitly instantiating the additional voice: << { % first voice } \new Voice { % second voice } >> “Here, the first expression within a temporary polyphonic passage is placed into the Voice context which was in use immediately before the polyphonic passage, and that same Voice context continues after the temporary section.” In other words: while the double backslash construct creates a more or less independent section in the score this version creates additional voice contexts while the primary voice continues unaffected. Simply replacing \ by \new Voice – which would be syntactically correct doesn’t help much and gives a quite irritating result: Second improvement: better polyphonic construct (not working) One voice seems to have vanished, and the beams still aren’t right. So what is happening here? Although irritating, everything is working correctly. This is what our polyphonic section looks like in the source: << { \override TupletNumber #'stencil = ##f \times 2/3 { b16\accent[ s ais] } } \new Voice { \times 2/3 { b16 eis, ais } } >> As the manual says the settings of the voices are not done implicitly but all voices share the setting in effect with the main voice, which happens to be \oneVoice in this example. Therefore the second voice didn’t vanish but actually sits on top of the other – a fact that is also obvious from the numerous console warnings about “too many clashing note columns”. Luckily this problem is solved by simply entering \voiceTwo in the lower voice, but this still doesn’t solve the beaming issue. As mentioned it is the first voice that continues the preceding voice context, and that is the b16\accent[ s ais] voice here. As it has its own explicit beaming it is clear that it can’t continue the beam, and it’s the wrong voice anyway. So I hope the correct solution becomes clear now: We have to put the voice that should share the beam in the voice defined first in the polyphonic section. After replacing the definitions we have to explicitly set \voiceOne and \voiceTwo (and reset it with \oneVoice afterwards), and we basically have everything we need: \version "2.16.2" \relative c' { \clef treble \time 6/8 \key b \major ais'4 gis8 gis'4.~\>\( gis16 fis eis dis cisis dis\! e eis$$ gisis,$$ais << { \voiceTwo \times 2/3 { b16 eis, ais } } \new Voice { \voiceOne \override TupletNumber #'stencil = ##f \times 2/3 { b16\accent[ s ais] } } >> \oneVoice gis4.\accent fis4$$
}

Everything’s technically correct now

All there is left to be done yet is tweaking the second phrasing slur a little bit, which is done using the \shape function (but not explained this time 🙂 ).

Final version (click to view source code)

2 thoughts on “Voice Contexts in Temporary Polyphonic Sections”

1. C. Schlosser

I often use such “inactive” voices, but instead of hiding notes, I use e.g.  s1*30 . I’m transcribing Renaissance Vihuela/Guitar tablature, often voices appear and only last for a measure or two. I’ve once tried to write a function to do something like this (unfortunately I failed):

<<
\new Voice { ... }
\new Voice { ... }