Hi all,

I'm working on putting together a set of functions for handling parts
that split into multiple voices and/or staves (using functionality
David Kastrup implemented in
https://code.google.com/p/lilypond/issues/detail?id=3518).  I attach a
first version and i'd be interested in your comments.

best,
Janek
\version "2.19.13"

together = { \tag #'together <>^\markup \bold "a2" }

soloI =
#(define-music-function (parser location mus) (ly:music?)
   #{
     <<
       \tag #'together <>^\markup \bold SoloI
       \tag #'divI { #mus }
       \tag #'together { #mus }
       \tag #'divII #(mmrest-of-length mus)
     >>
   #})

sharedStems =
#(define-music-function (parser location m1 m2) (ly:music? ly:music?)
   #{
     <<
       \tag divI  { #m1 }
       \tag divII { #m2 }
       \tag together <>^\markup \bold "div"
       \tag together << #m1 #m2 >>
     >>
   #})

voiceDivisi =
#(define-music-function (parser location m1 m2) (ly:music? ly:music?)
   #{
     <<
       \tag divI  { #m1 }
       \tag divII { #m2 }
       \tag together << { \dynamicUp #m1 } \\ { \dynamicDown #m2 } >>
     >>
   #})

staffDivisi =
#(define-music-function (parser location m1 m2) (ly:music? ly:music?)
   #{
     \unset Staff.keepAliveInterfaces
     <<
       \tag divI  { #m1 }
       \tag divII { #m2 }
       \tag together #(skip-of-length m1)
       \tag together #(skip-of-length m2)
     >>
     \set Staff.keepAliveInterfaces = #'()
   #})

divisibleStaff =
#(define-music-function (parser location name music) (string? ly:music?)
   (let ((nameI (string-append name " I"))
         (nameII (string-append name " II")))
     #{
       \new GrandStaff \with {
         \consists "Keep_alive_together_engraver"
       } <<
         \new Staff \with {
           \override VerticalAxisGroup.remove-first = ##t
           \override VerticalAxisGroup.remove-empty = ##t
           \override VerticalAxisGroup.remove-layer = 1
           keepAliveInterfaces = #'()
           instrumentName = #nameI
           shortInstrumentName = #nameI
         }
         \keepWithTag divI \music

         \new Staff \with {
           \override VerticalAxisGroup.remove-first = ##t
           \override VerticalAxisGroup.remove-empty = ##t
           \override VerticalAxisGroup.remove-layer = 1
           keepAliveInterfaces = #'()
           instrumentName = #nameII
           shortInstrumentName = #nameII
         }
         \keepWithTag divII \music

         \new Staff \with {
           instrumentName = #name
           shortInstrumentName = #name
           \override VerticalAxisGroup.remove-layer = 2
         }
         \keepWithTag together \music
       >>
     #}))
\version "2.19.13"

\include "definitions.ily"

\layout {
  short-indent = 2\cm
  indent = 2\cm
  line-width = 10\cm
}

music = {
  \together
  c'4 d' e' f'
  \sharedStems
  { a' f' a' g' }
  { f' d' f' e' }
  \voiceDivisi {
    g' b' d' b'
    d'' b' g' b'
  }
  {
    g'4 e' g' e'
    b' g' b' g'
  }
  \staffDivisi
  { <a' f''> g' q b' }
  { a' <e' b' e''> a' q }
  \together
  c' d' e' f'
  \soloI { g' b' d' b' }
  \together
  <f' a'> <d' f'> <f' a'> <e' g'>
  f' e' d' c'
}

\markup \bold { Violin I part: }
\new Staff \with {
  instrumentName = "Violin I"
  shortInstrumentName = "V I"
} \keepWithTag divI \music

\markup \bold { Violin II part: }
\new Staff \with {
  instrumentName = "Violin II"
  shortInstrumentName = "V II"
} \keepWithTag divII \music

\markup \bold { Combined: }
\divisibleStaff "Violin" \music

Attachment: example.pdf
Description: Adobe PDF document

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

Reply via email to