Drul_array<Offset> attachment_;
Real score_;
Bezier curve_;
-
+ Real height_;
+
+ int index_;
+
#if DEBUG_SLUR_SCORING
String score_card_;
#endif
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&);
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);
};
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_;
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;
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_;
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);
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)
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_;
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;
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;
}
/*
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
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)
{
}
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)
{
thickness_ = robust_scm2double (me->get_property ("thickness"), 1.0) * lt;
dir_ = get_grob_direction (me);
- init_score_param (me, ¶meters_);
+ parameters_.fill (me);
SCM eltlist = me->get_property ("note-columns");
SCM extra_list = me->get_property ("encompass-objects");
extremes_ = get_bound_info ();
is_broken_ = (!extremes_[LEFT].note_column_
- || !extremes_[RIGHT].note_column_);
+ || !extremes_[RIGHT].note_column_);
base_attachments_ = get_base_attachments ();
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]));
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;
}
}
{
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;
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_;
}
/*
{
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;
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;
}
}
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,
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;
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"
#. 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 ""
#. 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'"
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 ""
#.
#. 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 ""
#. 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..."
#.
#. 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 ""
#. FIXME:
#. FIXME:
#. FIXME:
+#. FIXME:
#: script-engraver.cc:102 lily/script-engraver.cc:102
msgid "Do not know how to interpret articulation: "
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"
#. FIXME:
#. FIXME:
#. FIXME:
+#. FIXME:
#: stem-engraver.cc:125 lily/stem-engraver.cc:125
#, c-format
msgid "Adding note head to incompatible stem (type = %d)"
#. 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)"
#.
#. 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."
#. (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"
(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)
))