]> git.donarmstrong.com Git - lilypond.git/commitdiff
Fix 386.
authorRune Zedeler <rune@lilypond.org>
Sat, 28 Jul 2007 22:20:24 +0000 (08:20 +1000)
committerJoe Neeman <joeneeman@gmail.com>
Sat, 28 Jul 2007 22:20:24 +0000 (08:20 +1000)
Fix dot and beam calculations for tremolos.

input/regression/repeat-tremolo-beams.ly [new file with mode: 0644]
input/regression/repeat-tremolo-dots.ly [new file with mode: 0644]
lily/chord-tremolo-iterator.cc
scm/music-functions.scm

diff --git a/input/regression/repeat-tremolo-beams.ly b/input/regression/repeat-tremolo-beams.ly
new file mode 100644 (file)
index 0000000..8ad418e
--- /dev/null
@@ -0,0 +1,13 @@
+\version "2.10.25"
+
+\header {
+  texidoc = "Each of the staves here should have four tremolo beams."
+}
+
+\paper { ragged-right = ##t }
+<<
+  \repeat tremolo 8 { c64 e64 }
+  \repeat tremolo 12 { c64 e64 }
+  \repeat tremolo 14 { c64 e64 }
+  \repeat tremolo 15 { c64 e64 }
+>>
\ No newline at end of file
diff --git a/input/regression/repeat-tremolo-dots.ly b/input/regression/repeat-tremolo-dots.ly
new file mode 100644 (file)
index 0000000..9fa8402
--- /dev/null
@@ -0,0 +1,11 @@
+\version "2.10.0"
+
+\header {
+  texidoc = "Dots are added to tremolo notes if the durations involved require them."
+}
+
+\paper{ ragged-right = ##t }
+\score { \relative c' {
+        c8 \repeat "tremolo" 14 { c32 a32 } |
+  }
+}
\ No newline at end of file
index 05e56e24a52f6b8d34919afdccbbcb1474f13f2f..71e206aa0322d4b403a8c5ed5b407d104e54f8c9 100644 (file)
@@ -41,7 +41,7 @@ Chord_tremolo_iterator::get_music_list () const
   Rational note_dur = total_dur / Rational (elt_count * Repeated_music::repeat_count (mus));
 
   SCM tremolo_type = scm_int2num (note_dur.den ());
-  int expected_beaming_ = max (0, (intlog2 (total_dur.den ()) - 2));
+  int expected_beaming_ = max (0, (intlog2 (total_dur.den ()) - intlog2 (total_dur.num () + 1) - 1));
 
   if (elt_count == 1)
     {
index 928eaf71692a5cf06c4f58fd480e3f7c290fab22..ce2286f3e25a0783d3012b71e32088b69784e0d7 100644 (file)
@@ -233,13 +233,11 @@ Returns `obj'.
     (set! (ly:music-property r 'repeat-count) (max times 1))
     (set! (ly:music-property r 'elements) talts)
     (if (equal? name "tremolo")
-       (let* ((dot? (zero? (modulo times 3)))
-              (dots (if dot? 1 0))
-              (mult (if dot?
-                        (quotient (* times 2) 3)
-                        times))
-              (shift (- (ly:intlog2 mult))))
-         
+       (let* ((dots (1- (logcount times)))
+              (mult (/ (* times (ash 1 dots)) (1- (ash 2 dots))))
+              (shift (- (ly:intlog2 (floor mult)))))
+         (if (not (integer?  mult))
+              (ly:warning (_ "illegal tremolo repeat count: ~a") times))
          (if (memq 'sequential-music (ly:music-property main 'types))
              ;; \repeat "tremolo" { c4 d4 }
              (let ((children (length (ly:music-property main 'elements))))