]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/beaming-pattern.cc
trim outdated comment.
[lilypond.git] / lily / beaming-pattern.cc
index 87ff00dc63cb1d5b7cc5732201bac10f6a664d8c..542ce8e455c61f6191a48c7a4d040948abd61285 100644 (file)
@@ -3,7 +3,7 @@
 
   source file of the GNU LilyPond music typesetter
 
-  (c) 1999--2006 Han-Wen Nienhuys <hanwen@xs4all.nl>
+  (c) 1999--2007 Han-Wen Nienhuys <hanwen@xs4all.nl>
 */
 
 #include "beaming-pattern.hh"
@@ -25,6 +25,16 @@ Beam_rhythmic_element::Beam_rhythmic_element (Moment m, int i)
 }
 
 
+void
+Beam_rhythmic_element::de_grace ()
+{
+  if (start_moment_.grace_part_)
+    {
+      start_moment_.main_part_ = start_moment_.grace_part_; 
+      start_moment_.grace_part_ = 0;
+    }
+}
+
 int
 count_factor_twos (int x)
 {
@@ -96,11 +106,23 @@ Beaming_pattern::beam_extend_count (Direction d) const
   return min (thisbeam.beam_count_drul_[-d], next.beam_count_drul_[d]);
 }
 
+void
+Beaming_pattern::de_grace ()
+{
+  for (vsize i = 0; i < infos_.size (); i ++)
+    {
+      infos_[i].de_grace ();
+    }
+}
+
 void
 Beaming_pattern::beamify (Context *context)
 {
   if (infos_.size () <= 1)
     return;
+
+  if (infos_[0].start_moment_.grace_part_)
+    de_grace ();
   
   bool subdivide_beams = to_boolean (context->get_property ("subdivideBeams"));
   Moment beat_length = robust_scm2moment (context->get_property ("beatLength"), Moment (1, 4));
@@ -137,13 +159,13 @@ Beaming_pattern::beamify (Context *context)
   vsize k = 0;
   for (vsize i = 0; i  < infos_.size(); i++)
     {
-      while (j < group_starts.size() - 1
+      while (j + 1 < group_starts.size()
             && group_starts[j+1] <= infos_[i].start_moment_)
        j++;
 
       infos_[i].group_start_ = group_starts[j];
       infos_[i].beat_length_ = beat_length;  
-      while (k < beat_starts.size() - 1
+      while (k + 1 < beat_starts.size() 
             && beat_starts[k+1] <= infos_[i].start_moment_)
        k++;