From 110fe421f8e51083c7498018d0d595ef6dc022f6 Mon Sep 17 00:00:00 2001 From: Rune Zedeler Date: Sun, 29 Jul 2007 08:20:24 +1000 Subject: [PATCH] Fix 386. Fix dot and beam calculations for tremolos. --- input/regression/repeat-tremolo-beams.ly | 13 +++++++++++++ input/regression/repeat-tremolo-dots.ly | 11 +++++++++++ lily/chord-tremolo-iterator.cc | 2 +- scm/music-functions.scm | 12 +++++------- 4 files changed, 30 insertions(+), 8 deletions(-) create mode 100644 input/regression/repeat-tremolo-beams.ly create mode 100644 input/regression/repeat-tremolo-dots.ly diff --git a/input/regression/repeat-tremolo-beams.ly b/input/regression/repeat-tremolo-beams.ly new file mode 100644 index 0000000000..8ad418ee13 --- /dev/null +++ b/input/regression/repeat-tremolo-beams.ly @@ -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 index 0000000000..9fa8402e9d --- /dev/null +++ b/input/regression/repeat-tremolo-dots.ly @@ -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 diff --git a/lily/chord-tremolo-iterator.cc b/lily/chord-tremolo-iterator.cc index 45ddbc443d..5b30b71878 100644 --- a/lily/chord-tremolo-iterator.cc +++ b/lily/chord-tremolo-iterator.cc @@ -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) { diff --git a/scm/music-functions.scm b/scm/music-functions.scm index fc401c6b17..e4f598b813 100644 --- a/scm/music-functions.scm +++ b/scm/music-functions.scm @@ -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)))) -- 2.39.5