lilypond-1.1.55
[lilypond.git] / lily / musical-request.cc
blob2716822b030c5e7ca1d4aa71a570ba8ce6653655
1 /*
2 request.cc -- implement all musical requests.
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 */
9 #include "musical-request.hh"
10 #include "misc.hh"
11 #include "debug.hh"
13 #include "music-list.hh"
15 void
16 Span_req::do_print () const
18 #ifndef NPRINT
19 DOUT << span_dir_;
20 #endif
23 Tremolo_req::Tremolo_req ()
25 type_i_ = 0;
28 void
29 Tremolo_req::do_print () const
31 #ifndef NPRINT
32 DOUT << "type " << type_i_ << '\n';
33 #endif
39 void
40 Melodic_req::transpose (Musical_pitch delta)
42 pitch_.transpose (delta);
44 if (abs (pitch_.accidental_i_) > 2)
46 warning (_f ("transposition by %s makes accidental larger than two",
47 delta.str ()));
53 bool
54 Melodic_req::do_equal_b (Request*r) const
56 Melodic_req* m= dynamic_cast <Melodic_req *> (r);
57 return m&& !compare (*m, *this);
60 int
61 Melodic_req::compare (Melodic_req const &m1 , Melodic_req const&m2)
63 return Musical_pitch::compare (m1.pitch_, m2.pitch_);
66 void
67 Melodic_req::do_print () const
69 pitch_.print ();
75 int
76 Rhythmic_req::compare (Rhythmic_req const &r1, Rhythmic_req const &r2)
78 return (r1.length_mom () - r2.length_mom ());
81 bool
82 Rhythmic_req::do_equal_b (Request*r) const
84 Rhythmic_req* rh = dynamic_cast <Rhythmic_req *> (r);
86 return rh && !compare (*this, *rh);
89 void
90 Rhythmic_req::do_print () const
92 #ifndef NPRINT
93 DOUT << "duration { " <<duration_.str () << "}";
94 #endif
98 Moment
99 Rhythmic_req::length_mom () const
101 return duration_.length_mom ();
104 void
105 Rhythmic_req::compress (Moment m)
107 duration_.compress (m);
110 void
111 Lyric_req::do_print () const
113 #ifndef NPRINT
114 Rhythmic_req::do_print ();
115 DOUT << "text = " << text_str_;
116 #endif
120 bool
121 Note_req::do_equal_b (Request*r) const
123 Note_req *n = dynamic_cast<Note_req*> (r);
124 return n&& Rhythmic_req::do_equal_b (n) && Melodic_req::do_equal_b (n);
128 Note_req::Note_req ()
130 cautionary_b_ = false;
131 forceacc_b_ = false;
136 void
137 Note_req::do_print () const
139 #ifndef NPRINT
140 Melodic_req::do_print ();
141 if (cautionary_b_)
143 DOUT << " force cautionary accidental\n";
145 else if (forceacc_b_)
147 DOUT << " force accidental\n";
149 Rhythmic_req::do_print ();
150 #endif
154 bool
155 Span_req::do_equal_b (Request*r) const
157 Span_req * s = dynamic_cast <Span_req *> (r);
158 return s && span_dir_ == s->span_dir_;
161 Span_req::Span_req ()
163 span_dir_ = CENTER;
167 void
168 Text_script_req::do_print () const
170 DOUT << "text" << text_str_
171 << ", style = " << style_str_;
174 bool
175 Text_script_req::do_equal_b (Request *r) const
177 Text_script_req * t = dynamic_cast<Text_script_req*>(r);
178 return t && t->text_str_ == text_str_ && t->style_str_ == style_str_;
181 void
182 Articulation_req::do_print () const
184 DOUT << articulation_str_;
187 bool
188 Articulation_req::do_equal_b (Request*r) const
190 Articulation_req * a = dynamic_cast<Articulation_req*>(r);
192 return a && articulation_str_ == a->articulation_str_;