]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/beaming-pattern.cc
Grand fixcc.py run on all .hh .cc files.
[lilypond.git] / lily / beaming-pattern.cc
index b823d2ecdaafb7e1c84d8a1c291601c993fb80cd..a0fa25e7f7a782b2aeba4fa045492ec6c89cfb9a 100644 (file)
@@ -82,17 +82,17 @@ Beaming_pattern::flag_direction (Beaming_options const &options, vsize i) const
     return CENTER;
 
   int count = infos_[i].count (LEFT); // Both directions should still be the same
-  int left_count = infos_[i-1].count (RIGHT);
-  int right_count = infos_[i+1].count (LEFT);
+  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;
+        return RIGHT;
+      else if (infos_[i + 1].rhythmic_importance_ < 0)
+        return LEFT;
     }
 
   if (count <= left_count && count <= right_count)
@@ -106,13 +106,13 @@ Beaming_pattern::flag_direction (Beaming_options const &options, vsize i) const
     return LEFT;
 
   // If all else fails, point the beamlet away from the important moment.
-  return (infos_[i].rhythmic_importance_ <= infos_[i+1].rhythmic_importance_) ? RIGHT : LEFT;
+  return (infos_[i].rhythmic_importance_ <= infos_[i + 1].rhythmic_importance_) ? RIGHT : LEFT;
 }
 
 void
 Beaming_pattern::de_grace ()
 {
-  for (vsize i = 0; i < infos_.size (); i ++)
+  for (vsize i = 0; i < infos_.size (); i++)
     {
       infos_[i].de_grace ();
     }
@@ -139,15 +139,15 @@ Beaming_pattern::beamify (Beaming_options const &options)
     {
       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 && options.subdivide_beams_)
-           ? 1 : min (infos_[i].count (non_flag_dir),
-                      infos_[i+non_flag_dir].count (-non_flag_dir));
-
-         infos_[i].beam_count_drul_[non_flag_dir] = count;
-       }
+        {
+          int importance = (non_flag_dir == LEFT)
+                           ? infos_[i].rhythmic_importance_ : infos_[i + 1].rhythmic_importance_;
+          int count = (importance < 0 && options.subdivide_beams_)
+                      ? 1 : min (infos_[i].count (non_flag_dir),
+                                 infos_[i + non_flag_dir].count (-non_flag_dir));
+
+          infos_[i].beam_count_drul_[non_flag_dir] = count;
+        }
     }
 }
 
@@ -164,44 +164,43 @@ Beaming_pattern::find_rhythmic_importance (Beaming_options const &options)
       // If a beat grouping is not specified, default to 2 beats per group.
       int count = 2;
       if (scm_is_pair (grouping))
-       {
-         count = scm_to_int (scm_car (grouping));
-         grouping = scm_cdr (grouping);
-       }
+        {
+          count = scm_to_int (scm_car (grouping));
+          grouping = scm_cdr (grouping);
+        }
 
       // Mark the start of this beat group
       if (infos_[i].start_moment_ == measure_pos)
-       infos_[i].rhythmic_importance_ = -2;
+        infos_[i].rhythmic_importance_ = -2;
 
       // Mark the start of each unit up to the end of this beat group.
       for (int unit = 1; unit <= count; unit++)
-       {
-         Moment next_measure_pos = measure_pos + options.base_moment_;
-
-         while (i < infos_.size () && infos_[i].start_moment_ < next_measure_pos)
-           {
-             Moment dt = infos_[i].start_moment_ - measure_pos;
-
-             // The rhythmic importance of a stem between beats depends on its fraction
-             // of a beat: those stems with a lower denominator are deemed more
-             // important.
-             // FIXME: This is not the right way to do things for tuplets. For example,
-             // in an 8th-note triplet with a quarter-note beat, 1/3 of a beat should be
-             // more important than 1/2.
-             if (infos_[i].rhythmic_importance_ >= 0)
-               infos_[i].rhythmic_importance_ = (int) (dt / options.base_moment_).den ();
-
-             i++;
-           }
-
-         measure_pos = next_measure_pos;
-         if (i < infos_.size () && infos_[i].start_moment_ == measure_pos)
-           infos_[i].rhythmic_importance_ = -1;
-       }
+        {
+          Moment next_measure_pos = measure_pos + options.base_moment_;
+
+          while (i < infos_.size () && infos_[i].start_moment_ < next_measure_pos)
+            {
+              Moment dt = infos_[i].start_moment_ - measure_pos;
+
+              // The rhythmic importance of a stem between beats depends on its fraction
+              // of a beat: those stems with a lower denominator are deemed more
+              // important.
+              // FIXME: This is not the right way to do things for tuplets. For example,
+              // in an 8th-note triplet with a quarter-note beat, 1/3 of a beat should be
+              // more important than 1/2.
+              if (infos_[i].rhythmic_importance_ >= 0)
+                infos_[i].rhythmic_importance_ = (int) (dt / options.base_moment_).den ();
+
+              i++;
+            }
+
+          measure_pos = next_measure_pos;
+          if (i < infos_.size () && infos_[i].start_moment_ == measure_pos)
+            infos_[i].rhythmic_importance_ = -1;
+        }
     }
 }
 
-
 /*
   Invisible stems should be treated as though they have the same number of
   beams as their least-beamed neighbour. Here we go through the stems and
@@ -213,21 +212,20 @@ 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));
-       infos_[i].beam_count_drul_[LEFT] = b;
-       infos_[i].beam_count_drul_[RIGHT] = b;
+        int b = min (infos_[i].count (LEFT), infos_[i - 1].count (LEFT));
+        infos_[i].beam_count_drul_[LEFT] = b;
+        infos_[i].beam_count_drul_[RIGHT] = b;
       }
 
   for (vsize i = infos_.size (); i--;)
     if (infos_[i].invisible_)
       {
-       int b = min (infos_[i].count (LEFT), infos_[i+1].count (LEFT));
-       infos_[i].beam_count_drul_[LEFT] = b;
-       infos_[i].beam_count_drul_[RIGHT] = b;
+        int b = min (infos_[i].count (LEFT), infos_[i + 1].count (LEFT));
+        infos_[i].beam_count_drul_[LEFT] = b;
+        infos_[i].beam_count_drul_[RIGHT] = b;
       }
 }
 
-
 void
 Beaming_pattern::add_stem (Moment m, int b, bool invisible)
 {
@@ -254,10 +252,10 @@ Moment
 Beaming_pattern::end_moment (int i) const
 {
   Duration *dur = new Duration (2 + max (beamlet_count (i, LEFT),
-                                        beamlet_count (i, RIGHT)),
-                               0);
+                                         beamlet_count (i, RIGHT)),
+                                0);
 
-  return infos_.at (i).start_moment_ + dur->get_length();
+  return infos_.at (i).start_moment_ + dur->get_length ();
 }
 
 bool
@@ -273,18 +271,18 @@ Beaming_pattern::invisibility (int i) const
 Beaming_pattern *
 Beaming_pattern::split_pattern (int i)
 {
-  Beaming_pattern* new_pattern=0;
+  Beaming_pattern *new_pattern = 0;
   int count;
 
   new_pattern = new Beaming_pattern ();
-  for (vsize j=i+1; j<infos_.size (); j++)
+  for (vsize j = i + 1; j < infos_.size (); j++)
     {
-      count = max(beamlet_count (j, LEFT), beamlet_count(j, RIGHT));
+      count = max (beamlet_count (j, LEFT), beamlet_count (j, RIGHT));
       new_pattern->add_stem (start_moment (j),
                              count,
                              invisibility (j));
     }
-  for (vsize j=i+1; j<infos_.size (); )
+  for (vsize j = i + 1; j < infos_.size ();)
     infos_.pop_back ();
   return (new_pattern);
 }