]> git.donarmstrong.com Git - lilypond.git/commitdiff
release commit release/2.3.21
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Sat, 9 Oct 2004 08:49:37 +0000 (08:49 +0000)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Sat, 9 Oct 2004 08:49:37 +0000 (08:49 +0000)
lily/include/slur-configuration.hh
lily/include/slur-scoring.hh
lily/slur-configuration.cc
lily/slur-scoring.cc
po/lilypond.pot
scm/slur.scm

index 0a59c053da871c1ba1ddde4d84382b2568f3adbc..42680ad0ab8174692dab52735e3d313779bcdf92 100644 (file)
@@ -22,7 +22,10 @@ public:
   Drul_array<Offset> attachment_;
   Real score_;
   Bezier curve_;
-
+  Real height_;
+  
+  int index_;
+  
 #if DEBUG_SLUR_SCORING
   String score_card_;
 #endif
@@ -31,7 +34,6 @@ public:
 
   void generate_curve (Slur_score_state const &state, Real r0, Real h_inf);
   void score (Slur_score_state const&);
-
 protected:
   void score_extra_encompass (Slur_score_state const&);
   void score_slopes  (Slur_score_state const&);
index fc44a48dae7b2c14cff3a977015d200d81b1d58a..8f4c6494dd96b47658a0d27f60bf852ce0c4bf30 100644 (file)
@@ -31,9 +31,12 @@ struct Slur_score_parameters
   Real free_slur_distance_;
   Real free_head_distance_;
   Real extra_encompass_free_distance_;
+  Real absolute_closeness_measure_;
   Real edge_slope_exponent_;
   Real head_slur_distance_max_ratio_;
   Real head_slur_distance_factor_;
+
+  void fill (Grob *him);
 };
 
 
@@ -122,7 +125,7 @@ struct Slur_score_state
   Slur_score_parameters parameters_;
   Drul_array<Bound_info> extremes_;
   Drul_array<Offset> base_attachments_;
-  Array<Slur_configuration> *scores_;
+  Link_array<Slur_configuration> configurations_;
   Real staff_space_;
   Real thickness_;
   
@@ -135,7 +138,7 @@ struct Slur_score_state
   
   Drul_array<Bound_info> get_bound_info () const;
   void generate_curves () const; 
-  Array<Slur_configuration> *enumerate_attachments (Drul_array<Real> end_ys) const;
+  Link_array<Slur_configuration> enumerate_attachments (Drul_array<Real> end_ys) const;
   Drul_array<Offset> get_base_attachments() const;
   Drul_array<Real> get_y_attachment_range() const;
   Encompass_info get_encompass_info (Grob *col) const;
index a8d52ca0b72331ace3aa4da264e334bc4986a562..ede2fcc8f9ca872d3a054bc0bab8c7a280e691b3 100644 (file)
@@ -94,11 +94,9 @@ fit_factor (Offset dz_unit, Offset dz_perp,
   return fit_factor;
 }
        
-
-Bezier
-get_bezier (Slur_score_state const &state,
-           Drul_array<Offset> attachments,
-           Real r_0, Real h_inf)
+void
+Slur_configuration::generate_curve (Slur_score_state const &state,
+                                   Real r_0, Real h_inf )
 {
   Link_array<Grob> encompasses = state.columns_;
 
@@ -131,7 +129,7 @@ get_bezier (Slur_score_state const &state,
        avoid.push (z);
       }
 
-  Offset dz = attachments[RIGHT]- attachments[LEFT];;
+  Offset dz = attachment_[RIGHT]- attachment_[LEFT];;
   Offset dz_unit = dz;
   dz_unit *= 1 / dz.length ();
   Offset dz_perp = dz_unit * Offset (0, 1);
@@ -179,44 +177,36 @@ get_bezier (Slur_score_state const &state,
   Real x2 = (excentricity - indent);
   
   Bezier curve;
-  curve.control_[0] = attachments[LEFT];
-  curve.control_[1] = attachments[LEFT] + dz_perp * height * state.dir_
+  curve.control_[0] = attachment_[LEFT];
+  curve.control_[1] = attachment_[LEFT] + dz_perp * height * state.dir_
     + dz_unit * x1;
-  curve.control_[2] = attachments[RIGHT] + dz_perp * height * state.dir_
+  curve.control_[2] = attachment_[RIGHT] + dz_perp * height * state.dir_
     + dz_unit * x2;
-  curve.control_[3] = attachments[RIGHT];
+  curve.control_[3] = attachment_[RIGHT];
 
   Real ff = fit_factor (dz_unit, dz_perp, curve, state.dir_, avoid);
   
   height = height >? ((height * ff) <? max_h);
 
-  curve.control_[0] = attachments[LEFT];
-  curve.control_[1] = attachments[LEFT] + dz_perp * height * state.dir_
+  curve.control_[0] = attachment_[LEFT];
+  curve.control_[1] = attachment_[LEFT] + dz_perp * height * state.dir_
     + dz_unit * x1;
-  curve.control_[2] = attachments[RIGHT] + dz_perp * height * state.dir_
+  curve.control_[2] = attachment_[RIGHT] + dz_perp * height * state.dir_
     + dz_unit * x2;
-  curve.control_[3] = attachments[RIGHT];
+  curve.control_[3] = attachment_[RIGHT];
 
-  return curve;
+  curve_ = avoid_staff_line (state, curve);
+  height_ = height;
 }
 
 Slur_configuration::Slur_configuration()
 {
   score_ = 0.0;
+  index_ = -1; 
 };
 
-void
-Slur_configuration::generate_curve (Slur_score_state const &state,
-                                   Real r_0, Real h_inf )
-{
-  Bezier bez = get_bezier (state,
-                          attachment_, r_0, h_inf);
 
-  bez = avoid_staff_line (state, bez);
-  attachment_[LEFT] = bez.control_[0];
-  attachment_[RIGHT] = bez.control_[3];
-  curve_ = bez;
-}
+
 
 void
 Slur_configuration::score_encompass (Slur_score_state const &state)
@@ -229,7 +219,6 @@ Slur_configuration::score_encompass (Slur_score_state const &state)
     attachment points.
   */
   Array<Real> convex_head_distances;
-  Array<Real> edge_distances;
   for (int j = 0; j < state.encompass_infos_.size (); j++)
     {
       Real x = state.encompass_infos_[j].x_;
@@ -238,14 +227,6 @@ Slur_configuration::score_encompass (Slur_score_state const &state)
       bool r_edge = j==state.encompass_infos_.size ()-1;
       bool edge =  l_edge || r_edge;
 
-
-      if (edge)
-       {
-         edge_distances.push (fabs (attachment_[l_edge ? LEFT : RIGHT][Y_AXIS]
-                                    - state.encompass_infos_[j].get_point (state.dir_)));
-       }
-       
-       
       if (! (x < attachment_[RIGHT][X_AXIS]
             && x > attachment_[LEFT][X_AXIS]))
        continue;
@@ -330,16 +311,12 @@ Slur_configuration::score_encompass (Slur_score_state const &state)
        For slurs over 3 or 4 heads, the average distance is not a
        good normalizer.
       */
-      int n =  convex_head_distances.size ();
-      if (convex_head_distances.size () <= 2)
+      Real n =  convex_head_distances.size ();
+      if (n <= 2)
        {
-         //          Real min_edge_dist = 1e6;
-         for (int j = 0; j < edge_distances.size (); j++)
-           {
-             avg_distance += edge_distances[j];
-             n++;
-           }
-
+         Real fact = 1.0;
+         avg_distance += height_ * fact;
+         n += fact;
        }
 
       /*
@@ -349,9 +326,11 @@ Slur_configuration::score_encompass (Slur_score_state const &state)
       avg_distance /= n;
       variance_penalty = state.parameters_.head_slur_distance_max_ratio_;
       if (min_dist > 0.0)
-       variance_penalty = ((avg_distance / (min_dist  +state.parameters_.free_head_distance_)) - 1.0)
+       variance_penalty =
+         (avg_distance / (min_dist + state.parameters_.absolute_closeness_measure_ ) - 1.0)
          <? variance_penalty;
 
+      variance_penalty = variance_penalty >? 0.0;
       variance_penalty *= state.parameters_.head_slur_distance_factor_;
     }
 #if DEBUG_SLUR_SCORING
index 1e4279baf85077dfe0a425b939b4c829a9a7cdae..d7e0129aa3c3ca089e3dee5f0a4f6e059a9ced10 100644 (file)
@@ -63,18 +63,13 @@ Slur_score_state::Slur_score_state()
   slur_ = 0;
   common_[X_AXIS] = 0;
   common_[Y_AXIS] = 0;
-  scores_ = 0;
 }
 
 Slur_score_state::~Slur_score_state ()
 {
-  delete scores_;
+  junk_pointers (configurations_);
 }
 
-
-
-
-
 Real
 get_detail (SCM alist, SCM sym)
 {
@@ -86,49 +81,49 @@ get_detail (SCM alist, SCM sym)
 }
 
 void
-init_score_param (Grob *me,
-                  Slur_score_parameters *score_param)
+Slur_score_parameters::fill (Grob *me)
 {
   SCM details = me->get_property ("slur-details");
 
-  score_param->region_size_
+  region_size_
     = (int) get_detail (details, ly_symbol2scm ("region-size"));
-  score_param->head_encompass_penalty_
+  head_encompass_penalty_
     = get_detail (details, ly_symbol2scm ("head-encompass-penalty"));
-  score_param->stem_encompass_penalty_
+  stem_encompass_penalty_
     = get_detail (details, ly_symbol2scm ("stem-encompass-penalty"));
-  score_param->closeness_factor_
+  closeness_factor_
     = get_detail (details, ly_symbol2scm ("closeness-factor"));
-  score_param->edge_attraction_factor_
+  edge_attraction_factor_
     = get_detail (details, ly_symbol2scm ("edge-attraction-factor"));
-  score_param->same_slope_penalty_
+  same_slope_penalty_
     = get_detail (details, ly_symbol2scm ("same-slope-penalty"));
-  score_param->steeper_slope_factor_
+  steeper_slope_factor_
     = get_detail (details, ly_symbol2scm ("steeper-slope-factor"));
-  score_param->non_horizontal_penalty_
+  non_horizontal_penalty_
     = get_detail (details, ly_symbol2scm ("non-horizontal-penalty"));
-  score_param->max_slope_
+  max_slope_
     = get_detail (details, ly_symbol2scm ("max-slope"));
-  score_param->max_slope_factor_
+  max_slope_factor_
     = get_detail (details, ly_symbol2scm ("max-slope-factor"));
-  score_param->free_head_distance_
+  free_head_distance_
     = get_detail (details, ly_symbol2scm ("free-head-distance"));
-  score_param->extra_object_collision_
+  absolute_closeness_measure_
+    = get_detail (details, ly_symbol2scm ("absolute-closeness-measure"));
+  extra_object_collision_
     = get_detail (details, ly_symbol2scm ("extra-object-collision"));
-  score_param->accidental_collision_
+  accidental_collision_
     = get_detail (details, ly_symbol2scm ("accidental-collision"));
-  score_param->extra_encompass_free_distance_
+  extra_encompass_free_distance_
     = get_detail (details, ly_symbol2scm ("extra-encompass-free-distance"));
-  score_param->head_slur_distance_factor_
+  head_slur_distance_factor_
     = get_detail (details, ly_symbol2scm ("head-slur-distance-factor"));
-  score_param->head_slur_distance_max_ratio_
+  head_slur_distance_max_ratio_
     = get_detail (details, ly_symbol2scm ("head-slur-distance-max-ratio"));
-  score_param->free_slur_distance_
+  free_slur_distance_
     = get_detail (details, ly_symbol2scm ("free-slur-distance"));
-  score_param->edge_slope_exponent_
+  edge_slope_exponent_
     = get_detail (details, ly_symbol2scm ("edge-slope-exponent"));
 }
-
 Real
 broken_trend_y (Slur_score_state const &state, Direction hdir)
 {
@@ -295,7 +290,7 @@ Slur_score_state::fill (Grob *me)
   thickness_ = robust_scm2double (me->get_property ("thickness"), 1.0) *  lt;
   
   dir_ = get_grob_direction (me);
-  init_score_param (me, &parameters_);
+  parameters_.fill (me);
   
   SCM eltlist = me->get_property ("note-columns");
   SCM extra_list = me->get_property ("encompass-objects");
@@ -316,7 +311,7 @@ Slur_score_state::fill (Grob *me)
 
   extremes_ = get_bound_info ();
   is_broken_ = (!extremes_[LEFT].note_column_
-                     || !extremes_[RIGHT].note_column_); 
+               || !extremes_[RIGHT].note_column_); 
 
   
   base_attachments_ = get_base_attachments ();
@@ -324,7 +319,7 @@ Slur_score_state::fill (Grob *me)
   Drul_array<Real> end_ys
     = get_y_attachment_range ();
 
-  scores_ = enumerate_attachments ( end_ys);
+  configurations_ = enumerate_attachments ( end_ys);
   for (int i = 0; i < columns_.size (); i++)
     encompass_infos_.push (get_encompass_info ( columns_[i]));
 
@@ -385,18 +380,18 @@ set_slur_control_points (Grob *me)
 Bezier
 Slur_score_state::get_best_curve ()
 {
-  for (int i = 0; i < scores_->size (); i++)
+  for (int i = 0; i < configurations_.size (); i++)
     {
-      scores_->elem (i).score (*this);
+      configurations_[i]->score (*this);
     }
   
   Real opt = 1e6;
   int opt_idx = -1;
-  for (int i = 0; i < scores_->size (); i++)
+  for (int i = 0; i < configurations_.size (); i++)
     {
-      if ((*scores_)[i].score_ < opt)
+      if (configurations_[i]->score_ < opt)
        {
-         opt = (*scores_)[i].score_;
+         opt = configurations_[i]->score_;
          opt_idx = i;
        }
     }
@@ -409,10 +404,10 @@ Slur_score_state::get_best_curve ()
     {
       Drul_array<Real> ins = ly_scm2interval (inspect_quants);
       Real mindist = 1e6;
-      for (int i = 0; i < scores_->size (); i ++)
+      for (int i = 0; i < configurations_.size (); i ++)
        {
-         Real d =fabs ((*scores_)[i].attachment_[LEFT][Y_AXIS] - ins[LEFT])
-           + fabs ((*scores_)[i].attachment_[RIGHT][Y_AXIS] - ins[RIGHT]);
+         Real d =fabs (configurations_[i]->attachment_[LEFT][Y_AXIS] - ins[LEFT])
+           + fabs (configurations_[i]->attachment_[RIGHT][Y_AXIS] - ins[RIGHT]);
          if (d < mindist)
            {
              opt_idx = i;
@@ -422,14 +417,17 @@ Slur_score_state::get_best_curve ()
       if (mindist > 1e5)
        programming_error ("Could not find quant.");
     }
-  (*scores_)[opt_idx].score_card_ += to_string ("i%d", opt_idx);
+
+  configurations_[opt_idx]->score_card_ += to_string ("=%.2f", opt);  
+  configurations_[opt_idx]->score_card_ += to_string ("i%d", opt_idx);
 
   // debug quanting
   slur_->set_property ("quant-score",
-                   scm_makfrom0str ((*scores_)[opt_idx].score_card_.to_str0 ()));
+                   scm_makfrom0str (configurations_[opt_idx]->score_card_.to_str0 ()));
+
 #endif
 
-  return scores_->elem (opt_idx).curve_;
+  return configurations_[opt_idx]->curve_;
 }
 
 /*
@@ -564,18 +562,18 @@ Slur_score_state::generate_curves () const
 {
   Real r_0 = robust_scm2double (slur_->get_property ("ratio"), 0.33);
   Real h_inf = staff_space_ *scm_to_double (slur_->get_property ("height-limit"));
-  for (int i = 0; i < scores_->size (); i++)
-    scores_->elem(i).generate_curve (*this, r_0, h_inf);
+  for (int i = 0; i < configurations_.size (); i++)
+    configurations_[i]->generate_curve (*this, r_0, h_inf);
 }
 
 
 
 
-Array<Slur_configuration> *
+Link_array<Slur_configuration> 
 Slur_score_state::enumerate_attachments (Drul_array<Real> end_ys) const
 {
   /*ugh.   */
-  Array<Slur_configuration> scores;
+  Link_array<Slur_configuration> scores;
 
 
   Drul_array<Offset> os;
@@ -652,8 +650,10 @@ Slur_score_state::enumerate_attachments (Drul_array<Real> end_ys) const
          while (flip (&d) != LEFT);
        
          s.attachment_ = os;
-         scores.push (s);
-       
+         s.index_ = scores.size ();
+
+         scores.push (new Slur_configuration (s));
+         
          os[RIGHT][Y_AXIS] += dir_ * staff_space_ / 2;
        }
 
@@ -661,12 +661,12 @@ Slur_score_state::enumerate_attachments (Drul_array<Real> end_ys) const
     }
 
   assert (scores.size () > 0);
-  return new Array<Slur_configuration> (scores);
+  return scores;
 }
 
 
 Array<Extra_collision_info>
-Slur_score_state::get_extra_encompass_infos ( ) const
+Slur_score_state::get_extra_encompass_infos () const
 {
   Link_array<Grob> encompasses
     = Pointer_group_interface__extract_grobs (slur_, (Grob *)0,
@@ -693,8 +693,7 @@ Slur_score_state::get_extra_encompass_infos ( ) const
              if (hdir && small_slur->get_bound (hdir) != slur_->get_bound (hdir))
                continue;
        
-
-             Offset z = b.curve_point ( k / 2.0);
+             Offset z = b.curve_point (k / 2.0);
              z += relative;
 
              Interval yext;
index fb44319090a9c437fb7288918d9ca35075ed8a27..991b13ea0fa29421fe1825a3e3b49857a63a6d7a 100644 (file)
@@ -8,7 +8,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: PACKAGE VERSION\n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2004-10-08 17:12+0200\n"
+"POT-Creation-Date: 2004-10-09 03:01+0200\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
 "Language-Team: LANGUAGE <LL@li.org>\n"
@@ -140,6 +140,8 @@ msgstr ""
 #. for --output-format.
 #. Bug in option parser: --output=foe is taken as an abbreviation
 #. for --output-format.
+#. Bug in option parser: --output=foe is taken as an abbreviation
+#. for --output-format.
 #: lilypond-book.py:89 main.cc:130 lily/main.cc:130
 msgid "EXT"
 msgstr ""
@@ -640,6 +642,7 @@ msgstr ""
 #. FIXME: broken sentence
 #. FIXME: broken sentence
 #. FIXME: broken sentence
+#. FIXME: broken sentence
 #: all-font-metrics.cc:95 lily/all-font-metrics.cc:95
 #, c-format
 msgid "checksum mismatch for font file: `%s'"
@@ -729,15 +732,16 @@ msgstr ""
 msgid "beam was started here"
 msgstr ""
 
-#: beam.cc:149 lily/beam.cc:149
+#: beam.cc:149 lily/beam.cc:149 lily/beam.cc:150
 msgid "beam has less than two visible stems"
 msgstr ""
 
-#: beam.cc:154 lily/beam.cc:154
+#: beam.cc:154 lily/beam.cc:154 lily/beam.cc:155
 msgid "removing beam with less than two stems"
 msgstr ""
 
 #: beam.cc:1038 lily/beam.cc:1038 lily/beam.cc:1063 lily/beam.cc:1065
+#: lily/beam.cc:1007
 msgid "no viable initial configuration found: may not find good beam slope"
 msgstr ""
 
@@ -793,6 +797,12 @@ msgstr ""
 #.
 #. last->translator_id_string ()  = get_change ()->change_to_id_string ();
 #.
+#.
+#. We could change the current translator's id, but that would make
+#. errors hard to catch
+#.
+#. last->translator_id_string ()  = get_change ()->change_to_id_string ();
+#.
 #: change-iterator.cc:93 lily/change-iterator.cc:93
 msgid "I'm one myself"
 msgstr ""
@@ -1184,6 +1194,7 @@ msgstr ""
 #. No version number or newline here.  It confuses help2man.
 #. No version number or newline here.  It confuses help2man.
 #. No version number or newline here.  It confuses help2man.
+#. No version number or newline here.  It confuses help2man.
 #: main.cc:192 lily/main.cc:192
 #, c-format
 msgid "Usage: %s [OPTIONS]... FILE..."
@@ -1284,6 +1295,9 @@ msgstr ""
 #.
 #. music for the softenon children?
 #.
+#.
+#. music for the softenon children?
+#.
 #: new-fingering-engraver.cc:155 lily/new-fingering-engraver.cc:155
 msgid "music for the martians."
 msgstr ""
@@ -1489,6 +1503,7 @@ msgstr ""
 #. FIXME:
 #. FIXME:
 #. FIXME:
+#. FIXME:
 #: script-engraver.cc:102 lily/script-engraver.cc:102
 msgid "Do not know how to interpret articulation: "
 msgstr ""
@@ -1504,6 +1519,7 @@ msgstr ""
 #. this shouldn't happen, but let's continue anyway.
 #. this shouldn't happen, but let's continue anyway.
 #. this shouldn't happen, but let's continue anyway.
+#. this shouldn't happen, but let's continue anyway.
 #: separation-item.cc:53 separation-item.cc:97 lily/separation-item.cc:53
 #: lily/separation-item.cc:97
 msgid "Separation_item:  I've been drinking too much"
@@ -1544,6 +1560,7 @@ msgstr ""
 #. FIXME:
 #. FIXME:
 #. FIXME:
+#. FIXME:
 #: stem-engraver.cc:125 lily/stem-engraver.cc:125
 #, c-format
 msgid "Adding note head to incompatible stem (type = %d)"
@@ -1607,6 +1624,8 @@ msgstr ""
 #. more of a programming error.
 #. Not using ngettext's plural feature here, as this message is
 #. more of a programming error.
+#. Not using ngettext's plural feature here, as this message is
+#. more of a programming error.
 #: tfm-reader.cc:108 lily/tfm-reader.cc:108
 #, c-format
 msgid "TFM header of `%s' has only %u word (s)"
@@ -1665,6 +1684,11 @@ msgstr ""
 #.
 #. OTOH, Tristan Keuris writes 8/20 in his Intermezzi.
 #.
+#.
+#. Todo: should make typecheck?
+#.
+#. OTOH, Tristan Keuris writes 8/20 in his Intermezzi.
+#.
 #: time-signature-engraver.cc:57 lily/time-signature-engraver.cc:57
 #, c-format
 msgid "Found strange time signature %d/%d."
@@ -1684,6 +1708,8 @@ msgstr ""
 #. (Here really with a warning!)
 #. If there is no such symbol, we default to the numbered style.
 #. (Here really with a warning!)
+#. If there is no such symbol, we default to the numbered style.
+#. (Here really with a warning!)
 #: time-signature.cc:91 lily/time-signature.cc:91
 #, c-format
 msgid "time signature symbol `%s' not found; reverting to numbered style"
index 5b1e9c102806984a6bb871ee13f76129b6898c84..772b5b28a4e804a33355b8e7fad68e178ad6f005 100644 (file)
@@ -25,5 +25,6 @@
     (extra-encompass-free-distance . 0.3)
     (head-slur-distance-max-ratio . 3)
     (head-slur-distance-factor . 10)
+    (absolute-closeness-measure . 0.3)
     (edge-slope-exponent . 2)
     ))