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.

Reply via email to