]> git.donarmstrong.com Git - lilypond.git/commitdiff
lilypond-1.1.34
authorfred <fred>
Tue, 26 Mar 2002 21:47:45 +0000 (21:47 +0000)
committerfred <fred>
Tue, 26 Mar 2002 21:47:45 +0000 (21:47 +0000)
12 files changed:
input/bugs/auto-beam.ly
input/test/auto-beam-triplet.ly [new file with mode: 0644]
lily/auto-beam-engraver.cc
lily/include/auto-beam-engraver.hh
ly/auto-beam-settings.ly
ly/property.ly
mutopia/E.Satie/petite-ouverture-a-danser.ly
mutopia/J.S.Bach/Solo-Cello-Suites/gigue-cello.ly
mutopia/J.S.Bach/Solo-Cello-Suites/gigue-viola.ly
mutopia/J.S.Bach/Solo-Cello-Suites/menuetto-cello.ly
mutopia/J.S.Bach/Solo-Cello-Suites/menuetto-viola.ly
mutopia/N.W.Gade/score.ly

index 622efcc3b713c9efbb8c1c2a02d2c81da8082578..ee339e34cbee85f0ef444cd29df287c9fdaab4bd 100644 (file)
@@ -13,9 +13,9 @@
            % add experimental auto-beaming
            \consists Auto_beam_engraver;
            beamAuto = 1.;
-           beamAutoEnd8 = "1/4";
-           beamAutoEnd16 = "1/4";
-           beamAutoEnd32 = "1/4";
+           beamAutoEnd_8 = "1/4";
+           beamAutoEnd_16 = "1/4";
+           beamAutoEnd_32 = "1/4";
        }
     }
 }
diff --git a/input/test/auto-beam-triplet.ly b/input/test/auto-beam-triplet.ly
new file mode 100644 (file)
index 0000000..4f3e4b7
--- /dev/null
@@ -0,0 +1,13 @@
+\score{
+       \notes\relative c''{
+               c8 c c c
+               \times 2/3 { c c c c c c}
+       }
+       \paper{
+               % urg, avoid crash
+               \translator{
+                       \VoiceContext
+                       \remove Tuplet_engraver;
+               }
+       }
+}
index a29ec75e67f420e55d831cb50f37f5bd1887e916..8055b73a52ad39107999c63ff19936d04cffbb2b 100644 (file)
@@ -21,8 +21,8 @@ ADD_THIS_TRANSLATOR (Auto_beam_engraver);
 
 Auto_beam_engraver::Auto_beam_engraver ()
 {
-  beam_p_ = 0;
-  mult_i_ = 0;
+  stem_l_arr_p_ = 0;
+  shortest_mom_ = 1;
   finished_beam_p_ = 0;
   finished_grouping_p_ = 0;
   grouping_p_ = 0;
@@ -41,8 +41,11 @@ Auto_beam_engraver::consider_end_and_begin ()
   int num = time->whole_per_measure_ / time->one_beat_;
   int den = time->one_beat_.den_i ();
   String time_str = String ("time") + to_str (num) + "_" + to_str (den);
-  int type = 1 << (mult_i_ + 2);
-  String type_str = to_str (type);
+  String type_str;
+  if (shortest_mom_.num () != 1)
+    type_str = to_str (shortest_mom_.num ());
+  if (shortest_mom_.den () != 1)
+    type_str = type_str + "_" + to_str (shortest_mom_.den ());
 
   /*
     Determine end moment for auto beaming (and begin, mostly 0==anywhere) 
@@ -92,7 +95,7 @@ Auto_beam_engraver::consider_end_and_begin ()
   /*
     third guess: property time exception, specific for duration type
   */
-  if (mult_i_)
+  if (type_str.length_i ())
     {
       Scalar end_mult = get_property (time_str + "beamAutoEnd" + type_str, 0);
       if (end_mult.length_i ())
@@ -116,7 +119,7 @@ Auto_beam_engraver::consider_end_and_begin ()
   /*
     fifth guess [user override]: property plain, specific for duration type
   */
-  if (mult_i_)
+  if (type_str.length_i ())
     {
       Scalar end_mult = get_property (String ("beamAutoEnd") + type_str, 0);
       if (end_mult.length_i ())
@@ -132,7 +135,7 @@ Auto_beam_engraver::consider_end_and_begin ()
   else
     r = Moment (1);
 
-  if (beam_p_ && !r)
+  if (stem_l_arr_p_ && !r)
     end_beam ();
      
   /*
@@ -144,7 +147,7 @@ Auto_beam_engraver::consider_end_and_begin ()
 
   if (begin_mom)
     r = time->whole_in_measure_.mod_rat (begin_mom);
-  if (!beam_p_ && (!begin_mom || !r))
+  if (!stem_l_arr_p_ && (!begin_mom || !r))
     begin_beam ();
 }
 
@@ -152,49 +155,61 @@ Auto_beam_engraver::consider_end_and_begin ()
 void
 Auto_beam_engraver::begin_beam ()
 {
-  DOUT << String ("starting autobeam at: ") + now_mom ().str () + "\n";
-  assert (!beam_p_);
-  beam_p_ = new Beam;
+  //  DOUT << String ("starting autobeam at: ") + now_mom ().str () + "\n";
+  assert (!stem_l_arr_p_);
+  stem_l_arr_p_ = new Array<Stem*>;
+  assert (!grouping_p_);
   grouping_p_ = new Rhythmic_grouping;
+}
+
+Beam*
+Auto_beam_engraver::create_beam_p ()
+{
+  Beam* beam_p = new Beam;
+
+  for (int i = 0; i < stem_l_arr_p_->size (); i++)
+    beam_p->add_stem ((*stem_l_arr_p_)[i]);
 
-      /* urg, copied from Beam_engraver */
+  /* urg, copied from Beam_engraver */
   Scalar prop = get_property ("beamslopedamping", 0);
   if (prop.isnum_b ()) 
-    beam_p_->damping_i_ = prop;
+    beam_p->damping_i_ = prop;
 
   prop = get_property ("beamquantisation", 0);
   if (prop.isnum_b ()) 
-    beam_p_->quantisation_ = (Beam::Quantisation)(int)prop;
+    beam_p->quantisation_ = (Beam::Quantisation)(int)prop;
  
-      // must set minVerticalAlign = = maxVerticalAlign to get sane results
-      // see input/test/beam-interstaff.ly
+  // must set minVerticalAlign = = maxVerticalAlign to get sane results
+  // see input/test/beam-interstaff.ly
   prop = get_property ("minVerticalAlign", 0);
   if (prop.isnum_b ())
-    beam_p_->vertical_align_drul_[MIN] = prop;
+    beam_p->vertical_align_drul_[MIN] = prop;
 
   prop = get_property ("maxVerticalAlign", 0);
   if (prop.isnum_b ())
-    beam_p_->vertical_align_drul_[MAX] = prop;
+    beam_p->vertical_align_drul_[MAX] = prop;
 
-  announce_element (Score_element_info (beam_p_, 0));
+  announce_element (Score_element_info (beam_p, 0));
+  return beam_p;
 }
 
 void
 Auto_beam_engraver::end_beam ()
 {
   DOUT << String ("ending autobeam at: ") + now_mom ().str () + "\n";
-  if (beam_p_->stems_.size () < 2)
+  if (stem_l_arr_p_->size () < 2)
     {
       DOUT << "junking autombeam: less than two stems\n";
       junk_beam ();
     }
   else
     {
-      finished_beam_p_ = beam_p_;
+      finished_beam_p_ = create_beam_p ();
       finished_grouping_p_ = grouping_p_;
-      beam_p_ = 0;
+      delete stem_l_arr_p_;
+      stem_l_arr_p_ = 0;
       grouping_p_ = 0;
-      mult_i_ = 0;
+      shortest_mom_ = 1;
     }
 }
  
@@ -229,7 +244,7 @@ void
 Auto_beam_engraver::do_removal_processing ()
 {
   typeset_beam ();
-  if (beam_p_)
+  if (stem_l_arr_p_ && stem_l_arr_p_->size ())
     {
       DOUT << "Unfinished beam\n";
       junk_beam ();
@@ -241,7 +256,7 @@ Auto_beam_engraver::acknowledge_element (Score_element_info info)
 {
   if (Beam *b = dynamic_cast<Beam *> (info.elem_l_))
     {
-      if (beam_p_)
+      if (stem_l_arr_p_)
        {
          DOUT << "junking autobeam: beam encountered\n";
          junk_beam ();
@@ -249,14 +264,14 @@ Auto_beam_engraver::acknowledge_element (Score_element_info info)
     }
   if (Bar *b = dynamic_cast<Bar *> (info.elem_l_))
     {
-      if (beam_p_)
+      if (stem_l_arr_p_)
        {
          DOUT << "junking autobeam: bar encountered\n";
          junk_beam ();
        }
     }
 
-  if (beam_p_)
+  if (stem_l_arr_p_)
     {
       Rhythmic_req *rhythmic_req = dynamic_cast <Rhythmic_req *> (info.req_l_);
       if (!rhythmic_req)
@@ -273,7 +288,7 @@ Auto_beam_engraver::acknowledge_element (Score_element_info info)
       if (!stem_l)
        return;
 
-      if (stem_l->beam_l_ && (stem_l->beam_l_ != beam_p_))
+      if (stem_l->beam_l_)
        {
          DOUT << "junking autobeam: beamed stem encountered\n";
          junk_beam ();
@@ -285,7 +300,7 @@ Auto_beam_engraver::acknowledge_element (Score_element_info info)
        now that we have last_add_mom_, perhaps we can (should) do away
        with these individual junk_beams
        */
-      if (rhythmic_req->duration_.durlog_i_<= 2)
+      if (rhythmic_req->duration_.durlog_i_ <= 2)
        {
          DOUT << "ending autobeam: stem doesn't fit in beam\n";
          end_beam ();
@@ -300,20 +315,19 @@ Auto_beam_engraver::acknowledge_element (Score_element_info info)
        }
       else
        {
-         int m = (rhythmic_req->duration_.durlog_i_ - 2);
          /*
-           if multiplicity would become greater,
+           if shortest duration would change
            reconsider ending/starting beam first.
           */
-         if (m > mult_i_)
+         Moment mom = rhythmic_req->duration_.length_mom ();
+         if (mom < shortest_mom_)
            {
-             mult_i_ = m;
+             shortest_mom_ = mom;
              consider_end_and_begin ();
            }
-         mult_i_ = m;
          grouping_p_->add_child (start, rhythmic_req->length_mom ());
          stem_l->flag_i_ = rhythmic_req->duration_.durlog_i_;
-         beam_p_->add_stem (stem_l);
+         stem_l_arr_p_->push (stem_l);
          Moment now = now_mom ();
          last_add_mom_ = now;
          extend_mom_ = extend_mom_ >? now + rhythmic_req->length_mom ();
@@ -324,29 +338,20 @@ Auto_beam_engraver::acknowledge_element (Score_element_info info)
 void
 Auto_beam_engraver::junk_beam () 
 {
-  assert (beam_p_);
-#if 0
-  for (int i=0; i < beam_p_->stems_.size (); i++)
-    {
-      Stem* s = beam_p_->stems_[i];
-      s->beams_i_drul_[LEFT] = 0;
-      s->beams_i_drul_[RIGHT] = 0;
-      s->mult_i_ = 0;
-      s->beam_l_ = 0;
-    }
-#endif
-  
-  beam_p_->unlink ();
-  beam_p_ = 0;
+  assert (stem_l_arr_p_);
+  for (int i = 0; i < stem_l_arr_p_->size (); i++)
+    (*stem_l_arr_p_)[i]->flag_i_ = 0;
+  delete stem_l_arr_p_;
+  stem_l_arr_p_ = 0;
   delete grouping_p_;
   grouping_p_ = 0;
-  mult_i_ = 0;
+  shortest_mom_ = 1;
 }
 
 void
 Auto_beam_engraver::process_acknowledged ()
 {
-  if (beam_p_)
+  if (stem_l_arr_p_)
     {
       Moment now = now_mom ();
       if ((extend_mom_ < now)
@@ -356,7 +361,7 @@ Auto_beam_engraver::process_acknowledged ()
            + last_add_mom_.str () + "\n";
          end_beam ();
        }
-      else if (!beam_p_->stems_.size ())
+      else if (!stem_l_arr_p_->size ())
        {
          DOUT << "junking started autobeam: no stems\n";
          junk_beam ();
index a2ebc6d4ccaad3c13e8774083b2cb6c6e68374cb..f56c7059fc159533e0880bb085bbe1cee04cfc59 100644 (file)
@@ -29,13 +29,14 @@ protected:
 private:
   void begin_beam ();
   void consider_end_and_begin ();
+  Beam* create_beam_p ();
   void end_beam ();
   void junk_beam ();
   void typeset_beam ();
 
-  int mult_i_;
+  Moment shortest_mom_;
   Beam *finished_beam_p_;
-  Beam *beam_p_;
+  Array<Stem*>* stem_l_arr_p_;
   Moment last_add_mom_;
   Moment extend_mom_;
   Rhythmic_grouping*grouping_p_;
index 09113b139d86a30c518759ff6b3ec6008c837954..b24a713d417df5551c3650d70fbacaaf3eda182b 100644 (file)
@@ -1,25 +1,31 @@
 %
 % setup for auto beamer
 %
+
+% *num_den (omitted if "1")
+
 time2_8beamAutoEnd = "2/8";
 time3_2beamAutoEnd = "1/2";
-time3_2beamAutoEnd16 = "1/4";
-time3_2beamAutoEnd32 = "1/8";
+time3_2beamAutoEnd_16 = "1/4";
+time3_2beamAutoEnd_32 = "1/8";
 time3_4beamAutoBegin = "1/4";
-time3_4beamAutoEnd8 = "3/4";
-time3_4beamAutoBegin32 = "1/8";
-time3_4beamAutoEnd32 = "1/8";
+time3_4beamAutoEnd_8 = "3/4";
+time3_4beamAutoBegin_32 = "1/8";
+time3_4beamAutoEnd_32 = "1/8";
 time3_8beamAutoBegin = "1/8";
 time3_8beamAutoEnd = "3/8";
-time4_4beamAutoEnd8 = "1/2";
-time4_4beamAutoEnd32 = "1/8";
-time4_8beamAutoEnd8 = "1/4";
-time4_8beamAutoEnd16 = "1/4";
-time4_8beamAutoEnd32 = "1/8";
+time4_4beamAutoEnd_8 = "1/2";
+% 1/12 == 1/8 * 2/3
+time4_4beamAutoEnd_12 = "1/4";
+time4_4beamAutoEnd_32 = "1/8";
+time4_8beamAutoEnd_8 = "1/4";
+time4_8beamAutoEnd_16 = "1/4";
+time4_8beamAutoEnd_32 = "1/8";
 time4_16beamAutoEnd = "1/8";
-time6_8beamAutoEnd8 = "3/8";
-time6_8beamAutoEnd16 = "3/8";
-time6_8beamAutoEnd32 = "1/8";
-time9_8beamAutoEnd8 = "3/8";
-time9_8beamAutoEnd16 = "3/8";
-time6_8beamAutoEnd32 = "1/8";
+time6_8beamAutoEnd_8 = "3/8";
+time6_8beamAutoEnd_16 = "3/8";
+time6_8beamAutoEnd_32 = "1/8";
+time9_8beamAutoEnd_8 = "3/8";
+time9_8beamAutoEnd_16 = "3/8";
+time6_8beamAutoEnd_32 = "1/8";
+
index fbd082d12ff79ed6d650069b66038254db7e1dd6..61b3333070a2883068bc6e62cfd76ba0e9ce1b8f 100644 (file)
@@ -61,8 +61,8 @@ barAtLineStart                0/1     generate bar at beginning of line
 [Staff]
 beamAuto                0/1     auto-beam on/off
 beamAutoEnd            "num/den"    end auto-beam
-beamAutoEnd          "num/den"    end auto-beam of 8ths
-beamAutoEnd16          "num/den"    end auto-beam of 16ths
+beamAutoEnd_8          "num/den"    end auto-beam of 8ths
+beamAutoEnd_16         "num/den"    end auto-beam of 16ths
 
 timeSignatureStyle     C       Use C and stroked C for 4/4,2/2
 timeSignatureStyle     old     Use old style mensuration marks
index 498d09a1b65ff0e02e63086e056583eb205d9107..67b645ef5491b1fd8f7195b250fbe80509577128 100644 (file)
@@ -152,8 +152,8 @@ lower = \type Staff \notes \relative c{
     \translator{ \OrchestralScoreContext }
     \translator{
            \VoiceContext
-           beamAutoEnd8 = "1/4";
-           beamAutoEnd16 = "1/4";
+           beamAutoEnd_8 = "1/4";
+           beamAutoEnd_16 = "1/4";
     }
   }
   \midi {
index 32c983c8d28652b4661decff070dfffeb22840b5..a60db7abd6621ad444fbce0211a84d9f7aa63298 100644 (file)
@@ -54,8 +54,8 @@ gigue_cello_staff = \type Staff <
                gourlay_maxmeasures = 7.0;
                \translator{
                        \VoiceContext
-                       beamAutoEnd8 = "3/4";
-                       beamAutoEnd16 = "3/4";
+                       beamAutoEnd_8 = "3/4";
+                       beamAutoEnd_16 = "3/4";
                }
        }
        \midi{ \tempo 4 = 60; }
index fbb79b2a0c49897d8fe9d31d3357754523abeae8..ab4becc7b827757de68eee3ee0ff142aa53a44aa 100644 (file)
@@ -54,8 +54,8 @@ gigue_viola_staff = \type Staff <
                gourlay_maxmeasures = 7.0;
                \translator{
                        \VoiceContext
-                       beamAutoEnd8 = "3/4";
-                       beamAutoEnd16 = "3/4";
+                       beamAutoEnd_8 = "3/4";
+                       beamAutoEnd_16 = "3/4";
                }
        }
        \midi{ \tempo 4 = 60; }
index 8595daaadea44ec9b73968d7328f28d2503152d6..94da30920d8914e657d160653841b2ecff274f39 100644 (file)
@@ -68,7 +68,7 @@ menuetto_i_cello_staff = \type Staff <
                gourlay_maxmeasures = 7.0;
                \translator{
                        \VoiceContext
-                       beamAutoEnd8 = "3/4";
+                       beamAutoEnd_8 = "3/4";
                }
        }
        \midi{ \tempo 4 = 110; }
@@ -103,7 +103,7 @@ menuetto_ii_cello_staff = \type Staff <
                gourlay_maxmeasures = 7.0;
                \translator{
                        \VoiceContext
-                       beamAutoEnd8 = "3/4";
+                       beamAutoEnd_8 = "3/4";
                }
        }
        \midi{ \tempo 4 = 130; }
index 90267514e0887497af43de8f7d1b2c9e1d3fd7aa..a1ff358dd3dd3f5282331d5e5c3f1f358774192d 100644 (file)
@@ -67,7 +67,7 @@ menuetto_i_viola_staff = \type Staff <
                gourlay_maxmeasures = 7.0;
                \translator{
                        \VoiceContext
-                       beamAutoEnd8 = "3/4";
+                       beamAutoEnd_8 = "3/4";
                }
        }
        \midi{ \tempo 4 = 110; }
@@ -101,7 +101,7 @@ menuetto_ii_viola_staff = \type Staff <
                gourlay_maxmeasures = 7.0;
                \translator{
                        \VoiceContext
-                       beamAutoEnd8 = "3/4";
+                       beamAutoEnd_8 = "3/4";
                }
        }
        \midi{ \tempo 4 = 130; }
index 23181116e2649b54039ecac8777db6dbae476a9c..b48b6d279c80b6b1d0fea751f0e6b20435297e89 100644 (file)
@@ -124,26 +124,23 @@ copyright =       "Mats Bengtsson, 1999. Free circulation permitted and " +
        textstyle = "italic";
        textScriptPadding = 5.0;
     }
-\translator{\VoiceContext
-\remove Auto_beam_engraver; % Bug workaround!
-}
   }
 }
 
 \score{
   \type StaffGroup <
-    \oboe
-    \flauto
-    \type Staff = cor {\notes \transpose bes <\clarI \clarII >}
-    \fagotto
-    \type Staff = cor {\notes \transpose f <\corI \corII >}
-    \type Staff = cor {\notes \transpose bes <\trpI \trpII >}
-    \timpani
-    \viI
-    \viII
-    \vla
-    \vlc
-    \cb
+    \type Staff = oboe \oboe
+    \type Staff = flauto \flauto
+    \type Staff = clarinetsInBes {\notes \transpose bes <\clarI \clarII >}
+    \type Staff = fagotto \fagotto
+    \type Staff = corniInF {\notes \transpose f <\corI \corII >}
+    \type Staff = trumpetsInBes {\notes \transpose bes <\trpI \trpII >}
+    \type Staff = timpani \timpani
+    \type Staff = violinoi \viI
+    \type Staff = violinoii \viII
+    \type Staff = viola \vla
+    \type Staff = violoncello \vlc
+    \type Staff = contrabass \cb
   >
   \midi {
     \tempo 4=120;