From: Han-Wen Nienhuys Date: Mon, 22 Jan 2007 17:12:16 +0000 (+0100) Subject: Fix #251 X-Git-Tag: release/2.11.13-1~5 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=08445b3682bc8560d0c8a861415f6f6fd093e30d;p=lilypond.git Fix #251 Pass Beaming_options to Beaming_pattern::beamify () iso. Context pointer. --- diff --git a/input/regression/auto-beam-beaming-override.ly b/input/regression/auto-beam-beaming-override.ly new file mode 100644 index 0000000000..2eb529a05f --- /dev/null +++ b/input/regression/auto-beam-beaming-override.ly @@ -0,0 +1,21 @@ + +\header { + + + texidoc = "Autobeamer remembers @code{subdivideBeams} and other +beaming pattern related functions at the start of an autobeam." + +} + + +\version "2.11.12" +\paper { ragged-right = ##t } +{ + \time 2/4 + b16 b b b + b16 b b b + \set subdivideBeams = ##t + \set Score.beatLength = #(ly:make-moment 1 8) + b16 b b b + b16 b b b +} diff --git a/lily/auto-beam-engraver.cc b/lily/auto-beam-engraver.cc index 4ff8d9d2b7..d2cef6ae16 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 (); }; @@ -207,6 +209,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 (); @@ -242,6 +245,7 @@ Auto_beam_engraver::end_beam () { announce_end_grob (finished_beam_, SCM_EOL); finished_grouping_ = grouping_; + finished_beaming_options_ = beaming_options_; } delete stems_; stems_ = 0; @@ -260,7 +264,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 288a474941..51569b0e27 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); @@ -135,13 +135,17 @@ 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 (stop_ev_ && beam_) - announce_end_grob (beam_, stop_ev_->self_scm ()); + { + announce_end_grob (beam_, stop_ev_->self_scm ()); + + } } void @@ -151,8 +155,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_; @@ -179,7 +183,8 @@ Beam_engraver::stop_translation_timestep () { finished_beam_ = beam_; finished_beam_info_ = beam_info_; - + finished_beaming_options_ = beaming_options_; + stop_ev_ = 0; beam_ = 0; beam_info_ = 0; diff --git a/lily/beaming-pattern.cc b/lily/beaming-pattern.cc index 87cfaf73dc..ba5b8a4a72 100644 --- a/lily/beaming-pattern.cc +++ b/lily/beaming-pattern.cc @@ -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,9 +146,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; @@ -166,7 +162,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++; @@ -175,7 +171,7 @@ Beaming_pattern::beamify (Context *context) infos_[i].beat_start_ = beat_starts[k]; } - beamify (subdivide_beams); + beamify (options.subdivide_beams_); } @@ -237,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; +} diff --git a/lily/include/beaming-pattern.hh b/lily/include/beaming-pattern.hh index 134c4488d5..4a9eae6198 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;