]> git.donarmstrong.com Git - lilypond.git/commitdiff
Add unfold-repeats-fully function which will expand repeats in the data
authorDavid Kastrup <dak@gnu.org>
Thu, 28 Nov 2013 16:25:11 +0000 (17:25 +0100)
committerDavid Kastrup <dak@gnu.org>
Sat, 15 Feb 2014 18:07:49 +0000 (19:07 +0100)
scm/music-functions.scm

index 45e07d6f7ae132c8dfcab51b416cc0373f479cdc..d57a2e22bf5c84f6e587136c95b736c1608e9849 100644 (file)
@@ -382,6 +382,28 @@ beats to be distinguished."
               (unfold-repeats e)))
     music))
 
+(define-public (unfold-repeats-fully music)
+  "Unfolds repeats and expands the resulting @code{unfolded-repeated-music}."
+  (map-some-music
+   (lambda (m)
+     (and (music-is-of-type? m 'unfolded-repeated-music)
+          (make-sequential-music
+           (ly:music-deep-copy
+            (let loop ((n (ly:music-property m 'repeat-count))
+                       (alts (ly:music-property m 'elements))
+                       (body (ly:music-property m 'element)))
+              (cond ((<= n 0) '())
+                    ((null? alts)
+                     (cons body (loop (1- n) alts body)))
+                    (else
+                     (cons* body (car alts)
+                            (loop (1- n)
+                                  (if (pair? (cdr alts))
+                                      (cdr alts)
+                                      alts)
+                                  body)))))))))
+   (unfold-repeats music)))
+
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; property setting music objs.