2 commandrequest.cc -- implement Nonmusical reqs
4 source file of the GNU LilyPond music typesetter
6 (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
9 #include "command-request.hh"
11 #include "musical-request.hh"
14 Command_script_req::do_print() const
16 Command_script_req::Command_script_req(){}
18 IMPLEMENT_IS_TYPE_B1(Command_script_req
,Command_req
);
21 IMPLEMENT_IS_TYPE_B1(Cadenza_req
, Timing_req
);
24 Cadenza_req::do_print() const
32 Cadenza_req::do_equal_b (Request
*r
) const
34 Cadenza_req
*cad
= r
->command()->timing ()->cadenza ();
36 return cad
->on_b_
== on_b_
;
39 Cadenza_req::Cadenza_req (bool b
)
47 Bar_req::do_equal_b (Request
*r
) const
49 Bar_req
* b
= r
->command()->bar ();
50 return type_str_
== b
->type_str_
;
54 IMPLEMENT_IS_TYPE_B1(Bar_req
,Command_req
);
57 Bar_req::do_print() const
62 Bar_req::Bar_req (String s
)
67 Partial_measure_req::Partial_measure_req (Moment m
)
73 Partial_measure_req::do_equal_b (Request
* r
) const
75 Partial_measure_req
*p
= r
->command()->timing ()->partial ();
77 return p
->duration_
== duration_
;
81 IMPLEMENT_IS_TYPE_B1(Timing_req
,Command_req
);
84 Timing_req::do_print() const{}
87 IMPLEMENT_IS_TYPE_B1(Command_req
,Request
);
90 Command_req::do_print() const{}
92 IMPLEMENT_IS_TYPE_B1(Disallow_break_req
,Command_req
);
95 Disallow_break_req::do_print() const
100 IMPLEMENT_IS_TYPE_B1(Barcheck_req
,Timing_req
);
103 Barcheck_req::do_print() const{}
106 Barcheck_req::do_equal_b (Request
*) const
110 /* *************** */
112 IMPLEMENT_IS_TYPE_B1(Clef_change_req
,Command_req
);
115 Clef_change_req::do_print() const
122 Clef_change_req::Clef_change_req (String s
)
127 /* *************** */
130 IMPLEMENT_IS_TYPE_B1(Partial_measure_req
,Timing_req
);
133 Partial_measure_req::do_print() const
139 IMPLEMENT_IS_TYPE_B1(Meter_change_req
,Timing_req
);
142 Meter_change_req::do_print() const
145 DOUT
<< beats_i_
<< "/" << one_beat_i_
;
150 Meter_change_req::do_equal_b (Request
* r
) const
152 Meter_change_req
* m
= r
->command()->timing ()->meterchange ();
154 return m
->beats_i_
== beats_i_
155 && one_beat_i_
== m
->one_beat_i_
;
158 Meter_change_req::Meter_change_req()
165 Meter_change_req::set (int b
,int o
)
172 Tempo_req::Tempo_req()
179 Tempo_req::do_print() const
181 DOUT
<< dur_
.str() << " = " <<metronome_i_
;
183 IMPLEMENT_IS_TYPE_B1(Tempo_req
, Timing_req
);
186 Tempo_req::do_equal_b (Request
*r
) const
188 Tempo_req
*t
= r
->command()->timing ()->tempo ();
190 return t
->dur_
.length()== dur_
.length () && metronome_i_
== t
->metronome_i_
;
193 /* *************** */
196 IMPLEMENT_IS_TYPE_B1(Measure_grouping_req
,Timing_req
);
199 Measure_grouping_req::do_print() const
201 for (int i
=0; i
< elt_length_arr_
.size(); i
++)
203 DOUT
<< beat_i_arr_
[i
] <<"*" << elt_length_arr_
[i
]<<" ";
209 Measure_grouping_req::do_equal_b (Request
*) const
211 return false; // todo
214 /* *************** */
217 Key_change_req::transpose (Melodic_req
const * d
) const
219 WARN
<< _("don't know how to transpose a key. \n");
220 for (int i
=0; i
< melodic_p_arr_
.size(); i
++)
222 melodic_p_arr_
[i
]->transpose (d
);
227 IMPLEMENT_IS_TYPE_B1(Key_change_req
,Command_req
);
229 Key_change_req::squash_octaves()
231 for (int i
=0; i
< melodic_p_arr_
.size(); i
++)
233 melodic_p_arr_
[i
]->octave_i_
= 0;
238 Key_change_req::do_print() const
241 for (int i
=0; i
< melodic_p_arr_
.size(); i
++)
243 melodic_p_arr_
[i
]->print();
248 Key_change_req::Key_change_req()
251 multi_octave_b_
= false;
254 Key_change_req::Key_change_req (Key_change_req
const&c
)
256 for (int i
=0; i
< c
.melodic_p_arr_
.size(); i
++)
257 melodic_p_arr_
.push (c
.melodic_p_arr_
[i
]->clone()->musical ()->melodic ());
258 minor_b_
= c
.minor_b_
;
259 multi_octave_b_
= c
.multi_octave_b_
;
262 Key_change_req::~Key_change_req()
264 for (int i
=0; i
< melodic_p_arr_
.size(); i
++)
265 delete melodic_p_arr_
[i
];
269 Key_change_req::flats_i()
272 for (int i
= 0; i
< melodic_p_arr_
.size(); i
++)
274 Melodic_req
* mel_l
= melodic_p_arr_
[i
]->melodic();
276 if (mel_l
->accidental_i_
< 0)
277 flats_i
-= mel_l
->accidental_i_
;
283 Key_change_req::minor_b()
289 Key_change_req::sharps_i()
292 for (int i
= 0; i
< melodic_p_arr_
.size(); i
++)
294 Melodic_req
* mel_l
= melodic_p_arr_
[i
]->melodic();
296 if (mel_l
->accidental_i_
> 0)
297 sharps_i
+= mel_l
->accidental_i_
;