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);
162 Lyric_req::do_print () const
164 Rhythmic_req::do_print ();
169 Note_req::do_equal_b (Request*r) const
171 Note_req *n = dynamic_cast<Note_req*> (r);
172 return n&& Rhythmic_req::do_equal_b (n) && Melodic_req::do_equal_b (n);
176 Note_req::Note_req ()
178 cautionary_b_ = false;
185 Note_req::do_print () const
188 Melodic_req::do_print ();
191 DOUT << " force cautionary accidental\n";
193 else if (forceacc_b_)
195 DOUT << " force accidental\n";
197 Rhythmic_req::do_print ();
202 Rest_req::do_print () const
204 Rhythmic_req::do_print ();
208 Multi_measure_rest_req::do_print () const
210 Rhythmic_req::do_print ();
215 Beam_req::do_print () const
219 Abbreviation_beam_req::Abbreviation_beam_req ()
225 Abbreviation_beam_req::do_print () const
231 Slur_req::do_print () const
237 Plet_req::Plet_req ()
243 Plet_req::do_print () const
247 Extender_req::Extender_req ()
252 Extender_req::do_print () const
258 Span_req::do_equal_b (Request*r) const
260 Span_req * s = dynamic_cast <Span_req *> (r);
261 return s && spantype_ == s->spantype_;
264 Span_req::Span_req ()
269 Script_req::Script_req (Script_req const&s)
272 scriptdef_p_ = s.scriptdef_p_ ? s.scriptdef_p_->clone () : 0;
281 Script_req::do_equal_b (Request*r) const
283 Script_req * s = dynamic_cast <Script_req *> (r);
284 return s && scriptdef_p_->equal_b (*s->scriptdef_p_);
287 Script_req::Script_req ()
297 Script_req::do_print () const
300 DOUT << " dir " << dir_;
301 scriptdef_p_->print ();
306 Musical_script_req::do_print () const
308 Script_req::do_print ();
311 Script_req::~Script_req ()
317 Text_req::~Text_req ()
323 Text_req::Text_req (Text_req const& src)
325 tdef_p_ = new Text_def (*src.tdef_p_);
329 Text_req::Text_req (int dir_i, Text_def* tdef_p)
331 dir_ = Direction (dir_i);
336 Text_req::do_print () const
339 DOUT << " dir " << dir_;
345 Skip_req::do_print () const
348 DOUT << "duration: " << duration ();
353 Dynamic_req::do_print () const
355 Musical_req::do_print ();
359 Absolute_dynamic_req::do_print () const
362 Dynamic_req::do_print ();
363 DOUT << " loudness " <<loudness_str ();
368 Absolute_dynamic_req::do_equal_b (Request *r) const
370 Absolute_dynamic_req *a = dynamic_cast <Absolute_dynamic_req *> (r);
371 return a&& loudness_ == a->loudness_;
375 Dynamic_req::loudness_static_str (Loudness l)
379 case FFF: return "fff";
380 case FF: return "ff";
382 case MF: return "mf";
383 case MP: return "mp";
385 case PP: return "pp";
386 case PPP: return "ppp";
387 case FP: return "fp";
388 case SF: return "sf";
389 case SFZ: return "sfz";
395 Absolute_dynamic_req::loudness_str () const
397 String str = loudness_static_str (loudness_);
401 warning (_f ("never heard of dynamic scale `\%s\', assuming %s",
409 Absolute_dynamic_req::Absolute_dynamic_req ()
417 Span_dynamic_req::do_equal_b (Request *req) const
419 Span_dynamic_req * s = dynamic_cast <Span_dynamic_req *> (req);
421 return s&& Span_req::do_equal_b (req) && s->dynamic_dir_ == dynamic_dir_;
424 Span_dynamic_req::Span_dynamic_req ()
426 dynamic_dir_ = CENTER;
430 Span_dynamic_req::do_print () const
433 Span_req::do_print ();
434 DOUT << "softer/louder: " << dynamic_dir_;