X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fbeaming-pattern.cc;h=ba5b8a4a72dee519ba9e1f254c61523e698cc6f7;hb=9880906860b1ba94a03e1509b2c17a13e9844fa3;hp=092c6b673d39f9509b87d997961796553e82c6fd;hpb=14a88203657dac1d147c1874c3889809ac4f64c0;p=lilypond.git diff --git a/lily/beaming-pattern.cc b/lily/beaming-pattern.cc index 092c6b673d..ba5b8a4a72 100644 --- a/lily/beaming-pattern.cc +++ b/lily/beaming-pattern.cc @@ -3,7 +3,7 @@ source file of the GNU LilyPond music typesetter - (c) 1999--2006 Han-Wen Nienhuys + (c) 1999--2007 Han-Wen Nienhuys */ #include "beaming-pattern.hh" @@ -116,28 +116,24 @@ Beaming_pattern::de_grace () } void -Beaming_pattern::beamify (Context *context) +Beaming_pattern::beamify (Beaming_options const &options) { if (infos_.size () <= 1) return; if (infos_[0].start_moment_.grace_part_) de_grace (); - - bool subdivide_beams = to_boolean (context->get_property ("subdivideBeams")); - Moment beat_length = robust_scm2moment (context->get_property ("beatLength"), Moment (1, 4)); - Moment measure_length = robust_scm2moment (context->get_property ("measureLength"), Moment (1, 4)); if (infos_[0].start_moment_ < Moment (0)) for (vsize i = 0; i < infos_.size(); i++) - infos_[i].start_moment_ += measure_length; + infos_[i].start_moment_ += options.measure_length_; - SCM grouping = context->get_property ("beatGrouping"); Moment measure_pos (0); vector group_starts; vector beat_starts; - + + SCM grouping = options.grouping_; while (measure_pos <= infos_.back().start_moment_) { int count = 2; @@ -150,29 +146,32 @@ Beaming_pattern::beamify (Context *context) group_starts.push_back (measure_pos); for (int i = 0; i < count; i++) { - beat_starts.push_back (measure_pos + beat_length * i); + beat_starts.push_back (measure_pos + options.beat_length_ * i); } - measure_pos += beat_length * count; + measure_pos += options.beat_length_ * count; } vsize j = 0; vsize k = 0; for (vsize i = 0; i < infos_.size(); i++) { - while (j < group_starts.size() - 1 + while (j + 1 < group_starts.size() && group_starts[j+1] <= infos_[i].start_moment_) j++; - infos_[i].group_start_ = group_starts[j]; - infos_[i].beat_length_ = beat_length; - while (k < beat_starts.size() - 1 + if (j < group_starts.size ()) + infos_[i].group_start_ = group_starts[j]; + + infos_[i].beat_length_ = options.beat_length_; + while (k + 1 < beat_starts.size() && beat_starts[k+1] <= infos_[i].start_moment_) k++; - infos_[i].beat_start_ = beat_starts[k]; + if (k < beat_starts.size()) + infos_[i].beat_start_ = beat_starts[k]; } - beamify (subdivide_beams); + beamify (options.subdivide_beams_); } @@ -234,3 +233,18 @@ Beaming_pattern::beamlet_count (int i, Direction d) const { return infos_.at (i).beam_count_drul_[d]; } + +void +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)); +} + +Beaming_options::Beaming_options () +{ + grouping_ = SCM_EOL; + subdivide_beams_ = false; +}