]> git.donarmstrong.com Git - lilypond.git/commitdiff
Fix #251
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Mon, 22 Jan 2007 17:12:16 +0000 (18:12 +0100)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Mon, 22 Jan 2007 17:12:16 +0000 (18:12 +0100)
Pass Beaming_options to Beaming_pattern::beamify () iso. Context
pointer.

input/regression/auto-beam-beaming-override.ly [new file with mode: 0644]
lily/auto-beam-engraver.cc
lily/beam-engraver.cc
lily/beaming-pattern.cc
lily/include/beaming-pattern.hh

diff --git a/input/regression/auto-beam-beaming-override.ly b/input/regression/auto-beam-beaming-override.ly
new file mode 100644 (file)
index 0000000..2eb529a
--- /dev/null
@@ -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
+}
index 4ff8d9d2b7c88e7632907e0651f02483ac90c55e..d2cef6ae1693ecb2bd9bf8a928958b9978a7fb4a 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 ();
 };
 
@@ -207,6 +209,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 ();
@@ -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;
 
index 288a47494149b9077187d17902b224a791905be3..51569b0e270b6582366f4e3cf0b7bb3412a97d9f 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);
 
@@ -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;
index 87cfaf73dc39d99d39f1ee4ac7cfb6b3d76f589f..ba5b8a4a72dee519ba9e1f254c61523e698cc6f7 100644 (file)
@@ -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<Moment> group_starts;
   vector<Moment> 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;
+}
index 134c4488d5e4a986c0cb3ef317fe2e57d330b19d..4a9eae6198c7eb8ab61b0a8cbea846e6953641e0 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;