+ if ((next_beat_pos > next_group_pos)
+ || (infos_[i].start_moment_ > next_beat_pos))
+ // Find the new group ending point
+ find_location (grouping, options.base_moment_, infos_[i].start_moment_,
+ infos_[i].factor_, &group_pos, &next_group_pos, &next_beat_pos);
+ // Mark the start of this beat group
+ if (infos_[i].start_moment_ == group_pos)
+ infos_[i].rhythmic_importance_ = -2;
+ // Work through the end of the beat group or the end of the beam
+ while (i < infos_.size () && infos_[i].start_moment_ < next_group_pos)
+ {
+ // Set the tuplet start as necessary
+ update_tuplet (infos_[i].start_moment_, infos_[i].factor_, &tuplet_start_moment);
+ Moment dt = infos_[i].start_moment_ - group_pos;
+ Rational tuplet = infos_[i].factor_;
+ Moment tuplet_moment (tuplet);
+ Moment tuplet_dt = infos_[i].start_moment_ - tuplet_start_moment;
+ tuplet_number = tuplet.den ();
+ // set the beat end and increment the next beat
+ if (infos_[i].start_moment_ == next_beat_pos)
+ {
+ infos_[i].rhythmic_importance_ = -1;
+ next_beat_pos += options.base_moment_;
+ }
+ // 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. For tuplets, we need to make sure that we use
+ // the fraction of the tuplet, instead of the fraction of
+ // a beat.
+ Moment ratio = (tuplet_number == 1)
+ ? dt / options.base_moment_
+ : tuplet_dt / Moment (1, 8) / tuplet_moment;
+ if (infos_[i].rhythmic_importance_ >= 0)
+ infos_[i].rhythmic_importance_ = (int) ratio.den ();
+
+ i++;
+ }
+
+ if (i < infos_.size () && infos_[i].start_moment_ == next_beat_pos)
+ {
+ if (tuplet_number == 1)
+ infos_[i].rhythmic_importance_ = -1;
+ next_beat_pos += options.base_moment_;
+ if (infos_[i].start_moment_ == next_group_pos)
+ infos_[i].rhythmic_importance_ = -2;
+ }