intersection gets smaller. This fixes slurs over extreme points.
* lily/melody-engraver.cc (stop_translation_timestep): ignore
stems with neutral-direction set.
* lily/piano-pedal-engraver.cc (create_text_grobs): idem.
* lily/open-type-font.cc (load_table): format error.
* lily/change-iterator.cc (process): format fix.
* flower/include/international.hh (_f): idem.
* flower/include/std-string.hh: add format printf attribute.
* scm/define-grobs.scm (all-grob-descriptions): height of all
PedalLineSpanner is Y-extent property. Fixes pedal-ped.ly
2006-02-22 Han-Wen Nienhuys <hanwen@xs4all.nl>
+ * lily/slur-configuration.cc (fit_factor): oops, skip point if
+ intersection gets smaller. This fixes slurs over extreme points.
+
+ * lily/melody-engraver.cc (stop_translation_timestep): ignore
+ stems with neutral-direction set.
+
+ * lily/piano-pedal-engraver.cc (create_text_grobs): idem.
+
+ * lily/open-type-font.cc (load_table): format error.
+
+ * lily/change-iterator.cc (process): format fix.
+
+ * flower/include/international.hh (_f): idem.
+
+ * flower/include/std-string.hh: add format printf attribute.
+
+ * scm/define-grobs.scm (all-grob-descriptions): height of all
+ PedalLineSpanner is Y-extent property. Fixes pedal-ped.ly
+
* lily/ambitus-engraver.cc (finalize): use grob_array. This fixes
ambitus lines.
Internationalisation: _f ("Usage: %s [FILE]", "lilypond") gets "translated" by
GNU gettext
*/
-string _f (char const *format, ...);
+string _f (char const *format, ...)
+ __attribute__ ((format (printf, 1, 2)));
string _f (char const *format, string s, string s2 = "", string s3 = "");
#endif // INTERNATIONAL_HH
string to_string (long unsigned);
string to_string (unsigned);
string to_string (bool b);
-string to_string (char const *format, ...);
+string to_string (char const *format, ...)
+ __attribute__ ((format (printf, 1, 2)));
string &replace_all (string &str, string find, string replace);
string &replace_all (string &str, char find, char replace);
last->translator_id_string () = get_change
()->change_to_id_string (); */
- error (_f ("not changing to same context type: %s", to_type));
+ error (_f ("not changing to same context type: %s", ly_symbol2string (to_type).c_str ()));
}
else
/* FIXME: uncomprehensable message */
{
Translator *t = get_translator (scm_car (s));
if (!t)
- warning (_f ("can't find: `%s'", s));
+ warning (_f ("can't find: `%s'", ly_symbol2string (scm_car (s)).c_str ()));
else
{
Translator *tr = t->clone ();
Real directed_round (Real f, Direction d);
+Real peak_around (Real epsilon, Real threshold, Real x);
#endif
class Slur_configuration
{
+ Real score_;
+ string score_card_;
+
public:
Drul_array<Offset> attachment_;
- Real score_;
Bezier curve_;
Real height_;
int index_;
- string score_card_;
-
Slur_configuration ();
+ Real score () const { return score_; }
+ string card () const { return score_card_; }
+ void add_score (Real, string);
+
void generate_curve (Slur_score_state const &state, Real r0, Real h_inf,
vector<Offset> const &);
- void score (Slur_score_state const &);
+ void calculate_score (Slur_score_state const &);
protected:
void score_extra_encompass (Slur_score_state const &);
void score_slopes (Slur_score_state const &);
--- /dev/null
+/*
+ slur-score-paramaters.hh -- declare Slur_score_parameters
+
+ source file of the GNU LilyPond music typesetter
+
+ (c) 2006 Han-Wen Nienhuys <hanwen@xs4all.nl>
+
+*/
+
+#ifndef SLUR_SCORE_PARAMATERS_HH
+#define SLUR_SCORE_PARAMATERS_HH
+
+#include "lily-proto.hh"
+
+struct Slur_score_parameters
+{
+ int region_size_;
+ Real head_encompass_penalty_;
+ Real stem_encompass_penalty_;
+ Real closeness_factor_;
+ Real edge_attraction_factor_;
+ Real same_slope_penalty_;
+ Real steeper_slope_factor_;
+ Real non_horizontal_penalty_;
+ Real max_slope_;
+ Real max_slope_factor_;
+ Real extra_object_collision_penalty_;
+ Real accidental_collision_;
+ 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);
+};
+#endif /* SLUR_SCORE_PARAMATERS_HH */
#include "lily-proto.hh"
#include "std-vector.hh"
#include "lily-guile.hh"
-
-struct Slur_score_parameters
-{
- int region_size_;
- Real head_encompass_penalty_;
- Real stem_encompass_penalty_;
- Real closeness_factor_;
- Real edge_attraction_factor_;
- Real same_slope_penalty_;
- Real steeper_slope_factor_;
- Real non_horizontal_penalty_;
- Real max_slope_;
- Real max_slope_factor_;
- Real extra_object_collision_penalty_;
- Real accidental_collision_;
- 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);
-};
+#include "slur-score-parameters.hh"
struct Extra_collision_info
{
void
Melody_engraver::stop_translation_timestep ()
{
- if (stem_)
+ if (stem_
+ && !is_direction (stem_->get_property_data (ly_symbol2scm ("neutral-direction"))))
{
extract_grob_set (stem_, "rests", rests);
if (rests.size ())
return ceil (f);
}
+
+
+/*
+ 0 at threshold, 1 at 0, with 1/x falloff.
+ */
+Real
+peak_around (Real epsilon, Real threshold, Real x)
+{
+ if (x < 0)
+ return 1.0;
+ return max (- epsilon * (x - threshold) / ((x + epsilon) * threshold), 0.0);
+}
{
FT_Byte *buffer = (FT_Byte *) malloc (*length);
if (buffer == NULL)
- error (_f ("can't allocate %d bytes", *length));
+ error (_f ("can't allocate %lu bytes", *length));
error_code = FT_Load_Sfnt_Table (face, tag, 0, buffer, length);
if (error_code)
Music *m = p->event_drul_[START];
if (!m) m = p->event_drul_ [STOP];
- string msg = _f ("expect 3 strings for piano pedals, found: %d",
+ string msg = _f ("expect 3 strings for piano pedals, found: %ld",
scm_ilength (strings));
if (m)
m->origin ()->warning (msg);
}
#include "translator.icc"
+
ADD_ACKNOWLEDGER (Piano_pedal_engraver, note_column);
+
ADD_TRANSLATOR (Piano_pedal_engraver,
- /* doc */ "Engrave piano pedal symbols and brackets.",
- /* create */ "SostenutoPedal SustainPedal UnaCordaPedal SostenutoPedalLineSpanner SustainPedalLineSpanner UnaCordaPedalLineSpanner",
- /* accept */ "pedal-event",
- /* read */ "currentCommandColumn "
+
+ /* doc */
+ "Engrave piano pedal symbols and brackets.",
+
+ /* create */
+ "SostenutoPedal "
+ "SostenutoPedalLineSpanner "
+ "SustainPedal "
+ "SustainPedalLineSpanner "
+ "UnaCordaPedal "
+ "UnaCordaPedalLineSpanner ",
+
+ /* accept */
+ "pedal-event",
+
+ /* read */
+ "currentCommandColumn "
"pedalSostenutoStrings "
- "pedalSustainStrings "
- "pedalUnaCordaStrings "
"pedalSostenutoStyle "
+ "pedalSustainStrings "
"pedalSustainStyle "
+ "pedalUnaCordaStrings "
"pedalUnaCordaStyle",
/* write */ "");
Real eps = 0.01;
Interval pext = eps * Interval (-1,1) + p[X_AXIS];
pext.intersect (curve_xext);
- if (pext.is_empty () || pext.length () <= 2.1* eps)
+ if (pext.is_empty () || pext.length () <= 1.999 * eps)
continue;
Real y = curve.get_other_coordinate (X_AXIS, p[X_AXIS]);
index_ = -1;
};
+
+void
+Slur_configuration::add_score (Real s, string desc)
+{
+ if (s)
+ {
+ score_card_ += to_string ("%s=%.2f ", desc.c_str (), s);
+ score_ += s;
+ }
+}
+
void
Slur_configuration::score_encompass (Slur_score_state const &state)
{
/ state.encompass_infos_.size ();
}
}
-
- Real variance_penalty = 0.0;
-
+ add_score (demerit, "encompass");
+
if (convex_head_distances.size ())
{
Real avg_distance = 0.0;
as penalty.
*/
avg_distance /= n;
- variance_penalty = state.parameters_.head_slur_distance_max_ratio_;
+ Real variance_penalty = state.parameters_.head_slur_distance_max_ratio_;
if (min_dist > 0.0)
variance_penalty
= min ((avg_distance / (min_dist + state.parameters_.absolute_closeness_measure_) - 1.0), variance_penalty);
variance_penalty = max (variance_penalty, 0.0);
variance_penalty *= state.parameters_.head_slur_distance_factor_;
- }
-
-#if DEBUG_SLUR_SCORING
- score_card_ += to_string ("C%.2f", demerit);
- score_card_ += to_string ("D%.2f", variance_penalty);
-#endif
- score_ += demerit + variance_penalty;
+ add_score (variance_penalty, "variance");
+ }
}
void
Slur_configuration::score_extra_encompass (Slur_score_state const &state)
{
- Real demerit = 0.0;
for (vsize j = 0; j < state.extra_encompass_infos_.size (); j++)
{
Drul_array<Offset> attachment = attachment_;
else
programming_error ("unknown avoidance type");
- Real epsilon = 0.1;
- Real factor
- = (1.0 / (max (dist, 0.0) + epsilon * state.parameters_.extra_encompass_free_distance_));
- Real threshold
- = 1.0 / ((1 + epsilon) * state.parameters_.extra_encompass_free_distance_);
+ dist = max (dist, 0.0);
- demerit
- += max (info.penalty_ * (factor - threshold), 0.0);
+ Real penalty = info.penalty_ * peak_around (0.1 * state.parameters_.extra_encompass_free_distance_,
+ state.parameters_.extra_encompass_free_distance_,
+ dist);
+
+ add_score (penalty, "extra");
}
-#if DEBUG_SLUR_SCORING
- score_card_ += to_string ("X%.2f", demerit);
-#endif
-
- score_ += demerit;
}
void
demerit *= exp (state.dir_ * d * slope
* state.parameters_.edge_slope_exponent_);
- score_ += demerit;
-#if DEBUG_SLUR_SCORING
- score_card_ += to_string ("E%.2f", demerit);
-#endif
+ add_score (demerit, "edge");
}
while (flip (&d) != LEFT);
}
? state.parameters_.same_slope_penalty_ / 10
: state.parameters_.same_slope_penalty_;
-#if DEBUG_SLUR_SCORING
- score_card_ += to_string ("S%.2f", demerit);
-#endif
- score_ += demerit;
+ add_score (demerit, "slope");
}
void
-Slur_configuration::score (Slur_score_state const &state)
+Slur_configuration::calculate_score (Slur_score_state const &state)
{
score_extra_encompass (state);
score_slopes (state);
--- /dev/null
+/*
+ slur-score-paramaters.cc -- implement Slur_score_parameters
+
+ source file of the GNU LilyPond music typesetter
+
+ (c) 2006 Han-Wen Nienhuys <hanwen@xs4all.nl>
+
+*/
+
+
+#include "slur-score-parameters.hh"
+#include "grob.hh"
+
+
+Real
+get_detail (SCM alist, SCM sym)
+{
+ SCM entry = scm_assq (sym, alist);
+ return robust_scm2double (scm_is_pair (entry)
+ ? scm_cdr (entry)
+ : SCM_EOL,
+ 0.0);
+}
+
+void
+Slur_score_parameters::fill (Grob *me)
+{
+ SCM details = me->get_property ("details");
+
+ region_size_
+ = (int) get_detail (details, ly_symbol2scm ("region-size"));
+ head_encompass_penalty_
+ = get_detail (details, ly_symbol2scm ("head-encompass-penalty"));
+ stem_encompass_penalty_
+ = get_detail (details, ly_symbol2scm ("stem-encompass-penalty"));
+ closeness_factor_
+ = get_detail (details, ly_symbol2scm ("closeness-factor"));
+ edge_attraction_factor_
+ = get_detail (details, ly_symbol2scm ("edge-attraction-factor"));
+ same_slope_penalty_
+ = get_detail (details, ly_symbol2scm ("same-slope-penalty"));
+ steeper_slope_factor_
+ = get_detail (details, ly_symbol2scm ("steeper-slope-factor"));
+ non_horizontal_penalty_
+ = get_detail (details, ly_symbol2scm ("non-horizontal-penalty"));
+ max_slope_
+ = get_detail (details, ly_symbol2scm ("max-slope"));
+ max_slope_factor_
+ = get_detail (details, ly_symbol2scm ("max-slope-factor"));
+ free_head_distance_
+ = get_detail (details, ly_symbol2scm ("free-head-distance"));
+ absolute_closeness_measure_
+ = get_detail (details, ly_symbol2scm ("absolute-closeness-measure"));
+ extra_object_collision_penalty_
+ = get_detail (details, ly_symbol2scm ("extra-object-collision-penalty"));
+ accidental_collision_
+ = get_detail (details, ly_symbol2scm ("accidental-collision"));
+ extra_encompass_free_distance_
+ = get_detail (details, ly_symbol2scm ("extra-encompass-free-distance"));
+ head_slur_distance_factor_
+ = get_detail (details, ly_symbol2scm ("head-slur-distance-factor"));
+ head_slur_distance_max_ratio_
+ = get_detail (details, ly_symbol2scm ("head-slur-distance-max-ratio"));
+ free_slur_distance_
+ = get_detail (details, ly_symbol2scm ("free-slur-distance"));
+ edge_slope_exponent_
+ = get_detail (details, ly_symbol2scm ("edge-slope-exponent"));
+}
#include "slur-scoring.hh"
-#include "libc-extension.hh"
-#include "slur-configuration.hh"
+
+#include "accidental-interface.hh"
#include "beam.hh"
#include "directional-element-interface.hh"
-#include "pointer-group-interface.hh"
-#include "slur.hh"
+#include "libc-extension.hh"
+#include "main.hh"
#include "note-column.hh"
#include "output-def.hh"
+#include "paper-column.hh"
#include "pitch.hh"
+#include "pointer-group-interface.hh"
+#include "slur-configuration.hh"
+#include "slur.hh"
#include "spanner.hh"
#include "staff-symbol-referencer.hh"
#include "staff-symbol.hh"
#include "stem.hh"
#include "warn.hh"
-#include "paper-column.hh"
-#include "accidental-interface.hh"
/*
TODO:
junk_pointers (configurations_);
}
-Real
-get_detail (SCM alist, SCM sym)
-{
- SCM entry = scm_assq (sym, alist);
- return robust_scm2double (scm_is_pair (entry)
- ? scm_cdr (entry)
- : SCM_EOL,
- 0.0);
-}
-
-void
-Slur_score_parameters::fill (Grob *me)
-{
- SCM details = me->get_property ("details");
-
- region_size_
- = (int) get_detail (details, ly_symbol2scm ("region-size"));
- head_encompass_penalty_
- = get_detail (details, ly_symbol2scm ("head-encompass-penalty"));
- stem_encompass_penalty_
- = get_detail (details, ly_symbol2scm ("stem-encompass-penalty"));
- closeness_factor_
- = get_detail (details, ly_symbol2scm ("closeness-factor"));
- edge_attraction_factor_
- = get_detail (details, ly_symbol2scm ("edge-attraction-factor"));
- same_slope_penalty_
- = get_detail (details, ly_symbol2scm ("same-slope-penalty"));
- steeper_slope_factor_
- = get_detail (details, ly_symbol2scm ("steeper-slope-factor"));
- non_horizontal_penalty_
- = get_detail (details, ly_symbol2scm ("non-horizontal-penalty"));
- max_slope_
- = get_detail (details, ly_symbol2scm ("max-slope"));
- max_slope_factor_
- = get_detail (details, ly_symbol2scm ("max-slope-factor"));
- free_head_distance_
- = get_detail (details, ly_symbol2scm ("free-head-distance"));
- absolute_closeness_measure_
- = get_detail (details, ly_symbol2scm ("absolute-closeness-measure"));
- extra_object_collision_penalty_
- = get_detail (details, ly_symbol2scm ("extra-object-collision-penalty"));
- accidental_collision_
- = get_detail (details, ly_symbol2scm ("accidental-collision"));
- extra_encompass_free_distance_
- = get_detail (details, ly_symbol2scm ("extra-encompass-free-distance"));
- head_slur_distance_factor_
- = get_detail (details, ly_symbol2scm ("head-slur-distance-factor"));
- head_slur_distance_max_ratio_
- = get_detail (details, ly_symbol2scm ("head-slur-distance-max-ratio"));
- free_slur_distance_
- = get_detail (details, ly_symbol2scm ("free-slur-distance"));
- edge_slope_exponent_
- = get_detail (details, ly_symbol2scm ("edge-slope-exponent"));
-}
-
Real
broken_trend_y (Slur_score_state const &state, Direction hdir)
{
Real opt = 1e6;
#if DEBUG_SLUR_SCORING
+ bool debug_slurs = to_boolean (slur_->layout ()
+ ->lookup_variable (ly_symbol2scm ("debug-slur-scoring")));
SCM inspect_quants = slur_->get_property ("inspect-quants");
- if (to_boolean (slur_->layout ()
- ->lookup_variable (ly_symbol2scm ("debug-slur-scoring")))
+ if (debug_slurs
&& scm_is_pair (inspect_quants))
{
opt_idx = get_closest_index (inspect_quants);
- configurations_[opt_idx]->score (*this);
- opt = configurations_[opt_idx]->score_;
+ configurations_[opt_idx]->calculate_score (*this);
+ opt = configurations_[opt_idx]->score ();
}
else
#endif
{
for (vsize i = 0; i < configurations_.size (); i++)
- configurations_[i]->score (*this);
+ configurations_[i]->calculate_score (*this);
for (vsize i = 0; i < configurations_.size (); i++)
{
- if (configurations_[i]->score_ < opt)
+ if (configurations_[i]->score () < opt)
{
- opt = configurations_[i]->score_;
+ opt = configurations_[i]->score ();
opt_idx = i;
}
}
}
#if DEBUG_SLUR_SCORING
- if (opt_idx >= 0)
- {
- configurations_[opt_idx]->score_card_ += to_string ("=%.2f", opt);
- configurations_[opt_idx]->score_card_ += to_string ("i%d", opt_idx);
- }
- else
+ if (debug_slurs)
{
- programming_error ("No optimal slur found. Guessing 0.");
- opt_idx = 0;
- }
+ string total;
+ if (opt_idx >= 0)
+ {
+ total = configurations_[opt_idx]->card ();
+ total += to_string ("TOTAL=%.2f idx=%d", configurations_[opt_idx]->score (), opt_idx);
+ }
+ else
+ {
+ programming_error ("No optimal slur found. Guessing 0.");
+ total = "no sol?";
+ }
- // debug quanting
- slur_->set_property ("quant-score",
- scm_makfrom0str (configurations_[opt_idx]->score_card_.c_str ()));
-
+ slur_->set_property ("quant-score",
+ scm_makfrom0str (total.c_str ()));
+ }
#endif
return configurations_[opt_idx]->curve_;
for (int k = 0; k < 3; k++)
{
- Direction hdir = Direction (k / 2 - 1);
+ Direction hdir = Direction (k - 1);
/*
Only take bound into account if small slur starts
Interval xext (-1, 1);
xext = xext * (thickness_ * 2) + z[X_AXIS];
Extra_collision_info info (small_slur,
- k - 1.0,
+ hdir,
xext,
yext,
parameters_.extra_object_collision_penalty_);
string str;
SCM properties = Font_interface::text_font_alist_chain (me);
+ properties = scm_cons (scm_acons (ly_symbol2scm ("font-size"), scm_from_int (-6), SCM_EOL),
+ properties);
Stencil tm = *unsmob_stencil (Text_interface::interpret_markup
(me->layout ()->self_scm (), properties,
quant_score));
#include "directional-element-interface.hh"
#include "item.hh"
#include "libc-extension.hh"
+#include "misc.hh"
#include "note-head.hh"
#include "rhythmic-head.hh"
#include "spanner.hh"
#include "tie.hh"
#include "warn.hh"
-/*
- 0 at threshold, 1 at 0, with 1/x falloff.
- */
-Real peak_around (Real epsilon, Real threshold, Real x)
-{
- if (x < 0)
- return 1.0;
- return max (- epsilon * (x - threshold) / ((x + epsilon) * threshold), 0.0);
-}
void
Tie_formatting_problem::print_ties_configuration (Ties_configuration const *ties)
(minimum-length . 1.5)
(height-limit . 2.0)
(ratio . 0.25)
+ (avoid-slur . inside)
(meta . ((class . Spanner)
(interfaces . (slur-interface))))))
(SostenutoPedalLineSpanner
. (
(axes . (1))
- (X-extent . ,ly:axis-group-interface::height)
+ (Y-extent . ,ly:axis-group-interface::height)
(Y-offset . ,ly:side-position-interface::y-aligned-side)
(side-axis . ,Y)
+ (staff-padding . 1.0)
(padding . 1.2)
(minimum-space . 1.0)
(direction . ,DOWN)
))
-
- ;; default stem direction for note on middle line
- (neutral-direction . ,DOWN)
-
;; We use the normal minima as minimum for the ideal lengths,
;; and the extreme minima as abolute minimum length.
(SustainPedalLineSpanner
. (
(axes . (1))
- (X-extent . ,ly:axis-group-interface::height)
+ (Y-extent . ,ly:axis-group-interface::height)
(Y-offset . ,ly:side-position-interface::y-aligned-side)
(side-axis . ,Y)
(padding . 1.2)
(UnaCordaPedalLineSpanner
. (
(axes . (1))
- (X-extent . ,ly:axis-group-interface::height)
+ (Y-extent . ,ly:axis-group-interface::height)
(Y-offset . ,ly:side-position-interface::y-aligned-side)
(side-axis . ,Y)
(padding . 1.2)
(free-slur-distance . 0.8)
(extra-object-collision-penalty . 50)
(accidental-collision . 3)
- (extra-encompass-free-distance . 0.3)
+ (extra-encompass-free-distance . 0.8)
(head-slur-distance-max-ratio . 3)
(head-slur-distance-factor . 10)
(absolute-closeness-measure . 0.3)