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
70 Request::Request(Request const&src)
73 defined_ch_C_ = src.defined_ch_C_;
76 Spacing_req::Spacing_req()
82 IMPLEMENT_STATIC_NAME(Spacing_req);
85 Spacing_req::do_print()const
88 mtor << "next " << next << "dist " << distance << "strength\n";
92 IMPLEMENT_STATIC_NAME(Blank_req);
95 Blank_req::do_print()const
97 Spacing_req::do_print();
100 Melodic_req::Melodic_req()
108 Melodic_req::transpose(Melodic_req const & delta)
110 octave_i_ += delta.octave_i_;
111 notename_i_ += delta.notename_i_;
112 while (notename_i_ >= 7 ) {
116 accidental_i_ += delta.accidental_i_;
117 if (abs(accidental_i_) > 2) {
118 warning("transposition makes accidental larger than 2",
119 delta.defined_ch_C_);
123 IMPLEMENT_STATIC_NAME(Melodic_req);
126 Melodic_req::do_print() const
129 mtor << "notename: " << notename_i_ << " acc: " <<accidental_i_<<" oct: "<< octave_i_;
134 Melodic_req::height() const
136 return notename_i_ + octave_i_*7;
140 should be settable from input to allow "viola"-mode
142 static Byte pitch_byte_a[ 7 ] = { 0, 2, 4, 5, 7, 9, 11 };
145 Melodic_req::pitch() const
147 return pitch_byte_a[ notename_i_ % 7 ] + accidental_i_ + octave_i_ * 12;
157 IMPLEMENT_STATIC_NAME(Plet_req);
160 Plet_req::do_print() const
163 mtor << "plet: " << type_c_ << ": " << dur_i_ << "/" << type_i_;
167 /* *************** */
169 Rhythmic_req::compare(Rhythmic_req const &r1, Rhythmic_req const &r2)
171 return sign(r1.duration() - r2.duration());
175 Rhythmic_req::set_duration(Duration d)
180 Rhythmic_req::Rhythmic_req()
184 IMPLEMENT_STATIC_NAME(Rhythmic_req);
187 Rhythmic_req::do_print() const
190 mtor << "duration { " <<duration_.str() << "}";
196 Rhythmic_req::duration() const {
197 return duration_.length();
199 /* *************** */
201 Lyric_req::Lyric_req(Text_def* def_p)
204 def_p->align_i_ = 0; // centre
205 dir_i_ = -1; // lyrics below (invisible) staff
208 IMPLEMENT_STATIC_NAME(Lyric_req);
211 Lyric_req::do_print() const
213 Rhythmic_req::do_print();
214 Text_req::do_print();
217 /* *************** */
222 IMPLEMENT_STATIC_NAME(Note_req);
225 Note_req::do_print() const
228 Melodic_req::do_print();
230 mtor << " force accidental\n";
232 Rhythmic_req::do_print();
235 /* *************** */
236 IMPLEMENT_STATIC_NAME(Rest_req);
239 Rest_req::do_print() const
241 Rhythmic_req::do_print();
244 /* *************** */
249 IMPLEMENT_STATIC_NAME(Beam_req);
251 Beam_req::do_print()const{}
252 /* *************** */
253 IMPLEMENT_STATIC_NAME(Slur_req);
255 Slur_req::do_print()const{}
256 /* *************** */
258 Span_req:: compare(Span_req const &r1, Span_req const &r2)
260 return r1.spantype - r2.spantype;
268 /* *************** */
269 Script_req::Script_req(int d , Script_def*def)
276 Script_req::compare(Script_req const &d1, Script_req const &d2)
278 return d1.dir_i_ == d2.dir_i_ &&
279 d1.scriptdef_p_->compare(*d2.scriptdef_p_);
282 Script_req::Script_req(Script_req const &s)
286 scriptdef_p_ = new Script_def(*s.scriptdef_p_);
289 IMPLEMENT_STATIC_NAME(Script_req);
292 Script_req::do_print() const
294 mtor << " dir " << dir_i_ ;
295 scriptdef_p_->print();
299 Script_req::~Script_req()
303 /* *************** */
305 Text_req:: compare(Text_req const &r1, Text_req const &r2)
307 bool b1 = (r1.dir_i_ == r2.dir_i_);
308 bool b2 = (r1.tdef_p_ ->compare(*r2.tdef_p_));
311 Text_req::~Text_req()
317 Text_req::Text_req(Text_req const& src)
319 tdef_p_ = new Text_def(*src.tdef_p_);
323 Text_req::Text_req(int dir_i, Text_def* tdef_p)
329 IMPLEMENT_STATIC_NAME(Text_req);
332 Text_req::do_print() const
336 mtor << " dir " << dir_i_ ;
341 /* *************** */
344 Skip_req::duration() const
349 IMPLEMENT_STATIC_NAME(Skip_req);
352 Skip_req::do_print() const
356 mtor << "duration: " << duration();
366 return (Voice*)elt_l_->voice_l_;
368 /* *************** */
370 IMPLEMENT_STATIC_NAME(Subtle_req);
373 Subtle_req::do_print() const
376 mtor << " subtime " << subtime_;
380 IMPLEMENT_STATIC_NAME(Dynamic_req);
383 Dynamic_req::do_print() const
385 Subtle_req::do_print();
388 IMPLEMENT_STATIC_NAME(Absolute_dynamic_req);
391 Absolute_dynamic_req::do_print() const
393 Dynamic_req::do_print();
394 mtor << " loudness " <<loudness_;
398 Dynamic_req::loudness_str(Loudness l)
401 case FFF: return "fff";
402 case FF: return "ff";
404 case MF: return "mf";
405 case MP: return "mp";
407 case PP: return "pp";
408 case PPP: return "ppp";
414 Absolute_dynamic_req::Absolute_dynamic_req()
420 Span_dynamic_req::Span_dynamic_req()
425 IMPLEMENT_STATIC_NAME(Span_dynamic_req);
428 Span_dynamic_req::do_print()const
431 Span_req::do_print();
432 mtor << "louder/louder: " <<dynamic_dir_i_;