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
239 Extender_req::Extender_req ()
244 Extender_req::do_print () const
250 Span_req::do_equal_b (Request*r) const
252 Span_req * s = dynamic_cast <Span_req *> (r);
253 return s && spantype_ == s->spantype_;
256 Span_req::Span_req ()
261 Script_req::Script_req (Script_req const&s)
264 scriptdef_p_ = s.scriptdef_p_ ? s.scriptdef_p_->clone () : 0;
273 Script_req::do_equal_b (Request*r) const
275 Script_req * s = dynamic_cast <Script_req *> (r);
276 return s && scriptdef_p_->equal_b (*s->scriptdef_p_);
279 Script_req::Script_req ()
289 Script_req::do_print () const
292 DOUT << " dir " << dir_;
293 scriptdef_p_->print ();
298 Musical_script_req::do_print () const
300 Script_req::do_print ();
303 Script_req::~Script_req ()
309 Skip_req::do_print () const
312 DOUT << "duration: " << duration ();
317 Dynamic_req::do_print () const
319 Musical_req::do_print ();
323 Absolute_dynamic_req::do_print () const
326 Dynamic_req::do_print ();
327 DOUT << " loudness " <<loudness_str ();
332 Absolute_dynamic_req::do_equal_b (Request *r) const
334 Absolute_dynamic_req *a = dynamic_cast <Absolute_dynamic_req *> (r);
335 return a&& loudness_ == a->loudness_;
339 Dynamic_req::loudness_static_str (Loudness l)
343 case FFFFFF: return "ffffff";
344 case FFFFF : return "fffff";
345 case FFFF: return "ffff";
346 case FFF: return "fff";
347 case FF: return "ff";
349 case MF: return "mf";
350 case MP: return "mp";
352 case PP: return "pp";
353 case PPP: return "ppp";
354 case PPPP: return "pppp";
355 case PPPPP: return "ppppp";
356 case PPPPPP: return "pppppp";
358 case FP: return "fp";
359 case SF: return "sf";
360 case SFF: return "sff";
361 case SFZ: return "sfz";
362 case SP: return "sp";
363 case SPP: return "spp";
364 case RFZ: return "rfz";
370 Absolute_dynamic_req::loudness_str () const
372 String str = loudness_static_str (loudness_);
376 warning (_f ("never heard of dynamic scale `\%s\', assuming %s",
384 Absolute_dynamic_req::Absolute_dynamic_req ()
392 Span_dynamic_req::do_equal_b (Request *req) const
394 Span_dynamic_req * s = dynamic_cast <Span_dynamic_req *> (req);
396 return s&& Span_req::do_equal_b (req) && s->dynamic_dir_ == dynamic_dir_;
399 Span_dynamic_req::Span_dynamic_req ()
401 dynamic_dir_ = CENTER;
405 Span_dynamic_req::do_print () const
408 Span_req::do_print ();
409 DOUT << "softer/louder: " << dynamic_dir_;