]> git.donarmstrong.com Git - lilypond.git/commitdiff
extract new Audio_note::tie_head() method
authorAdam Spiers <lilypond@adamspiers.org>
Sun, 13 Jan 2013 17:12:16 +0000 (17:12 +0000)
committerAdam Spiers <lilypond@adamspiers.org>
Sun, 27 Jan 2013 14:25:12 +0000 (14:25 +0000)
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

lily/audio-item.cc
lily/include/audio-item.hh

index 65ca70004d23149ac81aed6a7e46bdd589bb9460..895439e78401bbbb118a0c227eaaa592e457855a 100644 (file)
@@ -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
 {
index 1b858cd8c4d7261321e064103cd967a678bdccc2..5e5d499fbd433d6d1876a1ef98468e2d91b6574e 100644 (file)
@@ -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_;