X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fauto-beam-engraver.cc;h=a98b05f48d953384474d5e5996fb023062b02eb1;hb=cbf152f9dbdadd9af8b4c3bbbba0e5e0ce5b0fec;hp=26aef175432b2c4e05554e7f5b01980b19cb5d87;hpb=c4c0ba811cd526f047de3f4d3c77abcc32a3e076;p=lilypond.git diff --git a/lily/auto-beam-engraver.cc b/lily/auto-beam-engraver.cc index 26aef17543..a98b05f48d 100644 --- a/lily/auto-beam-engraver.cc +++ b/lily/auto-beam-engraver.cc @@ -3,7 +3,7 @@ source file of the GNU LilyPond music typesetter - (c) 1999--2006 Jan Nieuwenhuizen + (c) 1999--2007 Jan Nieuwenhuizen */ #include "bar-line.hh" @@ -27,7 +27,6 @@ class Auto_beam_engraver : public Engraver protected: void stop_translation_timestep (); - void start_translation_timestep (); void process_music (); virtual void finalize (); virtual void derived_mark () const; @@ -68,15 +67,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 (); }; @@ -104,6 +105,16 @@ Auto_beam_engraver::check_bar_property () void Auto_beam_engraver::process_music () { + /* + don't beam over skips + */ + if (stems_) + { + Moment now = now_mom (); + if (extend_mom_ < now) + end_beam (); + } + if (scm_is_string (get_property ("whichBar"))) { consider_end (shortest_mom_); @@ -133,7 +144,7 @@ IMPLEMENT_TRANSLATOR_LISTENER (Auto_beam_engraver, beam_forbid); void Auto_beam_engraver::listen_beam_forbid (Stream_event *ev) { - forbid_ = ev; + ASSIGN_EVENT_ONCE (forbid_, ev); } bool @@ -183,11 +194,10 @@ Auto_beam_engraver::create_beam () return 0; /* - Can't use make_spanner_from_properties() because we have to use + Can't use make_spanner_from_properties () because we have to use beam_settings_. */ - Spanner *beam = new Spanner (beam_settings_, - context ()->get_grob_key ("Beam")); + Spanner *beam = new Spanner (beam_settings_); for (vsize i = 0; i < stems_->size (); i++) Beam::add_stem (beam, (*stems_)[i]); @@ -208,6 +218,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 (); @@ -238,8 +249,13 @@ Auto_beam_engraver::end_beam () else { finished_beam_ = create_beam (); + if (finished_beam_) - finished_grouping_ = grouping_; + { + announce_end_grob (finished_beam_, SCM_EOL); + finished_grouping_ = grouping_; + finished_beaming_options_ = beaming_options_; + } delete stems_; stems_ = 0; grouping_ = 0; @@ -257,7 +273,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; @@ -266,26 +282,12 @@ Auto_beam_engraver::typeset_beam () } } -void -Auto_beam_engraver::start_translation_timestep () -{ - process_acknowledged_count_ = 0; - /* - don't beam over skips - */ - if (stems_) - { - Moment now = now_mom (); - if (extend_mom_ < now) - end_beam (); - } - forbid_ = 0; -} - void Auto_beam_engraver::stop_translation_timestep () { typeset_beam (); + process_acknowledged_count_ = 0; + forbid_ = 0; } void @@ -386,7 +388,7 @@ Auto_beam_engraver::acknowledge_stem (Grob_info info) durlog - 2); stems_->push_back (stem); last_add_mom_ = now; - extend_mom_ = max (extend_mom_, now) + get_event_length (ev); + extend_mom_ = max (extend_mom_, now) + get_event_length (ev, now); } void @@ -427,6 +429,11 @@ ADD_TRANSLATOR (Auto_beam_engraver, "@ref{Stem_engraver} properties @code{stemLeftBeamCount} and " "@code{stemRightBeamCount}. ", /* create */ "Beam", - /* accept */ "beam-forbid-event", - /* read */ "autoBeaming autoBeamSettings beatLength subdivideBeams", + + /* read */ + "autoBeaming " + "autoBeamSettings " + "beatLength " + "subdivideBeams ", + /* write */ "");