5

Adding a NullVoice to a staff with two other voices affects the orientation of ties and slurs. Consider the following three Examples and their output:

\version "2.22.2"
<<
  \new NullVoice { c } \\
  \stemUp { b2~ b} \\
  \stemDown { e2~ e }
>>
\version "2.22.2"
<<
  \stemUp { b2~ b} \\
  \stemDown { e2~ e }
>>
\version "2.22.2"
<<
  { b2~ b} \\
  { e2~ e } \\
  \new NullVoice { c }
>>

The version containig a NullVoice before the other voices (1) has a downwards facing tie, although it is the first (topmost) visible voice in the staff, and an upwards facing one in the voice below. If the NullVoice is removed (2), the upper tie is facing upwards, the lower one downwards, which is the expected result. Moving the NullVoice below the visible voices (3) produces the same output as (2) without the NullVoice.

Exactly the same happens with slurs in place of ties.

[Edit:] Rests also seem to be affected in a similar way, they are displaced vertically if a NullVoice is present.

My question now is: Why does (and why should) a NullVoice, which exists to be invisible, affect the visual output of the other voices?

(Obviously the third option is the way to go in this specific scenario, because it works as expected and saves you from manually setting the stem directions.)

Would this be considered a bug, or is there a reasoning behind this behaviour that I don't see?


tldr: Is it intended (and if yes, why) that invisible voices affect the visual output?

1
  • In the second example stemUp and stemDown are obviously not needed, I left them there to make it clear, that the only difference to the first example is the removal of the NullVoice.
    – iTeaMaster
    Commented Apr 20, 2022 at 17:38

3 Answers 3

4

Your output will be just the same if you remove every \new NullVoice { c } from your source while retaining every \\ (particularly those you placed behind the NullVoice). So it's not the NullVoice that is causing your problem.

3

LilyPond is doing exactly what you are asking of it. To see exactly what that is, try

\version "2.22.2"

mus =
<<
  \new NullVoice { c } \\
  \stemUp { b2~ b} \\
  \stemDown { e2 e }
>>
<<
  \stemUp { b2~ b} \\
  \stemDown { e2 e }
>>
<<
  { b2~ b} \\
  { e2 e } \\
  \new NullVoice { c }
>>

\void \displayLilyMusic #(ly:score-music (scorify-music mus))

To wit: everything in << ... >> is typeset to happen at the same time (unless enclosed in { ... } which makes sequential music locally). However, stuff separated by \\ is specially treated and set as Voice 1, 2, 3 ... including the necessary instructions for ties and slurs (1 is the topmost voice, 2 the bottommost voice, 3 the second topmost voice, 4 the second bottommost voice and so on, with odd voice numbers having upward-pointing stems, slurs and ties, and even voice numbers being downward-pointing in that respect).

When writing \new ... as one such part, this will end up in a context of its own and not use the settings implied from its relation to \\. But anything else will take the settings of \voiceOne, \voiceTwo...

4
  • @user86480 I see that it is confusing that I have put three seperate examples in one code block. I should change that for clarity. But I understand perfectly well both the meaning of << ... >> and a double backslash to seperate voices. I am also aware that 'anonymous' voices get the default voiceN names implicitly. It appears to me that you have not understood my actual question.
    – iTeaMaster
    Commented Apr 20, 2022 at 16:49
  • @Ramillies could you elaborate how the implicit declaration of voiceOne etc. relates to the shown behaviour? The original code that I extracted this minimal example from declares the used voice variables explicitly.
    – iTeaMaster
    Commented Apr 20, 2022 at 17:44
  • 1
    @iTeaMaster You may have misunderstood user86480's answer. The Null voice is still assigned voiceOne. Even though it's invisible (at this point in the score), LilyPond still preserves its voiceOne status in order to preserve any other \voiceN (i.e., to maintain voice consistency throughout the score). A workaround is to use the NullVoice \with { \remove "Slur_engraver" }. This "fixes" the slurs and also eliminates the need for \stemUp and \stemDown. Alternatively, \voiceOne and \voiceTwo can be explicitly given to the non-Null voices.
    – Aaron
    Commented Apr 21, 2022 at 7:49
  • @iTeaMaster, I think that this answer summarizes it quite well: "odd voice numbers having upward-pointing stems, slurs and ties, and even voice numbers being downward-pointing in that respect." So in your first example, the NullVoice is voice 1, the B's are voice 2 with everything down (except for stems which you have overriden with \stemUp), the E's are voice 3 with everything up (ditto for stems).
    – Ramillies
    Commented Apr 21, 2022 at 9:16
0

It is very simple: << ... \\ ... \\ ... >> will create three voices, the first music expression as Voice 1 (top), the second as 2 (bottom), the third as three (second top). So \new NullVoice ... then basically become something like new Voice { \voiceOne \new NullVoice ... }.

To get the NullVoice properly ignored you should do something like

<<
  \new NullVoice ...
  <<
    ... \\
    ...
  >>
>>

or manually

<<
  \new NullVoice ...
  \new Voice { \voiceOne ... }
  \new Voice { \voiceTwo ... }
>>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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