lilypond-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: New snippet: remove staff if another is alive (for wind divisi)


From: Saul Tobin
Subject: Re: New snippet: remove staff if another is alive (for wind divisi)
Date: Fri, 3 Aug 2018 14:33:13 -0700

Those errors are from this _expression_ in the three staff example: << \global \I \II \III >>. Lilypond is implicitly creating three Voices instead of treating it as a single Voice with simultaneous music. If you replace that _expression_ with { <> << \global \I \II \III >> }, the errors go away.

Since the partcombiner doesn't currently support more than 2 arguments, this is something that requires a workaround if you want to do three parts on a single staff.

Anyway, it doesn't affect the point of this snippet, which is automatically hiding staves based on which other staves are alive on each system.

On Fri, Aug 3, 2018 at 2:23 PM Ben <address@hidden> wrote:
On 8/3/2018 5:14 PM, Saul Tobin wrote:
Hi all,

I just put together a snippet to make managing shared wind staves more automatic, particularly with triple winds that may be combined in different ways.

\version "2.19.82"

#(define remove-if-sibling
   (lambda (offsets)
     (lambda (grob)
       (let* (
               ;; The parent of a VerticalAxisGroup is a VerticalAlignment
               (parent (ly:grob-parent grob 1))
               ;; Get the children VerticalAxisGroups of the parent
               (siblings (ly:grob-object parent 'elements))
               (siblings-list
                (if (ly:grob-array? siblings)
                    (ly:grob-array->list siblings)
                    '()))
               ;; Find the siblings above or below me by offsets
               (my-vindex (ly:grob-get-vertical-axis-group-index grob))
               (enemy-indices (map (lambda (offset) (+ offset my-vindex)) offsets))
               (enemy-vaxis? (lambda (v) (member (ly:grob-get-vertical-axis-group-index v)
                                           enemy-indices)))
               (enemy-vaxes
                (filter enemy-vaxis? siblings-list))
               )
         ;; Suicide if an enemy sibling is alive
         (map
          (lambda (enemy-vaxis)
            (ly:pointer-group-interface::add-grob grob 'make-dead-when enemy-vaxis))
          enemy-vaxes)
         )
       )
     )
   )

%% Two Staff Example

global = {
  s1
  \break 
  s1
  \break
  s1*2
}

I = {
  c'''1
  \context Staff = "1" { \set Staff.keepAliveInterfaces = #'() }
  c'''1
  c'''1
  \context Staff = "1" { \unset Staff.keepAliveInterfaces }
  c'''1
}

II = {
  e''1
  e''1
  e''1
  e''1
}

<< 
  \new Staff = "1+2" \with { 
    \override VerticalAxisGroup.before-line-breaking = #(remove-if-sibling '(1))
    \override VerticalAxisGroup.remove-empty = ##t 
    \override VerticalAxisGroup.remove-first = ##t 
  } << \global \partcombine \I \II >> 
  \new Staff = "1" \with { 
    \override VerticalAxisGroup.remove-empty = ##t 
    \override VerticalAxisGroup.remove-first = ##t 
  } << \global \I >> 
  \new Staff = "2" \with { 
    \override VerticalAxisGroup.before-line-breaking = #(remove-if-sibling '(-2))
    \override VerticalAxisGroup.remove-empty = ##t 
    \override VerticalAxisGroup.remove-first = ##t 
  } << \global \II >> 
>>

%% Three Staff Example

global = {
  s1
  \break 
  s1
  \break
  s1
  \break
  s1*2
}

I = {
  c'''1
  \context Staff = "1" { \set Staff.keepAliveInterfaces = #'() }
  c'''1
  c'''1
  c'''1
  \context Staff = "1" { \unset Staff.keepAliveInterfaces }
  c'''1
}

II = {
  e''1
  e''1
  e''1
  e''1
  e''1
}

III = {
  a'1
  a'1
  \context Staff = "3" { \set Staff.keepAliveInterfaces = #'() }
  a'1
  a'1
  a'1
}

<< 
  \new Staff = "1+2+3" \with { 
    \override VerticalAxisGroup.before-line-breaking = #(remove-if-sibling '(2 5))
    \override VerticalAxisGroup.remove-empty = ##t 
    \override VerticalAxisGroup.remove-first = ##t 
  } << \global \I \II \III >>
  \new Staff = "1+2" \with { 
    \override VerticalAxisGroup.before-line-breaking = #(remove-if-sibling '(1 -1))
    \override VerticalAxisGroup.remove-empty = ##t 
    \override VerticalAxisGroup.remove-first = ##t 
  } << \global \partcombine \I \II >> 
  \new Staff = "1" \with { 
    \override VerticalAxisGroup.remove-empty = ##t 
    \override VerticalAxisGroup.remove-first = ##t 
  } << \global \I >> 
  \new Staff = "2+3" \with { 
    \override VerticalAxisGroup.before-line-breaking = #(remove-if-sibling '(2 -3))
    \override VerticalAxisGroup.remove-empty = ##t 
    \override VerticalAxisGroup.remove-first = ##t 
  } << \global \partcombine \II \III >>
  \new Staff = "2" \with { 
    \override VerticalAxisGroup.before-line-breaking = #(remove-if-sibling '(-1 -3 -4))
    \override VerticalAxisGroup.remove-empty = ##t 
    \override VerticalAxisGroup.remove-first = ##t 
  } << \global \II >> 
  \new Staff = "3" \with { 
    \override VerticalAxisGroup.remove-empty = ##t 
    \override VerticalAxisGroup.remove-first = ##t 
  } << \global \III >> 
>>


Hello,

Thanks for sharing this with us! One question...

When I just copy and paste your snippet into Frescobaldi as is, I get a few errors.  ?

=============

Interpreting music...

Interpreting music...

Interpreting music...

Interpreting music...

Interpreting music...

Preprocessing graphical objects...

Interpreting music...

Preprocessing graphical objects...


document.ly:103:3: warning: this Voice needs a \voiceXx or \shiftXx setting

e''1


document.ly:102:3
: warning: this Voice needs a \voiceXx or \shiftXx setting

e''1


document.ly:101:3: warning: this Voice needs a \voiceXx or \shiftXx setting

e''1


document.ly:100:3: warning: this Voice needs a \voiceXx or \shiftXx setting

e''1


document.ly:99:3: warning: this Voice needs a \voiceXx or \shiftXx setting

e''1


Finding the ideal number of pages...

Fitting music on 1 page...

Drawing systems...

Layout output to `./tmp-lilypond-BWUill'...

Converting to `document.pdf'...

Deleting `./tmp-lilypond-BWUill'...

Success: compilation successfully completed

Completed successfully in 1.0".

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

reply via email to

[Prev in Thread] Current Thread [Next in Thread]