2 beaming-info.cc -- implement Beaming_info, Beaming_info_list
4 source file of the GNU LilyPond music typesetter
6 (c) 1999--2001 Han-Wen Nienhuys <hanwen@cs.uu.nl>
12 Beaming_info::Beaming_info ()
15 beams_i_drul_
[LEFT
] = 0;
16 beams_i_drul_
[RIGHT
] = 0;
19 Beaming_info::Beaming_info (Moment m
, int i
)
22 beams_i_drul_
[LEFT
] = i
;
23 beams_i_drul_
[RIGHT
] = i
;
26 const int infinity_i
= INT_MAX
; // guh.
29 Beaming_info_list::min_denominator_index () const
31 int minden
= infinity_i
;
34 for (int i
=1; i
< infos_
.size (); i
++)
36 if (infos_
[i
].start_mom_
.den () < minden
)
39 minden
= infos_
[i
].start_mom_
.den ();
47 Beaming_info_list::beam_extend_count (Direction d
) const
49 if (infos_
.size () == 1)
50 return infos_
[0].beams_i_drul_
[d
];
52 Beaming_info thisbeam
= infos_
.boundary (d
, 0);
53 Beaming_info next
= infos_
.boundary (d
, 1);
55 return thisbeam
.beams_i_drul_
[-d
] <? next
.beams_i_drul_
[d
];
59 Beaming_info_list::beamify ()
61 if (infos_
.size () <= 1)
64 Drul_array
<Beaming_info_list
> splits
;
65 int m
= min_denominator_index ();
66 splits
[LEFT
].infos_
= infos_
.slice (0,m
);
67 splits
[RIGHT
].infos_
= infos_
.slice (m
, infos_
.size ());
75 while (flip (&d
) != LEFT
);
77 int middle_beams
= splits
[RIGHT
].beam_extend_count (LEFT
) <?
78 splits
[LEFT
].beam_extend_count (RIGHT
);
82 if (splits
[d
].infos_
.size () != 1)
84 splits
[d
].infos_
.boundary (-d
, 0).beams_i_drul_
[-d
] = middle_beams
;
87 while (flip (&d
) != LEFT
);
89 infos_
= splits
[LEFT
].infos_
;
90 infos_
.concat (splits
[RIGHT
].infos_
);
94 Beaming_info_list::add_stem (Moment m
, int b
)
96 infos_
.push (Beaming_info (m
, b
));