]> git.donarmstrong.com Git - lilypond.git/commitdiff
Fix #348.
authorNeil Puttock <n.puttock@gmail.com>
Thu, 8 Apr 2010 22:27:59 +0000 (23:27 +0100)
committerNeil Puttock <n.puttock@gmail.com>
Thu, 8 Apr 2010 22:27:59 +0000 (23:27 +0100)
* input/regression/repeat-unfold-tremolo.ly:

  emend snippet to test for single element in braces

* scm/music-functions.scm (unfold-repeats):

  only add extra shift to duration-log if there are two children in 'elements

input/regression/repeat-unfold-tremolo.ly
scm/music-functions.scm

index 71b5ac56503f47a9bce47efca3599c2979ab5159..ad0c9a26d409b8aea119d26e73cf9e605764a363 100644 (file)
@@ -1,29 +1,22 @@
-\version "2.12.0"
-\header {
-
-  texidoc = "Unfolding tremolo repeats. All fragments fill one
- measure with 16th notes exactly."
+\version "2.13.18"
 
+\header {
+  texidoc = "Unfolding tremolo repeats.  All fragments fill one
+measure with 16th notes exactly."
 }
 
 \layout { ragged-right = ##t }
 
-
-
-{
+\relative c' {
   \time 2/4 
-  \applyMusic #unfold-repeats  
-  { \repeat tremolo 4 { c'16 e' } |
-    \repeat tremolo 8 c'16 } |
-
+  \unfoldRepeats {
+    \repeat tremolo 4 { c16 e } |
+    \repeat tremolo 8 c16
+  } |
   \time 3/4 
-  \applyMusic #unfold-repeats  
-  { \repeat tremolo 6 { c'16 e' } |
-    \repeat tremolo 12 c'16 } | \bar "|."
-  
-  \bar "|."
-
-  
+  \unfoldRepeats {
+    \repeat tremolo 6 { c16 e } |
+    \repeat tremolo 12 { c16 } |
+  }
+  \bar "|."  
 }
-  
-
index e0fe136257287e828883dfec4c4d791c37fa8e6e..57f17baaa2a6588777d535457f07c06ab2ae4d47 100644 (file)
@@ -311,17 +311,15 @@ through MUSIC."
 ;; repeats.
 
 (define-public (unfold-repeats music)
-  "
-This function replaces all repeats  with unfold repeats. "
+  "This function replaces all repeats with unfolded repeats."
 
   (let ((es (ly:music-property music 'elements))
-       (e  (ly:music-property music 'element))
-       )
+       (e (ly:music-property music 'element)))
+
     (if (memq 'repeated-music (ly:music-property music 'types))
-       (let*
-           ((props (ly:music-mutable-properties music))
-            (old-name (ly:music-property music 'name))
-            (flattened  (flatten-alist props)))
+       (let* ((props (ly:music-mutable-properties music))
+              (old-name (ly:music-property music 'name))
+              (flattened (flatten-alist props)))
 
          (set! music (apply make-music (cons 'UnfoldedRepeatedMusic
                                              flattened)))
@@ -329,20 +327,22 @@ This function replaces all repeats  with unfold repeats. "
          (if (equal? old-name 'TremoloRepeatedMusic)
              (let* ((seq-arg? (memq 'sequential-music
                                     (ly:music-property e 'types)))
-                    (count  (ly:music-property music 'repeat-count))
+                    (count (ly:music-property music 'repeat-count))
                     (dot-shift (if (= 0 (remainder count 3))
-                                   -1 0)))
+                                   -1 0))
+                    (child-count (if seq-arg?
+                                     (length (ly:music-property e 'elements))
+                                     0)))
 
                (if (= 0 -1)
                    (set! count (* 2 (quotient count 3))))
 
-               (shift-duration-log music (+ (if seq-arg? 1 0)
+               (shift-duration-log music (+ (if (= 2 child-count)
+                                                1 0)
                                             (ly:intlog2 count)) dot-shift)
 
                (if seq-arg?
-                   (ly:music-compress e (ly:make-moment (length (ly:music-property
-                                                                 e 'elements)) 1)))))))
-
+                   (ly:music-compress e (ly:make-moment child-count 1)))))))
 
     (if (pair? es)
        (set! (ly:music-property music 'elements)