2 beam.hh -- part of GNU LilyPond
4 source file of the LilyPond music typesetter
6 (c) 1996--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 Jan Nieuwenhuizen <janneke@gnu.org>
13 #include "lily-proto.hh"
14 #include "lily-guile.hh"
15 #include "stem-info.hh"
19 TODO: move quanting in separate file.
21 struct Beam_quant_parameters {
22 Real INTER_QUANT_PENALTY;
23 Real SECONDARY_BEAM_DEMERIT;
24 Real STEM_LENGTH_DEMERIT_FACTOR;
29 threshold to combat rounding errors.
33 // possibly ridiculous, but too short stems just won't do
34 Real STEM_LENGTH_LIMIT_PENALTY;
35 Real DAMPING_DIRECTION_PENALTY;
36 Real MUSICAL_DIRECTION_FACTOR;
37 Real IDEAL_SLOPE_FACTOR;
38 Real ROUND_TO_ZERO_SLOPE;
40 void fill (Grob *him);
46 static int visible_stem_count (Grob *);
47 static Grob *first_visible_stem (Grob *);
48 static Grob *last_visible_stem (Grob *);
49 static bool has_interface (Grob *);
50 static void add_stem (Grob *, Grob *);
51 static bool is_knee (Grob *);
52 static void set_beaming (Grob *, Beaming_info_list *);
53 static void set_stemlens (Grob *);
54 static int get_beam_count (Grob *me);
55 static void position_beam (Grob *me);
56 static Real get_beam_translation (Grob *me);
57 static Real get_thickness (Grob *me);
58 static void connect_beams (Grob *me);
60 DECLARE_SCHEME_CALLBACK (rest_collision_callback, (SCM element, SCM axis));
61 DECLARE_SCHEME_CALLBACK (space_function, (SCM, SCM));
62 DECLARE_SCHEME_CALLBACK (print, (SCM));
63 DECLARE_SCHEME_CALLBACK (before_line_breaking, (SCM));
64 DECLARE_SCHEME_CALLBACK (after_line_breaking, (SCM));
66 /* position callbacks */
67 DECLARE_SCHEME_CALLBACK (least_squares, (SCM));
68 DECLARE_SCHEME_CALLBACK (check_concave, (SCM));
69 DECLARE_SCHEME_CALLBACK (slope_damping, (SCM));
70 DECLARE_SCHEME_CALLBACK (shift_region_to_valid, (SCM));
71 DECLARE_SCHEME_CALLBACK (quanting, (SCM));
72 static Real score_slopes_dy (Real, Real, Real, Real, Real, bool, Beam_quant_parameters const*);
74 static Real score_stem_lengths (Link_array<Grob> const &stems,
75 Array<Stem_info> const &stem_infos,
76 Array<Real> const &base_stem_ys,
77 Array<Real> const &stem_xs,
80 Real yl, Real yr, Beam_quant_parameters const*);
81 static Real score_forbidden_quants (Real, Real,
82 Real, Real, Real, Real,
83 Drul_array<int>, Direction, Direction,
84 Beam_quant_parameters const*);
86 static int get_direction_beam_count (Grob *me, Direction d);
88 static Direction get_default_dir (Grob *);
89 static void set_stem_directions (Grob *, Direction);
90 static void consider_auto_knees (Grob *);
91 static void set_stem_shorten (Grob *);
92 static Real calc_stem_y (Grob *, Grob *s, Grob **c,
94 Drul_array<Real> pos, bool french);
95 static void set_stem_lengths (Grob *);
96 static int forced_stem_count (Grob *);
100 #define DEBUG_QUANTING 1