Le 30/07/2021 à 14:46, Daniel Benjamin Miller a écrit :
Hi all,
I want to replicate this feature, often found in manually-engraved
vocal scores. Although the feature I am talking about should be
obvious from the images, I will attempt to describe it. Basically, the
staff group starts partway through a system, as we switch from a solo
to a choral part. If necessary, another staff appears (filled with
rests as appropriate).
I know it is possible to insert a [ bar manually (although I cannot
quite figure out how to do this in a way that looks like a staff group
across staffs). Since the staff grouping needs to continue in the
following systems, and since I don't want to manually break my score,
I don't think that's a reasonable option either.
The solution I have been trying to work out essentially involves
trying to having the systems all be part of the staff group, but to
suppress the engraving of the staff group bracket where appropriate
(or something like that?). Still, it's proven to be a bit too
intricate for me.
Has anyone else done this? I know there are some of you who have
greater expertise, and I'm probably not the first person to at least
try to include this element in a score.
All the best,
Daniel
Hi Daniel,
Too bad that I can't find the snippet again -- anyway, here is a
remixed version of a hacky piece of code I once wrote for the
French list:
\version "2.22.1"
#(define add-bracket
(grob-transformer 'stencil
(lambda (grob original)
(let* ((vag (ly:grob-object grob 'axis-group-parent-Y))
(elts (ly:grob-array->list
(ly:grob-object vag 'elements)))
(system-start-delim
(filter
(lambda (g)
(and (grob::has-interface g
'system-start-delimiter-interface)
(not (eq? 'SystemStartBar (grob::name g)))))
elts)))
(if (eqv? 1 (length system-start-delim))
(ly:stencil-combine-at-edge
original
X
LEFT
(ly:grob-property (first system-start-delim)
'stencil)
(ly:grob-property grob 'padding))
(ly:warning "should have 1 delimiter, found ~a"
(length system-start-delim)))))))
forceBar =
\context Timing \applyContext
#(lambda (context)
(if (null? (ly:context-property context 'whichBar))
(set! (ly:context-property context 'whichBar)
"")))
midStaffBracket = {
\forceBar
\once \override StaffGroup.SpanBar.stencil = #add-bracket
}
\layout {
\context {
\StaffGroup
% Padding added between the bracket and the bar in case they
% are both present.
\override SpanBar.padding = 0.8
}
}
\new StaffGroup \with {
%% Change the number of systems with no bracket at the beginning.
\alterBroken transparent #(make-list 2 #t) SystemStartBracket
}
<<
\new Staff {
\repeat unfold 20 c'1
c2 \midStaffBracket c2 \midStaffBracket
\repeat unfold 79 c'1
}
\new Staff \repeat unfold 100 c'1
>>
(From a development perspective...)
To enable doing this more properly, one would have to start out
by making system start delimiters items rather than spanners. The
use of \alterBroken is not super natural here, it's tripped up
other before... Last time I looked, the problem was that in
theory you can always take the X-extent and X-offset of an
item before line breaking, and system start braces (as opposed
to brackets) have a horizontal extent that depends on the amount
of space between staves. So I wasn't very sure about the approach,
but probably this could be picked up.
Cheers,
Jean