]> git.donarmstrong.com Git - lilypond.git/commitdiff
Fix #251
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Mon, 22 Jan 2007 17:33:28 +0000 (18:33 +0100)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Mon, 22 Jan 2007 17:33:28 +0000 (18:33 +0100)
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
lily/beam-engraver.cc
lily/beaming-pattern.cc
lily/include/beaming-pattern.hh

index 48766e7e5245573324613f59e929431db0a4f31e..b6fe2081ecff4ae81b2046fde9327db28125c2ff 100644 (file)
@@ -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<Item*>;
   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;
 
index 2e5bf81a2084fa91064535ceb1ec3fdd535d72ad..bcf084b57531d0cdd77b49549eb6f2d350c18653 100644 (file)
@@ -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 ();
index 7ffe2d07b264cebbd0bf2e1640b6084c40dbe145..0f3b8872b24dae9260568e6558412fafc492fbc0 100644 (file)
@@ -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<Moment> group_starts;
   vector<Moment> 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;
+}
index 5e0c7c30ecd98004b776fc7fc40603772dae6d67..0c31fc29f4cd5c85b68731f20625b0dc3f286c60 100644 (file)
 #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;