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"
18 TODO: move quanting in separate file.
20 struct Beam_quant_parameters
22 Real INTER_QUANT_PENALTY;
23 Real SECONDARY_BEAM_DEMERIT;
24 Real STEM_LENGTH_DEMERIT_FACTOR;
28 threshold to combat rounding errors.
32 // possibly ridiculous, but too short stems just won't do
33 Real STEM_LENGTH_LIMIT_PENALTY;
34 Real DAMPING_DIRECTION_PENALTY;
35 Real MUSICAL_DIRECTION_FACTOR;
36 Real IDEAL_SLOPE_FACTOR;
37 Real ROUND_TO_ZERO_SLOPE;
39 void fill (Grob *him);
45 static int visible_stem_count (Grob *);
46 static Grob *first_visible_stem (Grob *);
47 static Grob *last_visible_stem (Grob *);
48 static bool has_interface (Grob *);
49 static void add_stem (Grob *, Grob *);
50 static bool is_knee (Grob *);
51 static void set_beaming (Grob *, Beaming_info_list const *);
52 static void set_stemlens (Grob *);
53 static int get_beam_count (Grob *me);
54 static Real get_beam_translation (Grob *me);
55 static Real get_thickness (Grob *me);
56 static void connect_beams (Grob *me);
58 DECLARE_SCHEME_CALLBACK (rest_collision_callback, (SCM element, SCM axis));
59 DECLARE_SCHEME_CALLBACK (print, (SCM));
60 DECLARE_SCHEME_CALLBACK (calc_direction, (SCM));
61 DECLARE_SCHEME_CALLBACK (calc_positions, (SCM));
63 /* position callbacks */
64 DECLARE_SCHEME_CALLBACK (least_squares, (SCM));
65 DECLARE_SCHEME_CALLBACK (check_concave, (SCM));
66 DECLARE_SCHEME_CALLBACK (slope_damping, (SCM));
67 DECLARE_SCHEME_CALLBACK (shift_region_to_valid, (SCM));
68 DECLARE_SCHEME_CALLBACK (quanting, (SCM));
69 static Real score_slopes_dy (Real, Real, Real, Real, Real, bool, Beam_quant_parameters const *);
71 static Real score_stem_lengths (Link_array<Grob> const &stems,
72 Array<Stem_info> const &stem_infos,
73 Array<Real> const &base_stem_ys,
74 Array<Real> const &stem_xs,
77 Real yl, Real yr, Beam_quant_parameters const *);
78 static Real score_forbidden_quants (Real, Real,
79 Real, Real, Real, Real,
80 Drul_array<int>, Direction, Direction,
81 Beam_quant_parameters const *);
83 static int get_direction_beam_count (Grob *me, Direction d);
85 static Direction get_default_dir (Grob *);
86 static void set_stem_directions (Grob *, Direction);
87 static void consider_auto_knees (Grob *);
88 static void set_stem_shorten (Grob *);
89 static Real calc_stem_y (Grob *, Grob *s, Grob **c,
91 Drul_array<Real> pos, bool french);
92 static void set_stem_lengths (Grob *);
93 static int forced_stem_count (Grob *);
97 #define DEBUG_QUANTING 1