On 2020-07-01 2:07 am, Maurits Lamers wrote:
Follow up question: is there a way to know the "parent" of the voices
as they are defined in the code?
In the following example, I would like to determine that voice "two"
splits off from voice "one" without relying on the context-id.
(ly:context-parent ctx) gives me the staff, not the "parent voice"...

[...]

If I am not mistaken, Voices do not form a hierarchy with each other. The parent context will always be some form of Staff. Consider:

%%%%
\version "2.20.0"

\new Voice = outer { e'8 g' \new Voice = inner { a'2 } b'4 }
%%%%

LilyPond syntax might make it appear as if one Voice is "inside" another, but that is an illusion. In reality, the two voices are in parallel with each other. The inlining of the inner Voice here only serves to keep the outer Voice alive.

Here is an alternate way to view the above:

%%%%
\version "2.20.0"

{
  \new Voice = outer { e'8 g' }
  <<
    \context Voice = outer { s2 }
    \new Voice = inner { a'2 }
  >>
  \context Voice = outer { b'4 }
}
%%%%

Hopefully it is more clear that the two Voices are siblings, not parent-child.


-- Aaron Hill

Reply via email to