Hi Aleksa,
Am 15.12.25 um 16:05 schrieb A Jakovljevic:
Hi all,
Working with older music, one often comes up with the fully written
out variety of multi-measure rests. Ex. from an original edition
(parts only) of a Vivaldi concerto:
Two bars of music in 3/8 time with a long 35 measure rest (original
edition, ca. 1725)
Now of course it is very trivial to simply change the expand-limit to
some arbitrary large value (I'll spare the code, it's simple enough to
type up), but that doesn't quite give the same style as the above:
Two bars of music in 3/8 time with a long 35 measure rest (Lilypond
with expand-limit set to #100)
Playing around with manually placed rests and offsets can get very
close (spacing around the edges would need to be smaller, although I'd
probably put just a little bit more than in the original) to what I
want, but is obviously not a very practical solution as it needs to be
done manually:
Two bars of music in 3/8 time with a long 35 measure rest (manually
placed rests and offsets)
The closeness is easy (max-symbol-separation), the alternating positions
are hard, since the combined symbols are brewed together into one
stencil in a hardcoded C++ function.
The following is a truly awful hack involving cracking up the stencil
expression and hoping that they'll look the same forever...
\version "2.25.23"
#(define (translation? stencil-expr)
(and (pair? stencil-expr)
(eq? (car stencil-expr) 'translate-stencil)))
#(define (innermost-translation stencil-expr)
(if (translation? stencil-expr)
(match stencil-expr
(('translate-stencil coord inner-stencil-expr)
(if (translation? inner-stencil-expr)
(innermost-translation inner-stencil-expr)
stencil-expr)))
stencil-expr))
#(define (translated-content stencil-expr)
(match stencil-expr
(('translate-stencil coord inner-stencil-expr)
(if (translation? inner-stencil-expr)
(translated-content inner-stencil-expr)
inner-stencil-expr))))
alternatingMMrests =
\override MultiMeasureRest.stencil =
#(grob-transformer
'stencil
(lambda (mmrest stil)
(let* ((stencils (cdr (translated-content (ly:stencil-expr stil))))
(encountered-MM3? #f))
(for-each
(lambda (translated-rest)
(if (translation? translated-rest)
(match (innermost-translation translated-rest)
(('translate-stencil coord ('named-glyph _ glyph))
(when (equal? glyph "rests.M3")
(when encountered-MM3?
(list-set! translated-rest 1 (cons (caadr
translated-rest)
(+ (cdadr
translated-rest) 1.0))))
(set! encountered-MM3? (not encountered-MM3?)))))))
stencils))
; modifying the stencil-expr in-place seems to suffice,
; so we simply return the same stencil object, cough...
stil))
\layout {
\context {
\Voice
\override MultiMeasureRest.expand-limit = 99999 % i.e. infinity
\override MultiMeasureRest.max-symbol-separation = 1.5
\alternatingMMrests
}
}
\score {
<<
\new Staff {
\key bes \major
\compressEmptyMeasures
\time 3/8
\relative c' {
b4 r8 |
R4.*35
bes'8 bes bes \bar"|."
}
}
>>
}
Lukas