Le vendredi 17 mars 2023 à 11:35 -0700, Alexandre Loomis a écrit :
> Hi, I'm running into an issue using \autoChange. I'd like CrossStaff to share
> the lower staff (and upper with another voice, but that doesn't seem to cause
> any issues), but it's creating its own.
>
> \version "2.24.0"
>
> CrossStaff = \autoChange f {
> \relative c' {
> c2 c,
> }
> }
>
> VoiceTwo = \relative { \clef "bass" c,1 }
>
> \new PianoStaff <<
> \new Staff = "up" {
> \new Voice \CrossStaff
> }
> \new Staff = "down" {
> \new Voice \VoiceTwo
> }
> >>
Try
```
\version "2.24.1"
CrossStaff = \autoChange f {
\relative c' {
c2 c,
}
}
VoiceTwo = \relative { \clef "bass" c,1 }
\new PianoStaff <<
\new Staff = "up" {
\new Voice \CrossStaff
}
\context Staff = "down" {
\new Voice \VoiceTwo
}
>>
```
As you can see in the examples in the documentation, `\autoChange` is designed
to create two staves at once if not already created. In this case, when
`\autoChange` is seen by LilyPond at the start of the music, there is no "down"
staff yet, so it's created, and then you create another one with `\new`. By
using `\context` instead of new (see [Creating and referencing
contexts](https://lilypond.org/doc/v2.24/Documentation/notation/creating-and-referencing-contexts)),
you insert your `\VoiceTwo` inside the same context rather than creating a new
one.
signature.asc
Description: This is a digitally signed message part
