lilypond-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Grace notes shouldn't shorten the previous note unless they overlap with


From: dschudy
Subject: Grace notes shouldn't shorten the previous note unless they overlap with it. (issue 29550043)
Date: Wed, 20 Nov 2013 08:17:54 +0000

Reviewers: ,

Message:
Here's a fix for a minor MIDI bug: grace notes after rests shorten the
last note before the rest.

Description:
Grace notes shouldn't shorten the previous note unless they overlap with
it.

Previously a grace note after a rest shortened the last note before the
rest.

This patch shortens the previous note to the start of the grace note
rather than by the length of the grace note, so notes before rests
aren't affected unless the grace notes are longer than the rest.

Please review this at https://codereview.appspot.com/29550043/

Affected files (+17, -1 lines):
  A input/regression/midi-grace-after-rest.ly
  M lily/note-performer.cc


Index: input/regression/midi-grace-after-rest.ly
diff --git a/input/regression/midi-grace-after-rest.ly b/input/regression/midi-grace-after-rest.ly
new file mode 100644
index 0000000000000000000000000000000000000000..8a99cddcfc295b17883fd089057f1d638648b9c3
--- /dev/null
+++ b/input/regression/midi-grace-after-rest.ly
@@ -0,0 +1,14 @@
+\header {
+  texidoc = "Grace notes shorten previous notes only if they'd overlap
+them. The A should be a full quarter note, but the C should be shortened
+to 1/4 - 9/40 * 1/8 = 71/320 (rounded down to 340/384 in MIDI)."
+}
+\version "2.18.0"
+\score {
+ \relative c' {
+   a4 r
+   \grace b8 c8... r64
+   \grace d8 e4
+ }
+ \midi { }
+}
Index: lily/note-performer.cc
diff --git a/lily/note-performer.cc b/lily/note-performer.cc
index ddf9fe39213e0d74910ce75a268808ad254d424c..db8257bd98ede565f51ace72fc25e9735b5f5069 100644
--- a/lily/note-performer.cc
+++ b/lily/note-performer.cc
@@ -96,7 +96,9 @@ Note_performer::process_music ()
                   for (vsize i = 0; i < last_notes_.size (); i++)
                     {
                       Audio_note *tie_head = last_notes_[i]->tie_head ();
- tie_head->length_mom_ += Moment (0, now_mom ().grace_part_);
+                      Moment start = tie_head->audio_column_->when ();
+                      tie_head->length_mom_ = min (tie_head->length_mom_,
+                                                   now_mom () - start);
                     }
                 }
             }





reply via email to

[Prev in Thread] Current Thread [Next in Thread]