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 "musical-request.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
40 mtor << name() << " {";
49 Span_req::do_print() const
61 Request::Request(Request const&src)
64 defined_ch_c_l_ = src.defined_ch_c_l_;
67 Spacing_req::Spacing_req()
74 Spacing_req::do_print()const
77 mtor << "next " << next << "dist " << distance << "strength\n";
82 Blank_req::do_print()const
84 Spacing_req::do_print();
87 Melodic_req::Melodic_req()
95 Melodic_req::transpose(Melodic_req const & delta)
97 octave_i_ += delta.octave_i_;
98 notename_i_ += delta.notename_i_;
99 while (notename_i_ >= 7 ) {
103 accidental_i_ += delta.accidental_i_;
104 if (abs(accidental_i_) > 2) {
105 warning("transposition makes accidental larger than 2",
106 delta.defined_ch_c_l_);
111 Melodic_req::do_print() const
114 mtor << "notename: " << notename_i_ << " acc: " <<accidental_i_<<" oct: "<< octave_i_;
119 Melodic_req::height() const
121 return notename_i_ + octave_i_*7;
125 should be settable from input to allow "viola"-mode
127 static Byte pitch_byte_a[ 7 ] = { 0, 2, 4, 5, 7, 9, 11 };
130 Melodic_req::pitch() const
132 return pitch_byte_a[ notename_i_ % 7 ] + accidental_i_ + octave_i_ * 12;
143 Plet_req::do_print() const
146 mtor << "plet: " << type_c_ << ": " << dur_i_ << "/" << type_i_;
150 /* *************** */
152 Rhythmic_req::compare(Rhythmic_req const &r1, Rhythmic_req const &r2)
154 return sign(r1.duration() - r2.duration());
156 Rhythmic_req::Rhythmic_req(int b, int d)
163 Rhythmic_req::Rhythmic_req()
171 Rhythmic_req::do_print() const
174 mtor << "ball: " << balltype ;
179 mtor<<", plet factor"<<plet_factor<<"\n";
185 Rhythmic_req::duration() const {
186 return wholes(balltype,dots)*plet_factor;
188 /* *************** */
190 Lyric_req::Lyric_req(Text_def* def_p)
193 def_p->align_i_ = 0; // centre
194 dir_i_ = -1; // lyrics below (invisible) staff
198 Lyric_req::do_print() const
200 Rhythmic_req::do_print();
201 Text_req::do_print();
204 /* *************** */
210 Note_req::do_print() const
213 mtor << " forceacc_b_ " << forceacc_b_ << '\n';
214 Melodic_req::do_print();
215 Rhythmic_req::do_print();
218 /* *************** */
220 Rest_req::do_print() const
222 Rhythmic_req::do_print();
225 /* *************** */
231 void Beam_req::do_print()const{}
232 /* *************** */
233 void Slur_req::do_print()const{}
234 /* *************** */
236 Span_req:: compare(Span_req const &r1, Span_req const &r2)
238 return r1.spantype - r2.spantype;
246 /* *************** */
247 Script_req::Script_req(int d , Script_def*def)
254 Script_req::compare(Script_req const &d1, Script_req const &d2)
256 return d1.dir_i_ == d2.dir_i_ &&
257 d1.scriptdef_p_->compare(*d2.scriptdef_p_);
260 Script_req::Script_req(Script_req const &s)
264 scriptdef_p_ = new Script_def(*s.scriptdef_p_);
268 Script_req::do_print() const
270 mtor << " dir " << dir_i_ ;
271 scriptdef_p_->print();
275 Script_req::~Script_req()
279 /* *************** */
281 Text_req:: compare(Text_req const &r1, Text_req const &r2)
283 bool b1 = (r1.dir_i_ == r2.dir_i_);
284 bool b2 = (r1.tdef_p_ ->compare(*r2.tdef_p_));
287 Text_req::~Text_req()
293 Text_req::Text_req(Text_req const& src)
295 tdef_p_ = new Text_def(*src.tdef_p_);
299 Text_req::Text_req(int dir_i, Text_def* tdef_p)
306 Text_req::do_print() const
310 mtor << " dir " << dir_i_ ;
315 /* *************** */
318 Skip_req::duration() const
324 Skip_req::do_print() const
328 mtor << "duration: " << duration();
338 return (Voice*)elt_l_->voice_l_;
340 /* *************** */
343 Subtle_req::do_print() const
346 mtor << " subtime " << subtime_;
351 Dynamic_req::do_print() const
353 Subtle_req::do_print();
357 Absolute_dynamic_req::do_print() const
359 Dynamic_req::do_print();
360 mtor << " loudness_" <<loudness_;
364 Dynamic_req::loudness_str(Loudness l)
367 case FFF: return "fff";
368 case FF: return "ff";
370 case MF: return "mf";
371 case MP: return "mp";
373 case PP: return "pp";
374 case PPP: return "ppp";
380 Absolute_dynamic_req::Absolute_dynamic_req()
386 Span_dynamic_req::Span_dynamic_req()
392 Span_dynamic_req::do_print()const
395 Span_req::do_print();
396 mtor << "louder/louder: " <<dynamic_dir_i_;