X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fbeaming-pattern.cc;h=b823d2ecdaafb7e1c84d8a1c291601c993fb80cd;hb=e90f0536f9be39ada0bef0aeb0d275dec3b2fb5b;hp=75dfc5a8c000954fa70d7e9f97192a0f922cde62;hpb=0e5d83a9ceb4a143f83d22406d7eb816314ff9f7;p=lilypond.git diff --git a/lily/beaming-pattern.cc b/lily/beaming-pattern.cc index 75dfc5a8c0..b823d2ecda 100644 --- a/lily/beaming-pattern.cc +++ b/lily/beaming-pattern.cc @@ -1,20 +1,24 @@ /* - beaming-info.cc -- implement Beam_rhythmic_element, Beaming_pattern + This file is part of LilyPond, the GNU music typesetter. - A Beaming_pattern object takes a set of stems at given moments and calculates - the pattern of their beam. That is, it works out, for each stem, how many - beams should be connected to the right and left sides of that stem. In - calculating this, Beaming_pattern takes into account - - the rhythmic position of the stems - - the options that are defined in Beaming_options + Copyright (C) 1999--2011 Han-Wen Nienhuys - source file of the GNU LilyPond music typesetter + LilyPond is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. - (c) 1999--2009 Han-Wen Nienhuys + LilyPond is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with LilyPond. If not, see . */ -#include "beaming-pattern.hh" #include "context.hh" +#include "beaming-pattern.hh" /* Represents a stem belonging to a beam. Sometimes (for example, if the stem @@ -52,7 +56,7 @@ Beam_rhythmic_element::de_grace () { if (start_moment_.grace_part_) { - start_moment_.main_part_ = start_moment_.grace_part_; + start_moment_.main_part_ = start_moment_.grace_part_; start_moment_.grace_part_ = 0; } } @@ -150,7 +154,7 @@ Beaming_pattern::beamify (Beaming_options const &options) void Beaming_pattern::find_rhythmic_importance (Beaming_options const &options) { - Moment measure_pos (0); + Moment measure_pos (0); SCM grouping = options.grouping_; vsize i = 0; @@ -169,10 +173,10 @@ Beaming_pattern::find_rhythmic_importance (Beaming_options const &options) if (infos_[i].start_moment_ == measure_pos) infos_[i].rhythmic_importance_ = -2; - // Mark the start of each beat up to the end of this beat group. - for (int beat = 1; beat <= count; beat++) + // 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.beat_length_; + Moment next_measure_pos = measure_pos + options.base_moment_; while (i < infos_.size () && infos_[i].start_moment_ < next_measure_pos) { @@ -185,7 +189,7 @@ Beaming_pattern::find_rhythmic_importance (Beaming_options const &options) // 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_ = (dt / options.beat_length_).den (); + infos_[i].rhythmic_importance_ = (int) (dt / options.base_moment_).den (); i++; } @@ -240,13 +244,60 @@ Beaming_pattern::beamlet_count (int i, Direction d) const return infos_.at (i).beam_count_drul_[d]; } +Moment +Beaming_pattern::start_moment (int i) const +{ + return infos_.at (i).start_moment_; +} + +Moment +Beaming_pattern::end_moment (int i) const +{ + Duration *dur = new Duration (2 + max (beamlet_count (i, LEFT), + beamlet_count (i, RIGHT)), + 0); + + return infos_.at (i).start_moment_ + dur->get_length(); +} + +bool +Beaming_pattern::invisibility (int i) const +{ + return infos_.at (i).invisible_; +} + +/* + Split a beamin pattern at index i and return a new + Beaming_pattern containing the removed elements +*/ +Beaming_pattern * +Beaming_pattern::split_pattern (int i) +{ + Beaming_pattern* new_pattern=0; + int count; + + new_pattern = new Beaming_pattern (); + for (vsize j=i+1; jadd_stem (start_moment (j), + count, + invisibility (j)); + } + for (vsize j=i+1; jget_property ("beatGrouping"); + grouping_ = context->get_property ("beatStructure"); 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)); + base_moment_ = robust_scm2moment (context->get_property ("baseMoment"), + Moment (1, 4)); + measure_length_ = robust_scm2moment (context->get_property ("measureLength"), + Moment (4, 4)); } Beaming_options::Beaming_options ()