From: David Kastrup Date: Thu, 14 Jun 2012 11:20:40 +0000 (+0200) Subject: Issue 2602: \unfoldRepeats and \repeat tremolo 7,14,15 produces weird output X-Git-Tag: release/2.15.41-1~35 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=ef7466577e0b77302723d2b5c1902dd72472fe21;p=lilypond.git Issue 2602: \unfoldRepeats and \repeat tremolo 7,14,15 produces weird output This just shamelessly copies the logic of make-repeat into unfold-repeats, on the assumption that we want to have the same rules apply for creating and unfolding tremoli. --- diff --git a/scm/music-functions.scm b/scm/music-functions.scm index edf7659748..8df16aae27 100644 --- a/scm/music-functions.scm +++ b/scm/music-functions.scm @@ -346,32 +346,35 @@ beats to be distinguished." (let ((es (ly:music-property music 'elements)) (e (ly:music-property music 'element))) - (if (memq 'repeated-music (ly:music-property music 'types)) + (if (music-is-of-type? music 'repeated-music) (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)) - (dot-shift (if (= 0 (remainder count 3)) - -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 (= 2 child-count) - 1 0) - (ly:intlog2 count)) dot-shift) - - (if seq-arg? - (ly:music-compress e (ly:make-moment child-count 1))))))) + (if (and (equal? old-name 'TremoloRepeatedMusic) + (pair? (extract-named-music e '(EventChord NoteEvent)))) + ;; This works for single-note and multi-note tremolos! + (let* ((children (if (music-is-of-type? e 'sequential-music) + ;; \repeat tremolo n { ... } + (length (extract-named-music e '(EventChord + NoteEvent))) + ;; \repeat tremolo n c4 + 1)) + (times (ly:music-property music 'repeat-count)) + + ;; # of dots is equal to the 1 in bitwise representation (minus 1)! + (dots (1- (logcount (* times children)))) + ;; The remaining missing multiplicator to scale the notes by + ;; times * children + (mult (/ (* times children (ash 1 dots)) (1- (ash 2 dots)))) + (shift (- (ly:intlog2 (floor mult))))) + + ;; Adjust the time of the notes + (ly:music-compress music (ly:make-moment children 1)) + ;; Adjust the displayed note durations + (shift-duration-log music (- shift) (- dots)))))) (if (pair? es) (set! (ly:music-property music 'elements)