From: Adam Spiers Date: Tue, 29 Jan 2013 22:53:48 +0000 (+0000) Subject: Merge branch 'tie-grace-fix' into staging X-Git-Tag: release/2.17.12-1~20 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=4c027ac238950c80e80f2a18632ca1c3a795eb3a;hp=d0ab50f4a92f410b22f015b4f05104c4f23bc3c7;p=lilypond.git Merge branch 'tie-grace-fix' into staging --- diff --git a/input/regression/midi-grace-after-tie.ly b/input/regression/midi-grace-after-tie.ly new file mode 100644 index 0000000000..6aca01bc1e --- /dev/null +++ b/input/regression/midi-grace-after-tie.ly @@ -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 { } +} diff --git a/lily/audio-item.cc b/lily/audio-item.cc index 201e8fd98e..895439e784 100644 --- a/lily/audio-item.cc +++ b/lily/audio-item.cc @@ -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 = "#to_string(); + } + if (tie_event_) + { + s += " tie_event"; + } + s += ">"; + return s; +} + Audio_key::Audio_key (int acc, bool major) { accidentals_ = acc; diff --git a/lily/include/audio-item.hh b/lily/include/audio-item.hh index 45dcc7b799..5e5d499fbd 100644 --- a/lily/include/audio-item.hh +++ b/lily/include/audio-item.hh @@ -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_; diff --git a/lily/midi-walker.cc b/lily/midi-walker.cc index 6d0b1290a3..b97630b0d1 100644 --- a/lily/midi-walker.cc +++ b/lily/midi-walker.cc @@ -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)) { diff --git a/lily/note-performer.cc b/lily/note-performer.cc index 01086620ef..b0a81195c7 100644 --- a/lily/note-performer.cc +++ b/lily/note-performer.cc @@ -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_); + } } } }