-\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 "|."
}
-
-
;; 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)))
(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)