]> git.donarmstrong.com Git - lilypond.git/commitdiff
fix handling of grace notes to shorten preceding tied notes correctly
authorAdam Spiers <lilypond@adamspiers.org>
Mon, 14 Jan 2013 00:21:45 +0000 (00:21 +0000)
committerAdam Spiers <lilypond@adamspiers.org>
Sun, 27 Jan 2013 14:25:12 +0000 (14:25 +0000)
In Note_performer::process_music(), when a grace note was encountered,
the immediately preceding Audio_note (or Audio_notes if the grace note
followed a chord) was/were shortened, but it failed to check whether the
Audio_note is part of a tie.  Ensure that any note being shortened in
this way is the head of a tie, if it is part of a tie.

https://code.google.com/p/lilypond/issues/detail?id=3091

input/regression/midi-grace-after-tie.ly [new file with mode: 0644]
lily/note-performer.cc

diff --git a/input/regression/midi-grace-after-tie.ly b/input/regression/midi-grace-after-tie.ly
new file mode 100644 (file)
index 0000000..6aca01b
--- /dev/null
@@ -0,0 +1,17 @@
+\header {
+
+  texidoc = "Tied notes sound as one note in MIDI.  Grace notes
+  following a tied note shorten the resulting single note in MIDI."
+
+  % https://code.google.com/p/lilypond/issues/detail?id=3091
+}
+\version "2.16.0"
+\score {
+  \relative c' {
+    % This first b~ tie should be honoured in the MIDI output:
+    a2. b4~
+    % i.e. this b8 must not be sounded:
+    | b8 \grace c16 d4
+  }
+  \midi { }
+}
index 01086620ef5e3f6ea23ce554926c52e7eb8ee338..b0a81195c7185b953fa97c645d83d18eaebd4fc9 100644 (file)
@@ -86,15 +86,18 @@ Note_performer::process_music ()
           notes_.push_back (p);
 
           /*
-            shorten previous note.
+            Shorten previous note. If it was part of a tie, shorten
+            the first note in the tie.
            */
           if (now_mom ().grace_part_)
             {
               if (last_start_.grace_part_ == Rational (0))
                 {
                   for (vsize i = 0; i < last_notes_.size (); i++)
-                    last_notes_[i]->length_mom_ += Moment (0,
-                                                           now_mom ().grace_part_);
+                    {
+                      Audio_note *tie_head = last_notes_[i]->tie_head ();
+                      tie_head->length_mom_ += Moment (0, now_mom ().grace_part_);
+                    }
                 }
             }
         }