lilypond-user
[Top][All Lists]
Advanced

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

Snippet


From: Martín Rincón Botero
Subject: Snippet
Date: Thu, 21 Apr 2022 19:50:26 +0200

Hello,

I have this snippet that combines subsequent multimeasure rests into a multiplied one that Lilypond can compress, that I grabbed from somewhere a while ago. It used to work without errors, if I remember well, in Lilypond 2.20. In 2.22.1 it still "works" but throws an error for the first line of the snippet, namely:

syntax error, unexpected SYMBOL, expecting '.' or '='

​#(define (append-merge x l r)

It seems that something changed in 2.22 that makes the snippet misbehave. Here's the snippet:

#(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 #})
\score {
  \mergeFullBarRests {
\context Staff = "staff1" {
  \compressEmptyMeasures
  c1 R1 R1 R1
}
  }
  }

Would it be possible to update it to work on Lilypond 2.22.1?

Regards,
Martín.
Sent from Mailspring
reply via email to

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