]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/beaming-pattern.cc
input/regression/bookparts.ly fails at PDF conversion stage
[lilypond.git] / lily / beaming-pattern.cc
index 4415debf98677e04888299dde09e760479b57245..53a8c354ea162d5e28d792f5e18bb0192b61e944 100644 (file)
@@ -1,7 +1,7 @@
 /*
   This file is part of LilyPond, the GNU music typesetter.
 
-  Copyright (C) 1999--2014 Han-Wen Nienhuys <hanwen@xs4all.nl>
+  Copyright (C) 1999--2015 Han-Wen Nienhuys <hanwen@xs4all.nl>
 
   LilyPond is free software: you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
@@ -19,6 +19,9 @@
 
 #include "context.hh"
 #include "beaming-pattern.hh"
+#include "misc.hh"
+
+using std::vector;
 
 /*
   Represents a stem belonging to a beam. Sometimes (for example, if the stem
@@ -131,6 +134,8 @@ Beaming_pattern::beamify (Beaming_options const &options)
   if (infos_.size () <= 1)
     return;
 
+  int subdivide_beam_count = intlog2(options.base_moment_.main_part_.den())-2;
+
   unbeam_invisible_stems ();
 
   if (infos_[0].start_moment_.grace_part_)
@@ -162,12 +167,13 @@ Beaming_pattern::beamify (Beaming_options const &options)
   for (int i = 0; i < 2; i++)
     for (vsize i = 1; i < infos_.size () - 1; i++)
       {
-        Direction non_flag_dir = other_dir (flag_directions[i]);
+        Direction non_flag_dir = -flag_directions[i];
         if (non_flag_dir)
           {
             int importance = infos_[i + 1].rhythmic_importance_;
-            int count = (importance < 0 && options.subdivide_beams_)
-                        ? 1 : min (min (infos_[i].count (non_flag_dir),
+            int count = (importance < 0 && options.subdivide_beams_) 
+                        ? subdivide_beam_count
+                        : std::min (std::min (infos_[i].count (non_flag_dir),
                                         infos_[i + non_flag_dir].count (-non_flag_dir)),
                                    infos_[i - non_flag_dir].count (non_flag_dir));
 
@@ -311,7 +317,7 @@ Beaming_pattern::unbeam_invisible_stems ()
   for (vsize i = 1; i < infos_.size (); i++)
     if (infos_[i].invisible_)
       {
-        int b = min (infos_[i].count (LEFT), infos_[i - 1].count (LEFT));
+        int b = std::min (infos_[i].count (LEFT), infos_[i - 1].count (LEFT));
         infos_[i].beam_count_drul_[LEFT] = b;
         infos_[i].beam_count_drul_[RIGHT] = b;
       }
@@ -320,7 +326,7 @@ Beaming_pattern::unbeam_invisible_stems ()
     for (vsize i = infos_.size () - 1; i--;)
       if (infos_[i].invisible_)
         {
-          int b = min (infos_[i].count (LEFT), infos_[i + 1].count (LEFT));
+          int b = std::min (infos_[i].count (LEFT), infos_[i + 1].count (LEFT));
           infos_[i].beam_count_drul_[LEFT] = b;
           infos_[i].beam_count_drul_[RIGHT] = b;
         }
@@ -351,7 +357,7 @@ Beaming_pattern::start_moment (int i) const
 Moment
 Beaming_pattern::end_moment (int i) const
 {
-  Duration dur (2 + max (beamlet_count (i, LEFT),
+  Duration dur (2 + std::max (beamlet_count (i, LEFT),
                          beamlet_count (i, RIGHT)),
                 0);
 
@@ -390,7 +396,7 @@ Beaming_pattern::split_pattern (int i)
   new_pattern = new Beaming_pattern ();
   for (vsize j = i + 1; j < infos_.size (); j++)
     {
-      count = max (beamlet_count (j, LEFT), beamlet_count (j, RIGHT));
+      count = std::max (beamlet_count (j, LEFT), beamlet_count (j, RIGHT));
       new_pattern->add_stem (start_moment (j),
                              count,
                              invisibility (j),