lilypond-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Combining Multimeasure rests


From: Kieren MacMillan
Subject: Re: Combining Multimeasure rests
Date: Tue, 11 Nov 2014 10:55:07 -0500

> there might be something there to look at.

In particular, consider the snippet:

\version "2.19"

#(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 #})

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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]