From: Adam Spiers <lilypond@adamspiers.org>
Date: Sun, 13 Jan 2013 17:12:16 +0000 (+0000)
Subject: extract new Audio_note::tie_head() method
X-Git-Tag: release/2.17.12-1~20^2~1
X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=d4047469357aa91fc32ef9915995cc3a9bc31d2d;p=lilypond.git

extract new Audio_note::tie_head() method

This makes it easy to retrieve the first note in a tie,
and will be used in the fix for issue #3091.

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

diff --git a/lily/audio-item.cc b/lily/audio-item.cc
index 65ca70004d..895439e784 100644
--- a/lily/audio-item.cc
+++ b/lily/audio-item.cc
@@ -58,15 +58,22 @@ 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
 {
diff --git a/lily/include/audio-item.hh b/lily/include/audio-item.hh
index 1b858cd8c4..5e5d499fbd 100644
--- a/lily/include/audio-item.hh
+++ b/lily/include/audio-item.hh
@@ -86,6 +86,7 @@ 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_;