]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/beaming-pattern.cc
Imported Upstream version 2.12.3
[lilypond.git] / lily / beaming-pattern.cc
index 1841f67900f468f0bea324712ebb0103887ecd56..251e65bb99461063cbb0ebb74604454d6635d703 100644 (file)
@@ -1,5 +1,5 @@
 /*
-  beaming-info.cc -- implement Beam_rhythmic_element, Beaming_pattern
+  beaming-pattern.cc -- implement Beam_rhythmic_element, Beaming_pattern
 
   A Beaming_pattern object takes a set of stems at given moments and calculates
   the pattern of their beam. That is, it works out, for each stem, how many
@@ -10,7 +10,7 @@
 
   source file of the GNU LilyPond music typesetter
 
-  (c) 1999--2007 Han-Wen Nienhuys <hanwen@xs4all.nl>
+  (c) 1999--2009 Han-Wen Nienhuys <hanwen@xs4all.nl>
 */
 
 #include "beaming-pattern.hh"
@@ -70,7 +70,7 @@ Beam_rhythmic_element::count (Direction d) const
   CENTER.
 */
 Direction
-Beaming_pattern::flag_direction (vsize i) const
+Beaming_pattern::flag_direction (Beaming_options const &options, vsize i) const
 {
   // The extremal stems shouldn't be messed with, so it's appropriate to
   // return CENTER here also.
@@ -81,6 +81,16 @@ Beaming_pattern::flag_direction (vsize i) const
   int left_count = infos_[i-1].count (RIGHT);
   int right_count = infos_[i+1].count (LEFT);
 
+  // If we are told to subdivide beams and we are next to a beat, point the
+  // beamlet away from the beat.
+  if (options.subdivide_beams_)
+    {
+      if (infos_[i].rhythmic_importance_ < 0)
+       return RIGHT;
+      else if (infos_[i+1].rhythmic_importance_ < 0)
+       return LEFT;
+    }
+
   if (count <= left_count && count <= right_count)
     return CENTER;
 
@@ -123,12 +133,12 @@ Beaming_pattern::beamify (Beaming_options const &options)
 
   for (vsize i = 1; i < infos_.size () - 1; i++)
     {
-      Direction non_flag_dir = other_dir (flag_direction (i));
+      Direction non_flag_dir = other_dir (flag_direction (options, i));
       if (non_flag_dir)
        {
          int importance = (non_flag_dir == LEFT)
            ? infos_[i].rhythmic_importance_ : infos_[i+1].rhythmic_importance_;
-         int count = (importance < 0)
+         int count = (importance < 0 && options.subdivide_beams_)
            ? 1 : min (infos_[i].count (non_flag_dir),
                       infos_[i+non_flag_dir].count (-non_flag_dir));
 
@@ -236,7 +246,7 @@ Beaming_options::from_context (Context *context)
   grouping_ = context->get_property ("beatGrouping");
   subdivide_beams_ = to_boolean (context->get_property ("subdivideBeams"));
   beat_length_ = robust_scm2moment (context->get_property ("beatLength"), Moment (1, 4));
-  measure_length_ = robust_scm2moment (context->get_property ("measureLength"), Moment (1, 4));
+  measure_length_ = robust_scm2moment (context->get_property ("measureLength"), Moment (4, 4));
 }
 
 Beaming_options::Beaming_options ()