2 beam.hh -- part of GNU LilyPond
4 source file of the LilyPond music typesetter
6 (c) 1996--2007 Han-Wen Nienhuys <hanwen@xs4all.nl>
7 Jan Nieuwenhuizen <janneke@gnu.org>
13 #include "grob-interface.hh"
14 #include "std-vector.hh"
15 #include "lily-proto.hh"
16 #include "stem-info.hh"
19 TODO: move quanting in separate file.
21 struct Beam_quant_parameters
23 Real INTER_QUANT_PENALTY
;
24 Real SECONDARY_BEAM_DEMERIT
;
25 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 HINT_DIRECTION_PENALTY
;
38 Real IDEAL_SLOPE_FACTOR
;
39 Real ROUND_TO_ZERO_SLOPE
;
41 void fill (Grob
*him
);
51 struct Beam_stem_segment
67 bool operator <(Beam_stem_segment
const &a
, Beam_stem_segment
const &b
);
72 static int normal_stem_count (Grob
*);
73 static Grob
*first_normal_stem (Grob
*);
74 static Grob
*last_normal_stem (Grob
*);
75 DECLARE_GROB_INTERFACE();
76 static void add_stem (Grob
*, Grob
*);
77 static bool is_cross_staff (Grob
*);
78 static bool is_knee (Grob
*);
79 static void set_beaming (Grob
*, Beaming_pattern
const *);
80 static void set_stemlens (Grob
*);
81 static int get_beam_count (Grob
*me
);
82 static Real
get_beam_translation (Grob
*me
);
83 static Real
get_thickness (Grob
*me
);
84 static void connect_beams (Grob
*me
);
85 static vector
<Beam_segment
> get_beam_segments (Grob
*me_grob
, Grob
**common
);
86 static Interval
no_visible_stem_positions (Grob
*me
, Interval default_value
);
88 DECLARE_SCHEME_CALLBACK (rest_collision_callback
, (SCM element
, SCM prev_off
));
89 DECLARE_SCHEME_CALLBACK (print
, (SCM
));
90 DECLARE_SCHEME_CALLBACK (calc_beaming
, (SCM
));
91 DECLARE_SCHEME_CALLBACK (calc_stem_shorten
, (SCM
));
92 DECLARE_SCHEME_CALLBACK (calc_direction
, (SCM
));
93 DECLARE_SCHEME_CALLBACK (calc_positions
, (SCM
));
94 DECLARE_SCHEME_CALLBACK (calc_least_squares_positions
, (SCM
, SCM
));
95 DECLARE_SCHEME_CALLBACK (calc_normal_stems
, (SCM
));
96 DECLARE_SCHEME_CALLBACK (calc_concaveness
, (SCM
));
97 DECLARE_SCHEME_CALLBACK (set_stem_lengths
, (SCM
));
98 DECLARE_SCHEME_CALLBACK (calc_cross_staff
, (SCM
));
100 /* position callbacks */
101 DECLARE_SCHEME_CALLBACK (shift_region_to_valid
, (SCM
, SCM
));
102 DECLARE_SCHEME_CALLBACK (slope_damping
, (SCM
, SCM
));
103 DECLARE_SCHEME_CALLBACK (quanting
, (SCM
, SCM
));
105 static Real
score_slopes_dy (Real
, Real
, Real
, Real
, Real
, bool, Beam_quant_parameters
const *);
107 static Real
score_stem_lengths (vector
<Grob
*> const &stems
,
108 vector
<Stem_info
> const &stem_infos
,
109 vector
<Real
> const &base_stem_ys
,
110 vector
<Real
> const &stem_xs
,
113 Real yl
, Real yr
, Beam_quant_parameters
const *);
114 static Real
score_forbidden_quants (Real
, Real
,
115 Real
, Real
, Real
, Real
,
116 Drul_array
<int>, Direction
, Direction
,
117 Beam_quant_parameters
const *);
119 static int get_direction_beam_count (Grob
*me
, Direction d
);
121 static Direction
get_default_dir (Grob
*);
122 static void set_stem_directions (Grob
*, Direction
);
123 static void consider_auto_knees (Grob
*);
124 static void set_stem_shorten (Grob
*);
125 static Real
calc_stem_y (Grob
*, Grob
*s
, Grob
**c
,
126 Real
, Real
, Direction
,
127 Drul_array
<Real
> pos
, bool french
);
128 static int forced_stem_count (Grob
*);