2 request.cc -- implement all musical requests.
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--1998 Han-Wen Nienhuys <hanwen@cs.uu.nl>
9 #include "musical-request.hh"
12 #include "script-def.hh"
13 #include "text-def.hh"
14 #include "music-list.hh"
20 Musical_req::do_print () const{}
22 Tie_req::do_print () const{}
31 Musical_span_req::do_print () const
33 Span_req::do_print ();
38 Span_req::do_print () const
47 Spacing_req::Spacing_req ()
55 Spacing_req::do_print () const
58 DOUT << "next " << next << "dist " << distance << "strength\n";
64 Abbreviation_req::Abbreviation_req ()
70 Abbreviation_req::do_print () const
73 DOUT << "type " << type_i_ << '\n';
81 Blank_req::do_print () const
83 Spacing_req::do_print ();
86 Melodic_req::Melodic_req ()
91 Melodic_req::transpose (Musical_pitch delta)
93 pitch_.transpose (delta);
95 if (abs (pitch_.accidental_i_) > 2)
97 warning (_f ("transposition by %s makes accidental larger than two",
105 Melodic_req::do_equal_b (Request*r) const
107 Melodic_req* m= dynamic_cast <Melodic_req *> (r);
108 return m&& !compare (*m, *this);
112 Melodic_req::compare (Melodic_req const &m1 , Melodic_req const&m2)
114 return Musical_pitch::compare (m1.pitch_, m2.pitch_);
118 Melodic_req::do_print () const
124 Rhythmic_req::compare (Rhythmic_req const &r1, Rhythmic_req const &r2)
126 return (r1.duration () - r2.duration ());
130 Rhythmic_req::do_equal_b (Request*r) const
132 Rhythmic_req* rh = dynamic_cast <Rhythmic_req *> (r);
134 return rh && !compare (*this, *rh);
141 Rhythmic_req::do_print () const
144 DOUT << "duration { " <<duration_.str () << "}";
150 Rhythmic_req::duration () const
152 return duration_.length ();
156 Rhythmic_req::compress (Moment m)
158 duration_.compress (m);
167 Lyric_req::do_print () const
169 Rhythmic_req::do_print ();
174 Note_req::do_equal_b (Request*r) const
176 Note_req *n = dynamic_cast<Note_req*> (r);
177 return n&& Rhythmic_req::do_equal_b (n) && Melodic_req::do_equal_b (n);
181 Note_req::Note_req ()
183 cautionary_b_ = false;
190 Note_req::do_print () const
193 Melodic_req::do_print ();
196 DOUT << " force cautionary accidental\n";
198 else if (forceacc_b_)
200 DOUT << " force accidental\n";
202 Rhythmic_req::do_print ();
209 Rest_req::do_print () const
211 Rhythmic_req::do_print ();
220 Multi_measure_rest_req::do_print () const
222 Rhythmic_req::do_print ();
231 Beam_req::do_print () const
238 Abbreviation_beam_req::Abbreviation_beam_req ()
244 Abbreviation_beam_req::do_print () const
250 Slur_req::do_print () const
256 Plet_req::Plet_req ()
262 Plet_req::do_print () const
266 Extender_req::Extender_req ()
271 Extender_req::do_print () const
277 Span_req::do_equal_b (Request*r) const
279 Span_req * s = dynamic_cast <Span_req *> (r);
280 return s && spantype == s->spantype;
283 Span_req::Span_req ()
288 Script_req::Script_req (Script_req const&s)
291 scriptdef_p_ = s.scriptdef_p_ ? s.scriptdef_p_->clone () : 0;
300 Script_req::do_equal_b (Request*r) const
302 Script_req * s = dynamic_cast <Script_req *> (r);
304 return s&& scriptdef_p_->equal_b (*s->scriptdef_p_);
307 Script_req::Script_req ()
317 Script_req::do_print () const
320 DOUT << " dir " << dir_;
321 scriptdef_p_->print ();
326 Musical_script_req::do_print () const
328 Script_req::do_print ();
335 Script_req::~Script_req ()
341 Text_req::~Text_req ()
347 Text_req::Text_req (Text_req const& src)
349 tdef_p_ = new Text_def (*src.tdef_p_);
353 Text_req::Text_req (int dir_i, Text_def* tdef_p)
355 dir_ = Direction (dir_i);
363 Text_req::do_print () const
366 DOUT << " dir " << dir_;
376 Skip_req::do_print () const
380 DOUT << "duration: " << duration ();
389 Dynamic_req::do_print () const
391 Musical_req::do_print ();
398 Absolute_dynamic_req::do_print () const
401 Dynamic_req::do_print ();
402 DOUT << " loudness " <<loudness_str ();
408 Absolute_dynamic_req::do_equal_b (Request *r) const
410 Absolute_dynamic_req *a = dynamic_cast <Absolute_dynamic_req *> (r);
411 return a&& loudness_ == a->loudness_;
415 Dynamic_req::loudness_static_str (Loudness l)
419 case FFF: return "fff";
420 case FF: return "ff";
422 case MF: return "mf";
423 case MP: return "mp";
425 case PP: return "pp";
426 case PPP: return "ppp";
427 case FP: return "fp";
428 case SF: return "sf";
429 case SFZ: return "sfz";
435 Absolute_dynamic_req::loudness_str () const
437 String str = loudness_static_str (loudness_);
441 warning (_f ("never heard of dynamic scale `\%s\', assuming %s",
449 Absolute_dynamic_req::Absolute_dynamic_req ()
457 Span_dynamic_req::do_equal_b (Request *req) const
459 Span_dynamic_req * s = dynamic_cast <Span_dynamic_req *> (req);
461 return s&& Span_req::do_equal_b (req) && s->dynamic_dir_ == dynamic_dir_;
464 Span_dynamic_req::Span_dynamic_req ()
466 dynamic_dir_ = CENTER;
473 Span_dynamic_req::do_print () const
476 Span_req::do_print ();
477 DOUT << "softer/louder: " << dynamic_dir_;