]> git.donarmstrong.com Git - lilypond.git/commitdiff
Make Completion_heads_engraver respect tuplets and scaling.
authorPál Benkő <benko.pal@gmail.com>
Tue, 4 May 2010 21:32:54 +0000 (22:32 +0100)
committerNeil Puttock <n.puttock@gmail.com>
Tue, 4 May 2010 21:36:26 +0000 (22:36 +0100)
Use compression factor from original note to calculate durations of
cloned notes.

input/regression/completion-heads-tuplets.ly [new file with mode: 0644]
lily/completion-note-heads-engraver.cc

diff --git a/input/regression/completion-heads-tuplets.ly b/input/regression/completion-heads-tuplets.ly
new file mode 100644 (file)
index 0000000..a498330
--- /dev/null
@@ -0,0 +1,20 @@
+\version "2.13.20"
+
+\header {
+  texidoc = "
+Completion heads may be used with tuplets (and compressed music) too.
+"
+}
+
+\layout {
+  \context {
+    \Voice
+    \remove "Note_heads_engraver"
+    \consists "Completion_heads_engraver"
+  }
+}
+
+\context Staff \relative c'' {
+  \set tupletSpannerDuration = #(ly:make-moment 1 1)
+  \times 2/3 { g1 g g }
+}
index 3e507ec8862723aecca477bdc09517ed3432d3c8..eb454e71524660de3583832578bf60fa4c1a7fd2 100644 (file)
@@ -87,6 +87,8 @@ class Completion_heads_engraver : public Engraver
   Rational left_to_do_;
   Rational do_nothing_until_;
 
+  Rational factor_;
+
   Moment next_barline_moment ();
   Item *make_note_head (Stream_event*);
 
@@ -187,16 +189,17 @@ Completion_heads_engraver::process_music ()
   Duration note_dur;
   Duration *orig = 0;
   if (left_to_do_)
-    note_dur = Duration (left_to_do_, false);
+    note_dur = Duration (left_to_do_ / factor_, false).compressed (factor_);
   else
     {
       orig = unsmob_duration (note_events_[0]->get_property ("duration"));
       note_dur = *orig;
+      factor_ = note_dur.factor ();
     }
   Moment nb = next_barline_moment ();
   if (nb.main_part_ && nb < note_dur.get_length ())
     {
-      note_dur = Duration (nb.main_part_, false);
+      note_dur = Duration (nb.main_part_ / factor_, false).compressed (factor_);
 
       do_nothing_until_ = now.main_part_ + note_dur.get_length ();
     }