Hi Ben,

your approach does work. It can be simplified quite a bit, mainly by using shortInstrumentName and \RemoveAllEmptyStaves, and not using keepAliveInterfaces, which you don’t even need. See ben-divisi.ly.

On 05.10.19 03:08, Ben wrote:
I didn't know if I should create the divisi staffgroups at the start of the piece and then hide it until it's needed, or just use it on the fly as needed (which is what I did here).


I think it’s more ‘messy’ and complicated creating them on the fly. I’d much rather keep one of them filled with music throughout, have the others quote that, and make full use of the keepAliveInterfaces approach. In all but the most complicated cases one won’t really need meddling with instrumentNames, which also removes the need to meddle with manual breaks. But of course that’s also possible—see demo-string-divisi.ly.

Best, Simon

\version "2.19.83"

\paper {
  #(set-paper-size "a7")
  left-margin = 20
  indent = 0
}

\layout {
  \context {
    \Staff
    \RemoveAllEmptyStaves
  }
}

vlIA = \repeat unfold 24 g4

\addQuote vlICommon \vlIA

vlIB = {
  \set Staff.keepAliveInterfaces = #'()
  \quoteDuring vlICommon s1*3
  \unset Staff.keepAliveInterfaces
  \repeat unfold 4 gis4
  \set Staff.keepAliveInterfaces = #'()
  \quoteDuring vlICommon s1*2
}

breaks = {
  s1*2
  \break
  s
  \break
  s
}
vlIdivADue = \set StaffGroup.shortInstrumentName = \markup\right-column {
  "Vl. I" "div. à 2"
}
vlInondiv = \set StaffGroup.shortInstrumentName = "Vl.I"
instrNameChangesVlIA = {
  s1*2
  \vlIdivADue
  s
  \vlInondiv
  s
}

\score {
  \new StaffGroup \with {
    instrumentName = "Violino I"
    shortInstrumentName = "Vl. I"
  } <<
    \new Staff << \breaks \instrNameChangesVlIA \vlIA >>
    \new Staff \vlIB
  >>
}
\version "2.19.83"

global = {
  \key c \major
  \time 4/4
}

violinI = \relative c'' {
  \global

  c1 e g e d c g e d c c
  \break
  <<
    { s1*12 }
    \new StaffGroup \with {
      alignAboveContext = "main"
      systemStartDelimiter = #'SystemStartBrace
      \override InstrumentName.self-alignment-X = -1
      shortInstrumentName = \markup { \left-column { "Vl. I" "(div.)" } }
    }

    <<
      \new Staff \with { shortInstrumentName = "1" }
      { c2 2 2 2 }
      \new Staff \with { shortInstrumentName = "2" }
      { c1 1  }
    >>
  >>
  \break
  \repeat unfold 7 { c1 } \break
}

violinII = \relative c'' {
  \global

  \repeat unfold 30 { c1 }
}

viola = \relative c' {
  \global

  \repeat unfold 30 { d1 }
}

cello = \relative c' {
  \global

  \repeat unfold 30 { e,1 }
}

violinIPart = \new Staff = "main" \with {
  instrumentName = "Violin I"
  midiInstrument = "violin"
  shortInstrumentName = "v1"
} \violinI

violinIIPart = \new Staff \with {
  instrumentName = "Violin II"
  midiInstrument = "violin"
  shortInstrumentName = "v2"
} \violinII

violaPart = \new Staff \with {
  instrumentName = "Viola"
  midiInstrument = "viola"
  shortInstrumentName = "vla"
} { \clef alto \viola }

celloPart = \new Staff \with {
  instrumentName = "Cello"
  midiInstrument = "cello"
  shortInstrumentName = "cl"
} { \clef bass \cello }

\score {
  \new StaffGroup \with {
    systemStartDelimiter = #'SystemStartSquare
  } <<
    \violinIPart
    \violinIIPart
    \violaPart
    \celloPart
  >>
  \layout {
    \context {
      \Staff
      \RemoveAllEmptyStaves
    }
  }
}

\paper {

  left-margin = 35\mm
  right-margin = 15\mm

}


_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user

Reply via email to