+/*
+ Finds the appropriate direction for the flags at the given index that
+ hang below the neighbouring flags. If
+ the stem has no more flags than either of its neighbours, this returns
+ CENTER.
+*/
+Direction
+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.
+ if (i == 0 || i == infos_.size () - 1)
+ 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);
+
+ // 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_)