Hi,

I'm looking for a way to create a MultiMeasureRest of exactly the same length as a music variable. I think having read about exactly this but I don't seem to be able to find anything, so I hacked a solution that actually seems to work. But somehow I feel there should really be a better solution that makes better use of what Lily can provide me directly.

So: Can anybody help me with making the attached file cleaner/better/whatever?

Thanks
Urs
\version "2.19.18"
#(use-modules (srfi srfi-60))

music = {
  \time 3/4
  s2.*5
  \time 4/4
  s1*3
  \time 5/16
  s16*5
  \time 4/4
  s1
}

getMusicRest =
#(define-music-function (parser location music)(ly:music?)
   (let*
    ((len (ly:music-length music))
     (num (ly:moment-main-numerator len))
     (den (ly:moment-main-denominator len))
     )
    (ly:message (format "length ~a/~a" num den))
    (make-music
     'SequentialMusic
     'elements
     (list (make-music
            'MultiMeasureRestMusic
            'duration
            (ly:make-duration (log2-binary-factors den) 0 num)
            'articulations
            '())))))

{
  <<
    \getMusicRest \music
    \new Voice \music
  >>
}

_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user

Reply via email to