Kieren MacMillan <kieren_macmillan <at> sympatico.ca> writes:
> You can write R1*48 in the *part*, but if a shared variable (say, a
global with other changes in it) is simultaneous-ed with it, the R1*48 gets
broken by Lilypond. This is what I'm trying to avoid.
>
Let's try it out, then, using music functions. I think that merging
skips after filtering out any irrelevant changes is good to do by default,
but we should only merge { R1*7 R1*8 } if explicitly asked.
music = \context Staff <<
\compressFullBarRests
{s1*10 \tag#'score \break s1*10}
{R1*5 R1*7^\markup\eyeglasses R1*8} >>
\keepWithTag #'part \music
\mergeSkips \keepWithTag #'part \music
\mergeFullBarRests \keepWithTag #'part \music
Try the definitions below (possibly after correcting for email corruption)
in a .ly file included before the examples above:
#(define (append-merge x l r)
"Add x to the head of list l, merging skips,
and if r is true also merging full measure rests."
(if (and (pair? l)
(ly:music? x)
(ly:music? (car l))
(or (and (music-is-of-type? x 'skip-event)
(music-is-of-type? (car l) 'skip-event))
(and r
(music-is-of-type? x 'multi-measure-rest)
(music-is-of-type? (car l) 'multi-measure-rest)))
(not (pair? (ly:music-property (car l) 'articulations))))
(let ((total
(ly:moment-add
(ly:music-duration-length (car l))
(ly:music-duration-length x)
)))
(set! (ly:music-property x 'duration)
(make-duration-of-length total))
(cons x (cdr l)))
(cons x l)))
mergeSkips = #(define-music-function
(parser location rests-also music) ((boolean?) ly:music?)
"Merge successive skips in sequential music,
optionally merge full-measure rests as well."
(music-map
(lambda (m)
(if (music-is-of-type? m 'sequential-music)
(ly:music-set-property! m
'elements
(fold-right (lambda (x l)
(append-merge x l rests-also))
'()
(ly:music-property m 'elements))))
m)
music))
mergeFullBarRests = #(define-music-function
(parser location music) (ly:music?)
#{ \mergeSkips ##t $music #})
_______________________________________________
lilypond-user mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/lilypond-user