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"
18 IMPLEMENT_IS_TYPE_B1 (Musical_req,Request);
20 Musical_req::do_print () const{}
22 Tie_req::do_print () const{}
26 IMPLEMENT_IS_TYPE_B1(Span_req,Request);
28 IMPLEMENT_IS_TYPE_B2(Musical_span_req, Span_req, Musical_span_req);
31 Musical_span_req::do_print () const
33 Span_req::do_print ();
38 Span_req::do_print () const
45 IMPLEMENT_IS_TYPE_B1 (Spacing_req,Request);
47 Spacing_req::Spacing_req ()
55 Spacing_req::do_print () const
58 DOUT << "next " << next << "dist " << distance << "strength\n";
62 IMPLEMENT_IS_TYPE_B1 (Abbreviation_req, Musical_req);
64 Abbreviation_req::Abbreviation_req ()
70 Abbreviation_req::do_print () const
73 DOUT << "type " << type_i_ << '\n';
78 IMPLEMENT_IS_TYPE_B2 (Blank_req,Spacing_req,Rhythmic_req);
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",
102 IMPLEMENT_IS_TYPE_B1 (Melodic_req,Musical_req);
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);
138 IMPLEMENT_IS_TYPE_B1 (Rhythmic_req,Musical_req);
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);
164 IMPLEMENT_IS_TYPE_B1 (Lyric_req,Rhythmic_req);
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;
187 IMPLEMENT_IS_TYPE_B2 (Note_req,Melodic_req,Rhythmic_req);
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 ();
206 IMPLEMENT_IS_TYPE_B1 (Rest_req, Rhythmic_req);
209 Rest_req::do_print () const
211 Rhythmic_req::do_print ();
217 IMPLEMENT_IS_TYPE_B1 (Multi_measure_rest_req, Rhythmic_req);
220 Multi_measure_rest_req::do_print () const
222 Rhythmic_req::do_print ();
227 IMPLEMENT_IS_TYPE_B1 (Beam_req,Span_req);
231 Beam_req::do_print () const
236 IMPLEMENT_IS_TYPE_B1 (Abbreviation_beam_req, Span_req);
238 Abbreviation_beam_req::Abbreviation_beam_req ()
244 Abbreviation_beam_req::do_print () const
248 IMPLEMENT_IS_TYPE_B1 (Slur_req,Span_req);
250 Slur_req::do_print () const
254 IMPLEMENT_IS_TYPE_B1 (Plet_req,Span_req);
256 Plet_req::Plet_req ()
262 Plet_req::do_print () const
268 Span_req::do_equal_b (Request*r) const
270 Span_req * s = dynamic_cast <Span_req *> (r);
271 return s && spantype == s->spantype;
274 Span_req::Span_req ()
279 Script_req::Script_req (Script_req const&s)
282 scriptdef_p_ = s.scriptdef_p_ ? s.scriptdef_p_->clone () : 0;
291 Script_req::do_equal_b (Request*r) const
293 Script_req * s = dynamic_cast <Script_req *> (r);
295 return s&& scriptdef_p_->equal_b (*s->scriptdef_p_);
298 Script_req::Script_req ()
305 IMPLEMENT_IS_TYPE_B1 (Script_req,Request);
308 Script_req::do_print () const
311 DOUT << " dir " << dir_;
312 scriptdef_p_->print ();
317 Musical_script_req::do_print () const
319 Script_req::do_print ();
323 IMPLEMENT_IS_TYPE_B2 (Musical_script_req,Musical_req, Script_req);
326 Script_req::~Script_req ()
332 Text_req::~Text_req ()
338 Text_req::Text_req (Text_req const& src)
340 tdef_p_ = new Text_def (*src.tdef_p_);
344 Text_req::Text_req (int dir_i, Text_def* tdef_p)
346 dir_ = Direction (dir_i);
351 IMPLEMENT_IS_TYPE_B1 (Text_req,Musical_req);
354 Text_req::do_print () const
357 DOUT << " dir " << dir_;
364 IMPLEMENT_IS_TYPE_B1 (Skip_req,Musical_req);
367 Skip_req::do_print () const
371 DOUT << "duration: " << duration ();
377 IMPLEMENT_IS_TYPE_B1 (Dynamic_req,Musical_req);
380 Dynamic_req::do_print () const
382 Musical_req::do_print ();
386 IMPLEMENT_IS_TYPE_B1 (Absolute_dynamic_req,Musical_req);
389 Absolute_dynamic_req::do_print () const
392 Dynamic_req::do_print ();
393 DOUT << " loudness " <<loudness_str ();
399 Absolute_dynamic_req::do_equal_b (Request *r) const
401 Absolute_dynamic_req *a = dynamic_cast <Absolute_dynamic_req *> (r);
402 return a&& loudness_ == a->loudness_;
406 Dynamic_req::loudness_static_str (Loudness l)
410 case FFF: return "fff";
411 case FF: return "ff";
413 case MF: return "mf";
414 case MP: return "mp";
416 case PP: return "pp";
417 case PPP: return "ppp";
418 case FP: return "fp";
419 case SF: return "sf";
420 case SFZ: return "sfz";
426 Absolute_dynamic_req::loudness_str () const
428 String str = loudness_static_str (loudness_);
432 warning (_f ("never heard of dynamic scale `\%s\', assuming %s",
440 Absolute_dynamic_req::Absolute_dynamic_req ()
448 Span_dynamic_req::do_equal_b (Request *req) const
450 Span_dynamic_req * s = dynamic_cast <Span_dynamic_req *> (req);
452 return s&& Span_req::do_equal_b (req) && s->dynamic_dir_ == dynamic_dir_;
455 Span_dynamic_req::Span_dynamic_req ()
457 dynamic_dir_ = CENTER;
461 IMPLEMENT_IS_TYPE_B1 (Span_dynamic_req,Musical_req);
464 Span_dynamic_req::do_print () const
467 Span_req::do_print ();
468 DOUT << "softer/louder: " << dynamic_dir_;
473 IMPLEMENT_IS_TYPE_B1 (Tie_req,Musical_req);