]> git.donarmstrong.com Git - lilypond.git/commitdiff
Merge branch 'tie-grace-fix' into staging
authorAdam Spiers <lilypond@adamspiers.org>
Tue, 29 Jan 2013 22:53:48 +0000 (22:53 +0000)
committerAdam Spiers <lilypond@adamspiers.org>
Tue, 29 Jan 2013 22:53:48 +0000 (22:53 +0000)
input/regression/midi-grace-after-tie.ly [new file with mode: 0644]
lily/audio-item.cc
lily/include/audio-item.hh
lily/midi-walker.cc
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 201e8fd98e7cf4939c1de6b4a7e8ca64efc540d6..895439e78401bbbb118a0c227eaaa592e457855a 100644 (file)
@@ -58,15 +58,41 @@ void
 Audio_note::tie_to (Audio_note *t, Moment skip)
 {
   tied_ = t;
-  Audio_note *first = t;
-  while (first->tied_)
-    first = first->tied_;
+  Audio_note *first = tie_head();
   // Add the skip to the tied note and the length of the appended note
   // to the full duration of the tie...
   first->length_mom_ += skip + length_mom_;
   length_mom_ = 0;
 }
 
+Audio_note *
+Audio_note::tie_head ()
+{
+  Audio_note *first = this;
+  while (first->tied_)
+    first = first->tied_;
+  return first;
+}
+
+string
+Audio_note::to_string () const
+{
+  string s = "#<Audio_note pitch ";
+  s += pitch_.to_string();
+  s += " len ";
+  s += length_mom_.to_string();
+  if (tied_)
+    {
+      s += " tied to " + tied_->to_string();
+    }
+  if (tie_event_)
+    {
+      s += " tie_event";
+    }
+  s += ">";
+  return s;
+}
+
 Audio_key::Audio_key (int acc, bool major)
 {
   accidentals_ = acc;
index 45dcc7b7991f6b486fbd1f8c284cafa0f56bbf61..5e5d499fbd433d6d1876a1ef98468e2d91b6574e 100644 (file)
@@ -86,6 +86,8 @@ public:
 
   // with tieWaitForNote, there might be a skip between the tied notes!
   void tie_to (Audio_note *, Moment skip = 0);
+  Audio_note *tie_head ();
+  virtual string to_string () const;
 
   Pitch pitch_;
   Moment length_mom_;
index 6d0b1290a38491f3f8c47f21d7063ab88f47b3a1..b97630b0d147ed8ebc05d63c111b8928c3667cad 100644 (file)
@@ -178,7 +178,8 @@ void
 Midi_walker::process ()
 {
   Audio_item *audio = items_[index_];
-  do_stop_notes (audio->audio_column_->ticks ());
+  Audio_column *col = audio->get_column ();
+  do_stop_notes (col->ticks ());
 
   if (Midi_item *midi = get_midi (audio))
     {
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_);
+                    }
                 }
             }
         }