]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/auto-beam-engraver.cc
release: 1.3.59
[lilypond.git] / lily / auto-beam-engraver.cc
index 6e1e805b3d3da27d8d53d27bc274dcaac95b1d91..c906fc6ac1012bb06735b4330036fb5f1d35810a 100644 (file)
@@ -3,7 +3,7 @@
   
   source file of the GNU LilyPond music typesetter
   
-  (c) 1999 Jan Nieuwenhuizen <janneke@gnu.org>
+  (c) 1999--2000 Jan Nieuwenhuizen <janneke@gnu.org>
   
  */
 #include "beaming.hh"
 
 ADD_THIS_TRANSLATOR (Auto_beam_engraver);
 
+
+/*
+  TODO: remove all references to Timing_engraver; should read properties.
+  
+ */
 Auto_beam_engraver::Auto_beam_engraver ()
 {
   stem_l_arr_p_ = 0;
@@ -43,7 +48,7 @@ Auto_beam_engraver::do_try_music (Music*)
 } 
 
 void
-Auto_beam_engraver::do_process_requests ()
+Auto_beam_engraver::do_process_music ()
 {
   consider_end_and_begin (shortest_mom_);
 }
@@ -52,7 +57,7 @@ void
 Auto_beam_engraver::consider_end_and_begin (Moment test_mom)
 {
   if (!timer_l_)
-      return;
+    return;
   
   int num;
   int den;
@@ -105,62 +110,62 @@ Auto_beam_engraver::consider_end_and_begin (Moment test_mom)
   /*
     first guess: end beam at end of beat
   */
-  SCM one (get_property ("beatLength", 0));
+  SCM one (get_property ("beatLength"));
 
   Moment end_mom;
-  if (SMOB_IS_TYPE_B(Moment, one))
-    end_mom = *SMOB_TO_TYPE (Moment, one);
+  if (unsmob_moment (one))
+    end_mom = *unsmob_moment (one);
 
   /*
     second guess: property generic time exception
   */
-  SCM begin = get_property (time_str + "beamAutoBegin", 0);
-  if (SMOB_IS_TYPE_B(Moment, begin))
-    begin_mom = * SMOB_TO_TYPE(Moment, begin);
+  SCM begin = get_property (time_str + "beamAutoBegin");
+  if (unsmob_moment (begin))
+    begin_mom = * unsmob_moment (begin);
 
-  SCM end = get_property (time_str + "beamAutoEnd", 0);
-  if (SMOB_IS_TYPE_B (Moment, end))
-    end_mom = * SMOB_TO_TYPE(Moment,end);
+  SCM end = get_property (time_str + "beamAutoEnd");
+  if (unsmob_moment (end))
+    end_mom = * unsmob_moment (end);
 
   /*
     third guess: property time exception, specific for duration type
   */
   if (type_str.length_i ())
     {
-      SCM end_mult = get_property (time_str + "beamAutoEnd" + type_str, 0);
-      if (SMOB_IS_TYPE_B (Moment, end_mult))
-       end_mom = * SMOB_TO_TYPE (Moment,end_mult);
+      SCM end_mult = get_property ( time_str + "beamAutoEnd" + type_str);
+      if (unsmob_moment (end_mult))
+       end_mom = * unsmob_moment (end_mult);
 
-      SCM begin_mult = get_property (time_str + "beamAutoBegin" + type_str, 0);
-      if (SMOB_IS_TYPE_B (Moment, begin_mult))
-       begin_mom = * SMOB_TO_TYPE (Moment,begin_mult);
+      SCM begin_mult = get_property (time_str + "beamAutoBegin" + type_str);
+      if (unsmob_moment (begin_mult))
+       begin_mom = * unsmob_moment (begin_mult);
     }
 
   /*
     fourth guess [user override]: property plain generic
   */
-  begin = get_property ("beamAutoBegin", 0);
-  if (SMOB_IS_TYPE_B(Moment, begin))
-    begin_mom = * SMOB_TO_TYPE(Moment, begin);
+  begin = get_property ("beamAutoBegin");
+  if (unsmob_moment (begin))
+    begin_mom = * unsmob_moment (begin);
 
 
   
-  end = get_property ("beamAutoEnd", 0);
-  if (SMOB_IS_TYPE_B (Moment, end))
-    end_mom = * SMOB_TO_TYPE (Moment,end);
+  end = get_property ("beamAutoEnd");
+  if (unsmob_moment (end))
+    end_mom = * unsmob_moment (end);
 
   /*
     fifth guess [user override]: property plain, specific for duration type
   */
   if (type_str.length_i ())
     {
-      SCM end_mult = get_property (String ("beamAutoEnd") + type_str, 0);
-      if (SMOB_IS_TYPE_B (Moment, end_mult))
-       end_mom = * SMOB_TO_TYPE (Moment,end_mult);
+      SCM end_mult = get_property (String ("beamAutoEnd") + type_str);
+      if (unsmob_moment (end_mult))
+       end_mom = * unsmob_moment (end_mult);
 
-      SCM begin_mult = get_property (String ("beamAutoBegin") + type_str, 0);
-      if (SMOB_IS_TYPE_B (Moment, begin_mult))
-       begin_mom = * SMOB_TO_TYPE (Moment,begin_mult);
+      SCM begin_mult = get_property (String ("beamAutoBegin") + type_str);
+      if (unsmob_moment (begin_mult))
+       begin_mom = * unsmob_moment (begin_mult);
     }
 
   Rational r;
@@ -175,8 +180,8 @@ Auto_beam_engraver::consider_end_and_begin (Moment test_mom)
   /*
     Allow already started autobeam to end
    */
-  SCM on = get_property ("noAutoBeaming", 0);
-  if (gh_boolean_p (on) && gh_scm2bool (on))
+  SCM on = get_property ("noAutoBeaming");
+  if (to_boolean (on))
     return;
 
   if (begin_mom)
@@ -200,7 +205,7 @@ Auto_beam_engraver::begin_beam ()
 Beam*
 Auto_beam_engraver::create_beam_p ()
 {
-  Beam* beam_p = new Beam;
+  Beam* beam_p = new Beam (get_property ("basicBeamProperties"));
 
   for (int i = 0; i < stem_l_arr_p_->size (); i++)
     {
@@ -289,8 +294,8 @@ bool
 Auto_beam_engraver::same_grace_state_b (Score_element* e)
 {
   bool gr = e->get_elt_property ("grace") == SCM_BOOL_T;
-  SCM wg =get_property ("weAreGraceContext",0);
-  return (gh_boolean_p (wg) && gh_scm2bool (wg)) == gr;
+  SCM wg =get_property ("weAreGraceContext");
+  return (to_boolean (wg)) == gr;
 }
 
 void
@@ -327,7 +332,7 @@ Auto_beam_engraver::acknowledge_element (Score_element_info info)
       /*
        Don't (start) auto-beam over empty stems; skips or rests
        */
-      if (!stem_l->head_l_arr_.size ())
+      if (!stem_l->heads_i ())
        {
          if (stem_l_arr_p_)
            end_beam ();