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"
17 IMPLEMENT_STATIC_NAME(Stem_req);
19 Stem_req::do_print() const
22 Rhythmic_req::do_print();
23 mtor << "dir : " << dir_i_;
33 IMPLEMENT_STATIC_NAME(Musical_req);
35 Musical_req::do_print()const{}
37 IMPLEMENT_STATIC_NAME(Request);
39 void Request::do_print() const{}
44 Request::print() const
47 mtor << name() << " {";
55 IMPLEMENT_STATIC_NAME(Span_req);
58 Span_req::do_print() const
69 Request::Request(Request const&src)
75 Spacing_req::Spacing_req()
81 IMPLEMENT_STATIC_NAME(Spacing_req);
84 Spacing_req::do_print()const
87 mtor << "next " << next << "dist " << distance << "strength\n";
91 IMPLEMENT_STATIC_NAME(Blank_req);
94 Blank_req::do_print()const
96 Spacing_req::do_print();
99 Melodic_req::Melodic_req()
107 Melodic_req::transpose(Melodic_req const & delta)
109 octave_i_ += delta.octave_i_;
110 notename_i_ += delta.notename_i_;
111 while (notename_i_ >= 7 ) {
115 accidental_i_ += delta.accidental_i_;
116 if (abs(accidental_i_) > 2) {
117 delta.warning("transposition makes accidental larger than 2");
121 IMPLEMENT_STATIC_NAME(Melodic_req);
124 Melodic_req::do_print() const
127 mtor << "notename: " << notename_i_ << " acc: " <<accidental_i_<<" oct: "<< octave_i_;
132 Melodic_req::height() const
134 return notename_i_ + octave_i_*7;
138 should be settable from input to allow "viola"-mode
140 static Byte pitch_byte_a[ 7 ] = { 0, 2, 4, 5, 7, 9, 11 };
143 Melodic_req::pitch() const
145 return pitch_byte_a[ notename_i_ % 7 ] + accidental_i_ + octave_i_ * 12;
155 IMPLEMENT_STATIC_NAME(Plet_req);
158 Plet_req::do_print() const
161 mtor << "plet: " << type_c_ << ": " << dur_i_ << "/" << type_i_;
165 /* *************** */
167 Rhythmic_req::compare(Rhythmic_req const &r1, Rhythmic_req const &r2)
169 return sign(r1.duration() - r2.duration());
173 Rhythmic_req::set_duration(Duration d)
178 Rhythmic_req::Rhythmic_req()
182 IMPLEMENT_STATIC_NAME(Rhythmic_req);
185 Rhythmic_req::do_print() const
188 mtor << "duration { " <<duration_.str() << "}";
194 Rhythmic_req::duration() const {
195 return duration_.length();
197 /* *************** */
199 Lyric_req::Lyric_req(Text_def* def_p)
202 def_p->align_i_ = 0; // centre
203 dir_i_ = -1; // lyrics below (invisible) staff
206 IMPLEMENT_STATIC_NAME(Lyric_req);
209 Lyric_req::do_print() const
211 Rhythmic_req::do_print();
212 Text_req::do_print();
215 /* *************** */
220 IMPLEMENT_STATIC_NAME(Note_req);
223 Note_req::do_print() const
226 Melodic_req::do_print();
228 mtor << " force accidental\n";
230 Rhythmic_req::do_print();
233 /* *************** */
234 IMPLEMENT_STATIC_NAME(Rest_req);
237 Rest_req::do_print() const
239 Rhythmic_req::do_print();
242 /* *************** */
247 IMPLEMENT_STATIC_NAME(Beam_req);
249 Beam_req::do_print()const{}
250 /* *************** */
251 IMPLEMENT_STATIC_NAME(Slur_req);
253 Slur_req::do_print()const{}
254 /* *************** */
256 Span_req:: compare(Span_req const &r1, Span_req const &r2)
258 return r1.spantype - r2.spantype;
266 /* *************** */
267 Script_req::Script_req(int d , Script_def*def)
274 Script_req::compare(Script_req const &d1, Script_req const &d2)
276 return d1.dir_i_ == d2.dir_i_ &&
277 d1.scriptdef_p_->compare(*d2.scriptdef_p_);
280 Script_req::Script_req(Script_req const &s)
284 scriptdef_p_ = new Script_def(*s.scriptdef_p_);
287 IMPLEMENT_STATIC_NAME(Script_req);
290 Script_req::do_print() const
292 mtor << " dir " << dir_i_ ;
293 scriptdef_p_->print();
297 Script_req::~Script_req()
301 /* *************** */
303 Text_req:: compare(Text_req const &r1, Text_req const &r2)
305 bool b1 = (r1.dir_i_ == r2.dir_i_);
306 bool b2 = (r1.tdef_p_ ->compare(*r2.tdef_p_));
309 Text_req::~Text_req()
315 Text_req::Text_req(Text_req const& src)
317 tdef_p_ = new Text_def(*src.tdef_p_);
321 Text_req::Text_req(int dir_i, Text_def* tdef_p)
327 IMPLEMENT_STATIC_NAME(Text_req);
330 Text_req::do_print() const
334 mtor << " dir " << dir_i_ ;
339 /* *************** */
342 Skip_req::duration() const
347 IMPLEMENT_STATIC_NAME(Skip_req);
350 Skip_req::do_print() const
354 mtor << "duration: " << duration();
364 return (Voice*)elt_l_->voice_C_;
366 /* *************** */
368 IMPLEMENT_STATIC_NAME(Subtle_req);
371 Subtle_req::do_print() const
374 mtor << " subtime " << subtime_;
378 IMPLEMENT_STATIC_NAME(Dynamic_req);
381 Dynamic_req::do_print() const
383 Subtle_req::do_print();
386 IMPLEMENT_STATIC_NAME(Absolute_dynamic_req);
389 Absolute_dynamic_req::do_print() const
391 Dynamic_req::do_print();
392 mtor << " loudness " <<loudness_;
396 Dynamic_req::loudness_str(Loudness l)
399 case FFF: return "fff";
400 case FF: return "ff";
402 case MF: return "mf";
403 case MP: return "mp";
405 case PP: return "pp";
406 case PPP: return "ppp";
412 Absolute_dynamic_req::Absolute_dynamic_req()
418 Span_dynamic_req::Span_dynamic_req()
423 IMPLEMENT_STATIC_NAME(Span_dynamic_req);
426 Span_dynamic_req::do_print()const
429 Span_req::do_print();
430 mtor << "louder/louder: " <<dynamic_dir_i_;