Hi Lukas,

That almost works as intended, but for rests of 12-15 measures (and 28-31,
&c), is not quite correct when compared with historical examples:
[image: image.png]
I do not so to say "speak" Scheme fluently, but after some attempts, the
solution appears to be a simple change to the "when" statement:
(when (or (equal? glyph "rests.M3") (equal? glyph "rests.M2"))

That gets the longa (4 measure) rests offset as desired when required. I'm
able to reduce the unnecessary white-space with the use of \override
MultiMeasureRest.bound-padding and a negative value (-4 or -5 work well) -
that has a practical limit as very long rests (50+ measures) will still
have a fair bit of white space on either end, though when you get to that
kind of length in baroque music the instrument is probably sitting the
entire movement out (a simple "tacet" will suffice), so not exactly a
common occurrence in terms of needing to be engraved...

Thanks very much for the help!

Aleksa

Am Mo., 15. Dez. 2025 um 12:51 Uhr schrieb Lukas-Fabian Moser <[email protected]>:

> 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:
> [image: 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:
> [image: 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:
> [image: 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
>

Reply via email to