From 9aa01bc8f2ac41e39915716f055576d1f0668d2c Mon Sep 17 00:00:00 2001 From: Han-Wen Nienhuys Date: Mon, 22 Jan 2007 18:33:28 +0100 Subject: [PATCH] Fix #251 Pass Beaming_options to Beaming_pattern::beamify () iso. Context pointer. Conflicts: lily/auto-beam-engraver.cc lily/beam-engraver.cc --- lily/auto-beam-engraver.cc | 16 ++++++++++----- lily/beam-engraver.cc | 18 ++++++++++++----- lily/beaming-pattern.cc | 35 ++++++++++++++++++++++----------- lily/include/beaming-pattern.hh | 13 +++++++++++- 4 files changed, 59 insertions(+), 23 deletions(-) diff --git a/lily/auto-beam-engraver.cc b/lily/auto-beam-engraver.cc index 48766e7e52..b6fe2081ec 100644 --- a/lily/auto-beam-engraver.cc +++ b/lily/auto-beam-engraver.cc @@ -68,15 +68,17 @@ private: Moment beam_start_moment_; Moment beam_start_location_; - bool subdivide_beams_; - Moment beat_length_; - // We act as if beam were created, and start a grouping anyway. Beaming_pattern *grouping_; SCM beam_settings_; Beaming_pattern *finished_grouping_; + + Beaming_options beaming_options_; + Beaming_options finished_beaming_options_; + + void check_bar_property (); }; @@ -208,6 +210,7 @@ Auto_beam_engraver::begin_beam () stems_ = new vector; grouping_ = new Beaming_pattern (); + beaming_options_.from_context (context ()); beam_settings_ = updated_grob_properties (context (), ly_symbol2scm ("Beam")); beam_start_moment_ = now_mom (); @@ -239,7 +242,10 @@ Auto_beam_engraver::end_beam () { finished_beam_ = create_beam (); if (finished_beam_) - finished_grouping_ = grouping_; + { + finished_grouping_ = grouping_; + finished_beaming_options_ = beaming_options_; + } delete stems_; stems_ = 0; grouping_ = 0; @@ -257,7 +263,7 @@ Auto_beam_engraver::typeset_beam () if (!finished_beam_->get_bound (RIGHT)) finished_beam_->set_bound (RIGHT, finished_beam_->get_bound (LEFT)); - finished_grouping_->beamify (context ()); + finished_grouping_->beamify (finished_beaming_options_); Beam::set_beaming (finished_beam_, finished_grouping_); finished_beam_ = 0; diff --git a/lily/beam-engraver.cc b/lily/beam-engraver.cc index 2e5bf81a20..bcf084b575 100644 --- a/lily/beam-engraver.cc +++ b/lily/beam-engraver.cc @@ -46,9 +46,9 @@ protected: /// moment (global time) where beam started. Moment beam_start_mom_; - bool subdivide_beams_; - Moment beat_length_; - + Beaming_options beaming_options_; + Beaming_options finished_beaming_options_; + void typeset_beam (); void set_melisma (bool); @@ -138,9 +138,15 @@ Beam_engraver::process_music () beam_start_location_ = mp; beam_start_mom_ = now_mom (); + beaming_options_.from_context (context ()); beam_info_ = new Beaming_pattern; /* urg, must copy to Auto_beam_engraver too */ } + typeset_beam (); + if (now_stop_ev_ && beam_) + { + announce_end_grob (beam_, now_stop_ev_->self_scm ()); + } } void @@ -150,8 +156,8 @@ Beam_engraver::typeset_beam () { if (!finished_beam_->get_bound (RIGHT)) finished_beam_->set_bound (RIGHT, finished_beam_->get_bound (LEFT)); - - finished_beam_info_->beamify (context ()); + + finished_beam_info_->beamify (finished_beaming_options_); Beam::set_beaming (finished_beam_, finished_beam_info_); delete finished_beam_info_; @@ -181,6 +187,8 @@ Beam_engraver::stop_translation_timestep () finished_beam_info_ = beam_info_; now_stop_ev_ = 0; + finished_beaming_options_ = beaming_options_; + beam_ = 0; beam_info_ = 0; typeset_beam (); diff --git a/lily/beaming-pattern.cc b/lily/beaming-pattern.cc index 7ffe2d07b2..0f3b8872b2 100644 --- a/lily/beaming-pattern.cc +++ b/lily/beaming-pattern.cc @@ -117,28 +117,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; @@ -151,9 +147,9 @@ 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; @@ -167,7 +163,7 @@ Beaming_pattern::beamify (Context *context) if (j < group_starts.size ()) infos_[i].group_start_ = group_starts[j]; - infos_[i].beat_length_ = beat_length; + infos_[i].beat_length_ = options.beat_length_; while (k + 1 < beat_starts.size() && beat_starts[k+1] <= infos_[i].start_moment_) k++; @@ -176,7 +172,7 @@ Beaming_pattern::beamify (Context *context) infos_[i].beat_start_ = beat_starts[k]; } - beamify (subdivide_beams); + beamify (options.subdivide_beams_); } @@ -238,3 +234,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; +} diff --git a/lily/include/beaming-pattern.hh b/lily/include/beaming-pattern.hh index 5e0c7c30ec..0c31fc29f4 100644 --- a/lily/include/beaming-pattern.hh +++ b/lily/include/beaming-pattern.hh @@ -13,6 +13,17 @@ #include "moment.hh" #include "lily-proto.hh" +struct Beaming_options +{ + SCM grouping_; + bool subdivide_beams_; + Moment beat_length_; + Moment measure_length_; + + Beaming_options (); + void from_context (Context*); +}; + struct Beam_rhythmic_element { Moment start_moment_; @@ -38,7 +49,7 @@ class Beaming_pattern public: Beaming_pattern (); - void beamify (Context*); + void beamify (Beaming_options const&); void de_grace (); void add_stem (Moment d, int beams); int beamlet_count (int idx, Direction d) const; -- 2.39.5