]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/beam.hh
* The grand 2005-2006 replace.
[lilypond.git] / lily / include / beam.hh
1 /*
2   beam.hh -- part of GNU LilyPond
3
4   source file of the LilyPond music typesetter
5
6   (c) 1996--2006 Han-Wen Nienhuys <hanwen@xs4all.nl>
7   Jan Nieuwenhuizen <janneke@gnu.org>
8 */
9
10 #ifndef BEAM_HH
11 #define BEAM_HH
12
13 #include "lily-proto.hh"
14 #include "lily-guile.hh"
15 #include "stem-info.hh"
16
17 /*
18   TODO: move quanting in separate file.
19 */
20 struct Beam_quant_parameters
21 {
22   Real INTER_QUANT_PENALTY;
23   Real SECONDARY_BEAM_DEMERIT;
24   Real STEM_LENGTH_DEMERIT_FACTOR;
25   Real REGION_SIZE;
26
27   /*
28     threshold to combat rounding errors.
29   */
30   Real BEAM_EPS;
31
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;
38
39   void fill (Grob *him);
40 };
41
42 class Beam
43 {
44 public:
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);
57
58   DECLARE_SCHEME_CALLBACK (rest_collision_callback, (SCM element, SCM prev_off));
59   DECLARE_SCHEME_CALLBACK (print, (SCM));
60   DECLARE_SCHEME_CALLBACK (calc_beaming, (SCM));
61   DECLARE_SCHEME_CALLBACK (calc_stem_shorten, (SCM));
62   DECLARE_SCHEME_CALLBACK (calc_direction, (SCM));
63   DECLARE_SCHEME_CALLBACK (calc_positions, (SCM));
64   DECLARE_SCHEME_CALLBACK (calc_least_squares_positions, (SCM, SCM));
65   DECLARE_SCHEME_CALLBACK (calc_concaveness, (SCM));
66   DECLARE_SCHEME_CALLBACK (set_stem_lengths, (SCM));
67
68   /* position callbacks */
69   DECLARE_SCHEME_CALLBACK (shift_region_to_valid, (SCM, SCM));
70   DECLARE_SCHEME_CALLBACK (slope_damping, (SCM, SCM));
71   DECLARE_SCHEME_CALLBACK (quanting, (SCM, SCM));
72   
73 static Real score_slopes_dy (Real, Real, Real, Real, Real, bool, Beam_quant_parameters const *);
74
75   static Real score_stem_lengths (Link_array<Grob> const &stems,
76                                   Array<Stem_info> const &stem_infos,
77                                   Array<Real> const &base_stem_ys,
78                                   Array<Real> const &stem_xs,
79                                   Real xl, Real xr,
80                                   bool knee,
81                                   Real yl, Real yr, Beam_quant_parameters const *);
82   static Real score_forbidden_quants (Real, Real,
83                                       Real, Real, Real, Real,
84                                       Drul_array<int>, Direction, Direction,
85                                       Beam_quant_parameters const *);
86
87   static int get_direction_beam_count (Grob *me, Direction d);
88 private:
89   static Direction get_default_dir (Grob *);
90   static void set_stem_directions (Grob *, Direction);
91   static void consider_auto_knees (Grob *);
92   static void set_stem_shorten (Grob *);
93   static Real calc_stem_y (Grob *, Grob *s, Grob **c,
94                            Real, Real,
95                            Drul_array<Real> pos, bool french);
96   static int forced_stem_count (Grob *);
97 };
98
99 #ifndef NDEBUG
100 #define DEBUG_QUANTING 1
101 #endif
102
103 #endif /* BEAM_HH */
104