]> git.donarmstrong.com Git - lilypond.git/blob - lily/musical-request.cc
release: 1.1.38
[lilypond.git] / lily / musical-request.cc
1 /*
2   request.cc -- implement all musical requests.
3
4   source file of the GNU LilyPond music typesetter
5
6   (c)  1997--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 */
8
9 #include "musical-request.hh"
10 #include "misc.hh"
11 #include "debug.hh"
12
13 #include "music-list.hh"
14
15 void
16 Span_req::do_print () const
17 {
18 #ifndef NPRINT
19   DOUT << spantype_;
20 #endif
21 }
22
23 Abbreviation_req::Abbreviation_req ()
24 {
25   type_i_ = 0;
26 }
27
28 void
29 Abbreviation_req::do_print () const
30 {
31 #ifndef NPRINT
32   DOUT << "type " << type_i_ << '\n';
33 #endif
34 }
35
36
37
38
39 void
40 Melodic_req::transpose (Musical_pitch delta)
41 {
42   pitch_.transpose (delta);
43   
44   if (abs (pitch_.accidental_i_) > 2)
45     {
46         warning (_f ("transposition by %s makes accidental larger than two",
47           delta.str ()));
48     }
49 }
50
51
52
53 bool
54 Melodic_req::do_equal_b (Request*r) const
55 {
56   Melodic_req* m= dynamic_cast <Melodic_req *> (r);
57   return m&& !compare (*m, *this);
58 }
59
60 int
61 Melodic_req::compare (Melodic_req const &m1 , Melodic_req const&m2)
62 {
63   return Musical_pitch::compare (m1.pitch_, m2.pitch_);
64 }
65
66 void
67 Melodic_req::do_print () const
68 {
69   pitch_.print ();
70 }
71
72
73
74
75 int
76 Rhythmic_req::compare (Rhythmic_req const &r1, Rhythmic_req const &r2)
77 {
78   return (r1.length_mom () - r2.length_mom ());
79 }
80
81 bool
82 Rhythmic_req::do_equal_b (Request*r) const
83 {
84   Rhythmic_req* rh = dynamic_cast <Rhythmic_req *> (r);
85
86   return rh && !compare (*this, *rh);
87 }
88
89 void
90 Rhythmic_req::do_print () const
91 {
92 #ifndef NPRINT
93   DOUT << "duration { " <<duration_.str () << "}";
94 #endif
95 }
96
97
98 Moment
99 Rhythmic_req::length_mom () const
100 {
101   return duration_.length_mom ();
102 }
103
104 void
105 Rhythmic_req::compress (Moment m)
106 {
107   duration_.compress (m);
108 }
109
110 void
111 Lyric_req::do_print () const
112 {
113   Rhythmic_req::do_print ();
114 }
115
116
117 bool
118 Note_req::do_equal_b (Request*r) const
119 {
120   Note_req *n = dynamic_cast<Note_req*> (r);
121   return n&& Rhythmic_req::do_equal_b (n) && Melodic_req::do_equal_b (n);
122 }
123
124
125 Note_req::Note_req ()
126 {
127   cautionary_b_ = false;
128   forceacc_b_ = false;
129 }
130
131
132
133 void
134 Note_req::do_print () const
135 {
136 #ifndef NPRINT
137   Melodic_req::do_print ();
138   if (cautionary_b_)
139     {
140         DOUT << " force cautionary accidental\n";
141     }
142   else if (forceacc_b_)
143     {
144         DOUT << " force accidental\n";
145     }
146   Rhythmic_req::do_print ();
147 #endif
148 }
149
150
151 Abbreviation_beam_req::Abbreviation_beam_req ()
152 {
153   type_i_ = 0;
154 }
155
156 bool
157 Span_req::do_equal_b (Request*r) const
158 {
159   Span_req * s = dynamic_cast <Span_req *> (r);
160   return s && spantype_ == s->spantype_;
161 }
162
163 Span_req::Span_req ()
164 {
165   spantype_ = CENTER;
166 }
167
168
169 void
170 Absolute_dynamic_req::do_print () const
171 {
172 #ifndef NPRINT
173   DOUT << " loudness " <<loudness_str_ ;
174 #endif
175 }
176
177 bool
178 Absolute_dynamic_req::do_equal_b (Request *r) const
179 {
180   Absolute_dynamic_req *a = dynamic_cast <Absolute_dynamic_req *> (r);
181   return a&& loudness_str_ == a->loudness_str_;
182 }
183
184 Absolute_dynamic_req::Absolute_dynamic_req ()
185 {
186   loudness_str_ = "fm";         // yes, "illegal" on purpose.
187 }
188
189
190
191 bool
192 Span_dynamic_req::do_equal_b (Request *req) const
193 {
194   Span_dynamic_req * s = dynamic_cast <Span_dynamic_req *> (req);
195
196   return s&& Span_req::do_equal_b (req) && s->dynamic_dir_ == dynamic_dir_;
197 }
198
199 Span_dynamic_req::Span_dynamic_req ()
200 {
201   dynamic_dir_  = CENTER;
202 }
203
204 void
205 Span_dynamic_req::do_print () const
206 {
207 #ifndef NPRINT
208   Span_req::do_print ();
209   DOUT << "softer/louder: " << dynamic_dir_;
210 #endif
211 }
212
213 void
214 Text_script_req::do_print () const
215 {
216   DOUT << "text" << text_str_
217        << ", style = " << style_str_;
218 }
219
220 void
221 Articulation_req::do_print () const
222 {
223   DOUT << articulation_str_;
224 }
225
226 bool
227 Articulation_req::do_equal_b (Request*r) const
228 {
229   Articulation_req * a = dynamic_cast<Articulation_req*>(r);
230   return articulation_str_ == a->articulation_str_;
231 }