]> 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:28:42 +0000 (08:28 +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 45ddbc443d65121fc4b1b7fcadf009fb67fef568..5b30b71878da0878676467b8eb35aac88fa5452c 100644 (file)
@@ -39,7 +39,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 fc401c6b17e26a685704dfe77a5619a54be328b2..e4f598b813000c943c7304eb86d02dbae860fe15 100644 (file)
@@ -217,13 +217,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))))