2 meter-reg.cc -- implement Meter_register
4 source file of the GNU LilyPond music typesetter
6 (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
9 #include "meter-reg.hh"
11 #include "command-request.hh"
12 #include "score-reg.hh"
14 Meter_register::Meter_register()
18 default_grouping_
= Rhythmic_grouping(MInterval(0,4),4); // ugh
22 Meter_register::fill_staff_info(Staff_info
&inf
)
25 inf
.rhythmic_C_
= &default_grouping_
;
29 Meter_register::do_try_request(Request
*r
)
33 if (r
->command() && r
->command()->timing()) {
35 Timing_req
* tr_l
= r
->command()->timing();
36 Meter_change_req
*m_l
= tr_l
->meterchange();
40 int b_i
= m_l
->beats_i_
;
41 int o_i
= m_l
->one_beat_i_
;
42 if (! time_
.allow_meter_change_b() )
43 tr_l
->warning("Meter change not allowed here");
45 time_
.set_meter(b_i
, o_i
);
47 Rhythmic_grouping(MInterval(0,Moment(b_i
, o_i
)), b_i
);
49 } else if (tr_l
->partial()) {
50 Moment m
= tr_l
->partial()->duration_
;
51 String error
= time_
.try_set_partial_str(m
);
56 } else if (tr_l
->barcheck()) {
57 if (time_
.whole_in_measure_
) {
58 tr_l
->warning( "Barcheck failed");
60 time_
.whole_in_measure_
= 0; // resync
61 time_
.error_b_
= true;
64 } else if (tr_l
->cadenza()) {
65 time_
.set_cadenza(tr_l
->cadenza()->on_b_
);
67 } else if (tr_l
->measuregrouping()) {
68 default_grouping_
= parse_grouping(
69 tr_l
->measuregrouping()->beat_i_arr_
,
70 tr_l
->measuregrouping()->elt_length_arr_
);
79 Meter_register::do_creation_processing()
81 time_
.when_
= get_staff_info().when();
85 Meter_register::do_process_requests()
89 args
.push(meter_req_l_
->beats_i_
);
90 args
.push(meter_req_l_
->one_beat_i_
);
92 meter_p_
= new Meter(args
);
96 announce_element(Score_elem_info(meter_p_
, meter_req_l_
) );
100 Meter_register::do_pre_move_processing()
103 typeset_breakable_item(meter_p_
);
108 Register_group_register
* reg_l
= daddy_reg_l_
;
109 while (reg_l
->daddy_reg_l_
) {
110 reg_l
= reg_l
->daddy_reg_l_
;
113 assert( reg_l
->name() == Score_register::static_name());
114 if (!time_
.cadenza_b_
)
115 ((Score_register
*)reg_l
)->add_moment_to_process( time_
.next_bar_moment());
119 Meter_register::do_post_move_processing()
121 time_
.add( get_staff_info().when() - time_
.when_
);
124 IMPLEMENT_STATIC_NAME(Meter_register
);
125 ADD_THIS_REGISTER(Meter_register
);
126 IMPLEMENT_IS_TYPE_B1(Meter_register
,Request_register
);