[prev in list] [next in list] [prev in thread] [next in thread]
List: lilypond-user
Subject: Re: \section across staves
From: Timothy Lanfear <timothy () lanfear ! me>
Date: 2024-02-26 11:26:59
Message-ID: a6533bf4-4052-4968-9664-ac5f20a9a8fc () lanfear ! me
[Download RAW message or body]
On 26/02/2024 02:04, Garrett Fitzgerald wrote:
> I see this has been raised before, and is intentional behavior, but I
> just wanted to be clear. When typesetting band marches, I have a
> \rehearsalMarks definition that includes double bars as needed. I
> define all the parts in a single file (for example, MaineFestival.ly)
> and then have multiple part files (MFestClar1.ly) and score files
> (MFestScore.ly). In MFestClar1.ly, I will include both \rehearsalMarks
> and \clarinetOne, and get the bars as specified. In MFestScore.ly, I
> will only include \rehearsalMarks with the \fluteOne staff, and the
> bars carry down through all the other staves.
>
> Now, with the advent of \section, I thought I could do this the same
> way. It worked fine for the Clar1 part, but when I tried the score, I
> found that the \section double bars only appeared in the flute staff
> where they were included, and did not carry down to the cornet staff
> where I had the actual music that I had put in up to this point.
>
> So, should I basically give up on \section? Should I include it in the
> individual parts, instead of relying on the \rehearsalMarks
> definition? Or am I missing a point somewhere?
>
Here is a possible solution. The SectionBcast engraver listens for
section and fine events from the rmarks context and broadcasts them to
other contexts. The staff context for the instruments have another
engraver (SectionRecv) that listens for the broadcasted events and
processes them. You probably want to put the additional code in an
include file for easy reuse.
\version "2.24.2"
%% Put this part in a separate file to be included
#(define (add-context-property symbol type?)
(set-object-property! symbol 'translation-type? type?)
(set-object-property! symbol 'translation-doc "custom context property")
(set! all-translation-properties (cons symbol
all-translation-properties)) symbol)
#(add-context-property 'channel ly:dispatcher?)
SectionBcast =
#(lambda (context)
(make-engraver
((initialize translator)
(let* ((channel (ly:make-dispatcher))
(score (ly:context-find context 'Score)))
(ly:context-set-property! score 'channel channel)))
(listeners
((fine-event engraver event)
(let ((score (ly:context-find context 'Score)))
(ly:broadcast (ly:context-property score 'channel) event)))
((section-event engraver event)
(let ((score (ly:context-find context 'Score)))
(ly:broadcast (ly:context-property score 'channel) event))))))
SectionRecv =
#(lambda (context)
(make-engraver
((initialize translator)
(let* ((score (ly:context-find context 'Score))
(channel (ly:context-property score 'channel)))
(ly:connect-dispatchers (ly:context-event-source context)
channel)))))
\layout {
\context { \Staff \consists \SectionRecv }
}
%% end of include file
rmarks = { s1*2 \mark\default s1*2 \section a1*2 \fine }
flute = { \repeat unfold 6 c''1 }
oboe = { \repeat unfold 6 f'1 }
\score {
<<
\new Devnull \with { \consists \SectionBcast } \rmarks
\new Staff \with { instrumentName="flute" } \flute
\new Staff \with { instrumentName="oboe" } \oboe
>>
}
--
Timothy Lanfear, Bristol, UK.
[Attachment #3 (text/html)]
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<div class="moz-cite-prefix">On 26/02/2024 02:04, Garrett Fitzgerald
wrote:<br>
</div>
<blockquote type="cite"
cite="mid:CAGd8MrfnWCgVRi+MjTni_bG6TCsa59_JJVZst+P8T+6ZWUTS_w@mail.gmail.com">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<div dir="ltr">
<div>I see this has been raised before, and is intentional
behavior, but I just wanted to be clear. When typesetting band
marches, I have a \rehearsalMarks definition that includes
double bars as needed. I define all the parts in a single file
(for example, MaineFestival.ly) and then have multiple part
files (MFestClar1.ly) and score files (MFestScore.ly). In
MFestClar1.ly, I will include both \rehearsalMarks and
\clarinetOne, and get the bars as specified. In MFestScore.ly,
I will only include \rehearsalMarks with the \fluteOne staff,
and the bars carry down through all the other staves.</div>
<div><br>
</div>
<div>Now, with the advent of \section, I thought I could do this
the same way. It worked fine for the Clar1 part, but when I
tried the score, I found that the \section double bars only
appeared in the flute staff where they were included, and did
not carry down to the cornet staff where I had the actual
music that I had put in up to this point.</div>
<div><br>
</div>
<div>So, should I basically give up on \section? Should I
include it in the individual parts, instead of relying on the
\rehearsalMarks definition? Or am I missing a point somewhere?</div>
<div><br>
</div>
</div>
</blockquote>
<p>Here is a possible solution. The SectionBcast engraver listens
for section and fine events from the rmarks context and broadcasts
them to other contexts. The staff context for the instruments have
another engraver (SectionRecv) that listens for the broadcasted
events and processes them. You probably want to put the additional
code in an include file for easy reuse.</p>
<p><font face="monospace">\version "2.24.2"<br>
<br>
%% Put this part in a separate file to be included<br>
#(define (add-context-property symbol type?)<br>
(set-object-property! symbol 'translation-type? type?)<br>
(set-object-property! symbol 'translation-doc "custom context
property")<br>
(set! all-translation-properties (cons symbol
all-translation-properties)) symbol)<br>
<br>
#(add-context-property 'channel ly:dispatcher?)<br>
<br>
SectionBcast = <br>
#(lambda (context)<br>
(make-engraver<br>
((initialize translator)<br>
(let* ((channel (ly:make-dispatcher))<br>
(score (ly:context-find context 'Score)))<br>
(ly:context-set-property! score 'channel channel)))<br>
<br>
(listeners<br>
((fine-event engraver event)<br>
(let ((score (ly:context-find context 'Score)))<br>
(ly:broadcast (ly:context-property score 'channel)
event)))<br>
((section-event engraver event)<br>
(let ((score (ly:context-find context 'Score)))<br>
(ly:broadcast (ly:context-property score 'channel)
event))))))<br>
<br>
SectionRecv =<br>
#(lambda (context)<br>
(make-engraver<br>
((initialize translator)<br>
(let* ((score (ly:context-find context 'Score))<br>
(channel (ly:context-property score 'channel)))<br>
(ly:connect-dispatchers (ly:context-event-source
context) channel)))))<br>
<br>
\layout {<br>
\context { \Staff \consists \SectionRecv }<br>
}<br>
%% end of include file<br>
<br>
rmarks = { s1*2 \mark\default s1*2 \section a1*2 \fine }<br>
flute = { \repeat unfold 6 c''1 }<br>
oboe = { \repeat unfold 6 f'1 }<br>
<br>
\score {<br>
<<<br>
\new Devnull \with { \consists \SectionBcast } \rmarks<br>
\new Staff \with { instrumentName="flute" } \flute<br>
\new Staff \with { instrumentName="oboe" } \oboe<br>
>><br>
}<br>
</font><br>
</p>
<pre class="moz-signature" cols="72">--
Timothy Lanfear, Bristol, UK.</pre>
<div id="grammalecte_menu_main_button_shadow_host"
style="width: 0px; height: 0px;"></div>
</body>
</html>
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic