2 request.cc -- implement all musical requests.
4 source file of the LilyPond music typesetter
6 (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
9 #include "musicalrequest.hh"
12 #include "script-def.hh"
13 #include "text-def.hh"
15 #include "voice-element.hh"
18 Stem_req::do_print() const
20 Rhythmic_req::do_print();
21 mtor
<< "dir : " << dir_i_
;
24 Stem_req::Stem_req(int s
, int d
)
31 void Musical_req::do_print()const{}
32 void Request::do_print() const{}
37 Request::print() const
39 mtor
<< name() << " {";
47 Span_req::do_print() const
59 Request::Request(Request
const&src
)
62 defined_ch_c_l_
= src
.defined_ch_c_l_
;
65 Spacing_req::Spacing_req()
72 Spacing_req::do_print()const
74 mtor
<< "next " << next
<< "dist " << distance
<< "strength\n";
78 Blank_req::do_print()const
80 Spacing_req::do_print();
83 Melodic_req::Melodic_req()
92 Melodic_req::do_print() const
94 mtor
<< "notename: " << notename_i_
<< " acc: " <<accidental_i_
<<" oct: "<< octave_i_
;
98 Melodic_req::height() const
100 return notename_i_
+ octave_i_
*7;
104 should be settable from input to allow "viola"-mode
106 static Byte pitch_byte_a
[ 7 ] = { 0, 2, 4, 5, 7, 9, 11 };
109 Melodic_req::pitch() const
111 return pitch_byte_a
[ notename_i_
% 7 ] + accidental_i_
+ octave_i_
* 12;
122 Plet_req::do_print() const
124 mtor
<< "plet: " << type_c_
<< ": " << dur_i_
<< "/" << type_i_
;
127 /* *************** */
129 Rhythmic_req::compare(const Rhythmic_req
&r1
, const Rhythmic_req
&r2
)
131 return sign(r1
.duration() - r2
.duration());
133 Rhythmic_req::Rhythmic_req(int b
, int d
)
140 Rhythmic_req::Rhythmic_req()
148 Rhythmic_req::do_print() const
150 mtor
<< "ball: " << balltype
;
155 mtor
<<", plet factor"<<plet_factor
<<"\n";
160 Rhythmic_req::duration() const {
161 return wholes(balltype
,dots
)*plet_factor
;
163 /* *************** */
165 Lyric_req::Lyric_req(Text_def
* def_p
)
168 def_p
->align_i_
= 0; // centre
169 dir_i_
= -1; // lyrics below (invisible) staff
173 Lyric_req::do_print() const
175 Rhythmic_req::do_print();
176 Text_req::do_print();
178 /* *************** */
180 Note_req::do_print() const
182 Melodic_req::do_print();
183 Rhythmic_req::do_print();
185 /* *************** */
187 Rest_req::do_print() const
189 Rhythmic_req::do_print();
192 /* *************** */
198 void Beam_req::do_print()const{}
199 /* *************** */
200 void Slur_req::do_print()const{}
201 /* *************** */
203 Span_req:: compare(const Span_req
&r1
, const Span_req
&r2
)
205 return r1
.spantype
- r2
.spantype
;
213 /* *************** */
214 Script_req::Script_req(int d
, Script_def
*def
)
221 Script_req::compare(const Script_req
&d1
, const Script_req
&d2
)
223 return d1
.dir_i_
== d2
.dir_i_
&&
224 d1
.scriptdef_p_
->compare(*d2
.scriptdef_p_
);
227 Script_req::Script_req(Script_req
const &s
)
231 scriptdef_p_
= new Script_def(*s
.scriptdef_p_
);
235 Script_req::do_print() const
237 mtor
<< " dir " << dir_i_
;
238 scriptdef_p_
->print();
242 Script_req::~Script_req()
246 /* *************** */
248 Text_req:: compare(const Text_req
&r1
, const Text_req
&r2
)
250 bool b1
= (r1
.dir_i_
== r2
.dir_i_
);
251 bool b2
= (r1
.tdef_p_
->compare(*r2
.tdef_p_
));
254 Text_req::~Text_req()
260 Text_req::Text_req(Text_req
const& src
)
262 tdef_p_
= new Text_def(*src
.tdef_p_
);
266 Text_req::Text_req(int dir_i
, Text_def
* tdef_p
)
273 Text_req::do_print() const
275 mtor
<< " dir " << dir_i_
;
279 /* *************** */
282 Skip_req::duration() const
288 Skip_req::do_print() const
290 mtor
<< "duration: " << duration();
299 return (Voice
*)elt_l_
->voice_l_
;