[Top][All Lists]

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

workaround: keeping piano staves alive together in a RemoveEmptyStaffCon

From: Valentin Villenave
Subject: workaround: keeping piano staves alive together in a RemoveEmptyStaffContext
Date: Wed, 17 Dec 2008 12:59:05 +0100

Hi everyone,

this one has really kept bugging me for a while. I'm referring to
(what else?)

I have a huge score to publish within days, and I really need to find
some solution. Here's my latest attempt; it's almost working but
problems still occur when new Voice contexts are created within one of
the staves.

I hope someone smarter than me may find a solution; it's currently a
very dirty thing and it produces a lot of NaN errors.


one = {
  \repeat unfold 4 { a4 b c' d'} \break
  \repeat unfold 4 { a4 b c' d'} \break
  \repeat unfold 4 { a4 b c' d'} \break
two = { \clef bass
  \repeat unfold 4 { a4 b  c' d'} \break
  \repeat unfold 4 { a4. << c' \\ c  >> c' d'} \break
  R1*4 \break
three = { \clef bass
  \repeat unfold 4 { a,4 b, c d} \break
  R1*4 \break
  R1*4 \break

\layout {
  \context {
  \context {
    \name PseudoVoice
    \type "Engraver_group"
    \consists "Note_heads_engraver"
    \override NoteHead #'stencil = ##f
  \context {
    \accepts PseudoVoice

#(define (remove music)
"Sends the whole thing to Devnull whenever possible"
  (context-spec-music music 'Devnull))

#(define (pseudo-remove music)
"In polyphonic situations, I need a better plan"
  (ly:music-set-property! music 'tweaks
    (acons 'stencil #f ;; empty-stencil works better
        (ly:music-property music 'tweaks)))

#(define (event-filter event)
  (let ((n (ly:music-property event 'name)))
  (if (or
     (eq? n 'ContextSpeccedMusic) ; to avoid clefs and ottavas
     (eq? n 'ContextChange)) ; cross-staff voices are supported
    (music-map remove event))
  (if (eq? n 'SimultaneousMusic) ; this is where I could use some help.
       (music-map pseudo-remove event))))

makeGhost =
#(define-music-function (parser location music) (ly:music?)
  (context-spec-music (music-filter event-filter music) 'PseudoVoice))

#(define-music-function (parser location up down) (ly:music? ly:music?)
    \new Staff = "up" \with { \remove Accidental_engraver }
       \new Voice \with { \consists Accidental_engraver }
          { \clef treble $up }
       \new Voice { \makeGhost $down }
    \new Staff = "down" \with { \remove Accidental_engraver }
       \new Voice \with { \consists Accidental_engraver }
          { \clef bass $down }
       \new Voice { \makeGhost $up }

\score { <<
    \new Staff \one
    \new PianoStaff \LetsTryThis \two \three
>> }



reply via email to

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