[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Feature Request] \compressFullBarRests improvement(s)
From: |
Keith OHara |
Subject: |
Re: [Feature Request] \compressFullBarRests improvement(s) |
Date: |
Sun, 22 Dec 2013 21:35:33 +0000 (UTC) |
User-agent: |
Loom/3.14 (http://gmane.org/) |
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 #})
- Re: [Feature Request] \compressFullBarRests improvement(s), (continued)
- Re: [Feature Request] \compressFullBarRests improvement(s), Werner LEMBERG, 2013/12/22
- Re: [Feature Request] \compressFullBarRests improvement(s), Simon Bailey, 2013/12/22
- Re: [Feature Request] \compressFullBarRests improvement(s), James Harkins, 2013/12/22
- Re: [Feature Request] \compressFullBarRests improvement(s), Werner LEMBERG, 2013/12/22
- Re: [Feature Request] \compressFullBarRests improvement(s), address@hidden, 2013/12/22
- Re: [Feature Request] \compressFullBarRests improvement(s), Werner LEMBERG, 2013/12/22
- Re: [Feature Request] \compressFullBarRests improvement(s), address@hidden, 2013/12/22
- Re: [Feature Request] \compressFullBarRests improvement(s), Werner LEMBERG, 2013/12/22
- Re: [Feature Request] \compressFullBarRests improvement(s), Alex Loomis, 2013/12/22
- RE: [Feature Request] \compressFullBarRests improvement(s), Kieren MacMillan, 2013/12/22
- Re: [Feature Request] \compressFullBarRests improvement(s),
Keith OHara <=
- Re: [Feature Request] \compressFullBarRests improvement(s), Kieren MacMillan, 2013/12/26
- Re: [Feature Request] \compressFullBarRests improvement(s), Keith OHara, 2013/12/27
- Re: [Feature Request] \compressFullBarRests improvement(s), Alex Loomis, 2013/12/27
- Re: [Feature Request] \compressFullBarRests improvement(s), Kieren MacMillan, 2013/12/27
- Re: [Feature Request] \compressFullBarRests improvement(s), David Kastrup, 2013/12/27
- Re: [Feature Request] \compressFullBarRests improvement(s), Kieren MacMillan, 2013/12/27
- the "perfect" break-engraver (was Re: [Feature Request] \compressFullBarRests improvement(s)), Kieren MacMillan, 2013/12/27
- Re: the "perfect" break-engraver (was Re: [Feature Request] \compressFullBarRests improvement(s)), Jay Anderson, 2013/12/28
- Re: the "perfect" break-engraver (was Re: [Feature Request] \compressFullBarRests improvement(s)), Kieren MacMillan, 2013/12/28
- Re: [Feature Request] \compressFullBarRests improvement(s), James Harkins, 2013/12/22