2 request.cc -- implement all musical requests.
4 source file of the LilyPond music typesetter
6 (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
9 #include "musical-request.hh"
12 #include "script-def.hh"
13 #include "text-def.hh"
15 #include "voice-element.hh"
18 Stem_req::do_print() const
21 Rhythmic_req::do_print();
22 mtor << "dir : " << dir_i_;
32 void Musical_req::do_print()const{}
33 void Request::do_print() const{}
38 Request::print() const
41 mtor << name() << " {";
50 Span_req::do_print() const
62 Request::Request(Request const&src)
65 defined_ch_C_ = src.defined_ch_C_;
68 Spacing_req::Spacing_req()
75 Spacing_req::do_print()const
78 mtor << "next " << next << "dist " << distance << "strength\n";
83 Blank_req::do_print()const
85 Spacing_req::do_print();
88 Melodic_req::Melodic_req()
96 Melodic_req::transpose(Melodic_req const & delta)
98 octave_i_ += delta.octave_i_;
99 notename_i_ += delta.notename_i_;
100 while (notename_i_ >= 7 ) {
104 accidental_i_ += delta.accidental_i_;
105 if (abs(accidental_i_) > 2) {
106 warning("transposition makes accidental larger than 2",
107 delta.defined_ch_C_);
112 Melodic_req::do_print() const
115 mtor << "notename: " << notename_i_ << " acc: " <<accidental_i_<<" oct: "<< octave_i_;
120 Melodic_req::height() const
122 return notename_i_ + octave_i_*7;
126 should be settable from input to allow "viola"-mode
128 static Byte pitch_byte_a[ 7 ] = { 0, 2, 4, 5, 7, 9, 11 };
131 Melodic_req::pitch() const
133 return pitch_byte_a[ notename_i_ % 7 ] + accidental_i_ + octave_i_ * 12;
144 Plet_req::do_print() const
147 mtor << "plet: " << type_c_ << ": " << dur_i_ << "/" << type_i_;
151 /* *************** */
153 Rhythmic_req::compare(Rhythmic_req const &r1, Rhythmic_req const &r2)
155 return sign(r1.duration() - r2.duration());
159 Rhythmic_req::set_duration(Duration d)
164 Rhythmic_req::Rhythmic_req()
169 Rhythmic_req::do_print() const
172 mtor << duration_.str();
178 Rhythmic_req::duration() const {
179 return duration_.length();
181 /* *************** */
183 Lyric_req::Lyric_req(Text_def* def_p)
186 def_p->align_i_ = 0; // centre
187 dir_i_ = -1; // lyrics below (invisible) staff
191 Lyric_req::do_print() const
193 Rhythmic_req::do_print();
194 Text_req::do_print();
197 /* *************** */
203 Note_req::do_print() const
206 Melodic_req::do_print();
207 mtor << " forceacc_b_ " << forceacc_b_ << '\n';
208 Rhythmic_req::do_print();
211 /* *************** */
213 Rest_req::do_print() const
215 Rhythmic_req::do_print();
218 /* *************** */
224 void Beam_req::do_print()const{}
225 /* *************** */
226 void Slur_req::do_print()const{}
227 /* *************** */
229 Span_req:: compare(Span_req const &r1, Span_req const &r2)
231 return r1.spantype - r2.spantype;
239 /* *************** */
240 Script_req::Script_req(int d , Script_def*def)
247 Script_req::compare(Script_req const &d1, Script_req const &d2)
249 return d1.dir_i_ == d2.dir_i_ &&
250 d1.scriptdef_p_->compare(*d2.scriptdef_p_);
253 Script_req::Script_req(Script_req const &s)
257 scriptdef_p_ = new Script_def(*s.scriptdef_p_);
261 Script_req::do_print() const
263 mtor << " dir " << dir_i_ ;
264 scriptdef_p_->print();
268 Script_req::~Script_req()
272 /* *************** */
274 Text_req:: compare(Text_req const &r1, Text_req const &r2)
276 bool b1 = (r1.dir_i_ == r2.dir_i_);
277 bool b2 = (r1.tdef_p_ ->compare(*r2.tdef_p_));
280 Text_req::~Text_req()
286 Text_req::Text_req(Text_req const& src)
288 tdef_p_ = new Text_def(*src.tdef_p_);
292 Text_req::Text_req(int dir_i, Text_def* tdef_p)
299 Text_req::do_print() const
303 mtor << " dir " << dir_i_ ;
308 /* *************** */
311 Skip_req::duration() const
317 Skip_req::do_print() const
321 mtor << "duration: " << duration();
331 return (Voice*)elt_l_->voice_l_;
333 /* *************** */
336 Subtle_req::do_print() const
339 mtor << " subtime " << subtime_;
344 Dynamic_req::do_print() const
346 Subtle_req::do_print();
350 Absolute_dynamic_req::do_print() const
352 Dynamic_req::do_print();
353 mtor << " loudness_" <<loudness_;
357 Dynamic_req::loudness_str(Loudness l)
360 case FFF: return "fff";
361 case FF: return "ff";
363 case MF: return "mf";
364 case MP: return "mp";
366 case PP: return "pp";
367 case PPP: return "ppp";
373 Absolute_dynamic_req::Absolute_dynamic_req()
379 Span_dynamic_req::Span_dynamic_req()
385 Span_dynamic_req::do_print()const
388 Span_req::do_print();
389 mtor << "louder/louder: " <<dynamic_dir_i_;