Greetings all.

This forum was most helpful recently in showing me how to use \context { \Staff 
\RemoveEmptyStaves } to hide non-empty staves containing music.

The purpose of this was to swap a single staff with two combined voices for two 
separate staves with one voice each after a line break, and vice versa 
(combining two voices on different staves into a single staff after a line 
break).  

(Lest anyone be confused, the voices that have the effect of appearing, in the 
score, to be split and recombined are separate Voice contexts that don't 
actually jump staves.)

The proposed solution was to use Staff context property "keepAliveInterfaces" 
to create hideStaff and showStaff commands.

hideStaff = \set Staff.keepAliveInterfaces = #'()
showStaff = \set Staff.keepAliveInterfaces = #'(
    bass-figure-interface
    chord-name-interface
    cluster-beacon-interface
    fret-diagram-interface
    lyric-syllable-interface
    note-head-interface
    tab-note-head-interface
    lyric-interface
    percent-repeat-item-interface
    percent-repeat-interface
    stanza-number-interface
    text-interface
    rest-interface  % added to allow keeping alive staves with only rests
)

This ends up working quite well for 
* short to moderate-length pieces 
* where only one score is to be created from music so annotated with \hideStaff 
and \showStaff 
* and where explicit line breaks (\beak and \noBreak) are used.

For this project, it is just about imperative to use Lilypond's automatic line 
breaking instead of explicit \break \noBreak line breaking, due to the massive 
length of the piece and the need to produce multiple versions at different font 
sizes and with different combinations of parts.

The problem is that when I use \showStaff, as defined above, it causes Lilypond 
to display the staff, starting at the PREVIOUS line break.  And I need it to 
delay showing the staff until the NEXT line break.

Anyone know how I can get Lilypond to unhide a staff at the NEXT line break?


Here's some pseudo-lilypond source the illustrates what I want to be able to 
write:

celloCombined = \relative c {   
\clef bass
| c4 c c c
.
.
.
\barNumberCheck #10
| d4 d d d
% start overlap
| \hideStaff <c e>4 ^"divided" <c e> <c e> <c e>  % staff hidden at next line 
break
| <d f>4 <d f> <d f> <d f>
| <c e>4 <c e> <c e> <c e>
| <d f>4 <d f> <d f> <d f> 
% end overlap
| R1*10
}

celloI = \relative c {
\clef bass
R1*10

\barNumberCheck #11  % measure 1 + 10 measures rest = measure 11
% start overlap
| \showStaffNextBreak e4 e e e  % staff shown at NEXT line break, not from 
previous line break
| f4 f f f
| e4 e e e
| f4 f f f 
% end overlap
| g4\p\< g, f8 f' f'4\f  % messy stuff, that's not good for one staff; voice 
crossing
.
.
. % continues
}

celloII = \relative c {
\clef bass
R1*10

\barNumberCheck #11  % measure 1 + 10 measures rest = measure 11
% start overlap
| \showStaffNextBreak c4 c c c  % staff shown at NEXT line break, not from 
previous line break
| d4 d d d
| c4 c c c
| d d d d 
% end overlap
| d'2\f> d,,4 e\!  % different dynamics
.
.
. % continues
}

\score {
\new GrandStaff <<
\new Staff \celloCombined
\new Staff \celloI
\new Staff \celloII
>>

\layout {
\context { \Staff \RemoveEmptyStaves }
}
}

This may not perfectly demonstrate everything, but the idea is that I code an 
overlap in the parts after the place I tell Lilypond to switch out the staves 
and as soon as Lilypond finds an optimal line break, it makes the switch.  As 
long as the overlap is large enough, the dropping out staff will be removed 
before the end of the overlap and the change will appear seamless without 
having to encode the whole score twice-- once in two staves and one in a 
combined single staff.


Thanks for any ideas!


_______________________________________________
lilypond-user mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/lilypond-user

Reply via email to