]> git.donarmstrong.com Git - lilypond.git/blob - lily/musical-request.cc
65b72214044e01fa8ba25c4a75ab044287f9aa0a
[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 #include "music-list.hh"
13
14 void
15 Span_req::do_print () const
16 {
17 #ifndef NPRINT
18   DOUT << span_dir_;
19 #endif
20 }
21
22 Tremolo_req::Tremolo_req ()
23 {
24   type_i_ = 0;
25 }
26
27 void
28 Tremolo_req::do_print () const
29 {
30 #ifndef NPRINT
31   DOUT << "type " << type_i_ << '\n';
32 #endif
33 }
34
35
36
37
38 void
39 Melodic_req::transpose (Musical_pitch delta)
40 {
41   pitch_.transpose (delta);
42   
43   if (abs (pitch_.accidental_i_) > 2)
44     {
45         warning (_f ("transposition by %s makes accidental larger than two",
46           delta.str ()));
47     }
48 }
49
50
51
52 bool
53 Melodic_req::do_equal_b (Request*r) const
54 {
55   Melodic_req* m= dynamic_cast <Melodic_req *> (r);
56   return m&& !compare (*m, *this);
57 }
58
59 int
60 Melodic_req::compare (Melodic_req const &m1 , Melodic_req const&m2)
61 {
62   return Musical_pitch::compare (m1.pitch_, m2.pitch_);
63 }
64
65 void
66 Melodic_req::do_print () const
67 {
68   pitch_.print ();
69 }
70
71
72
73
74 int
75 Rhythmic_req::compare (Rhythmic_req const &r1, Rhythmic_req const &r2)
76 {
77   return (r1.length_mom () - r2.length_mom ());
78 }
79
80 bool
81 Rhythmic_req::do_equal_b (Request*r) const
82 {
83   Rhythmic_req* rh = dynamic_cast <Rhythmic_req *> (r);
84
85   return rh && !compare (*this, *rh);
86 }
87
88 void
89 Rhythmic_req::do_print () const
90 {
91 #ifndef NPRINT
92   DOUT << "duration { " <<duration_.str () << "}";
93 #endif
94 }
95
96
97 Moment
98 Rhythmic_req::length_mom () const
99 {
100   return duration_.length_mom ();
101 }
102
103 void
104 Rhythmic_req::compress (Moment m)
105 {
106   duration_.compress (m);
107 }
108
109 void
110 Lyric_req::do_print () const
111 {
112 #ifndef NPRINT
113   Rhythmic_req::do_print ();
114   DOUT <<  "text = " << text_str_;
115 #endif
116 }
117
118
119 bool
120 Note_req::do_equal_b (Request*r) const
121 {
122   Note_req *n = dynamic_cast<Note_req*> (r);
123   return n&& Rhythmic_req::do_equal_b (n) && Melodic_req::do_equal_b (n);
124 }
125
126
127 Note_req::Note_req ()
128 {
129   cautionary_b_ = false;
130   forceacc_b_ = false;
131 }
132
133
134
135 void
136 Note_req::do_print () const
137 {
138 #ifndef NPRINT
139   Melodic_req::do_print ();
140   if (cautionary_b_)
141     {
142         DOUT << " force cautionary accidental\n";
143     }
144   else if (forceacc_b_)
145     {
146         DOUT << " force accidental\n";
147     }
148   Rhythmic_req::do_print ();
149 #endif
150 }
151
152
153 bool
154 Span_req::do_equal_b (Request*r) const
155 {
156   Span_req * s = dynamic_cast <Span_req *> (r);
157   return s && span_dir_ == s->span_dir_;
158 }
159
160 Span_req::Span_req ()
161 {
162   span_dir_ = CENTER;
163 }
164
165
166 void
167 Text_script_req::do_print () const
168 {
169   DOUT << "text" << text_str_
170        << ", style = " << style_str_;
171 }
172
173 bool
174 Text_script_req::do_equal_b (Request *r) const
175 {
176   Text_script_req * t  = dynamic_cast<Text_script_req*>(r);
177   return t && t->text_str_ == text_str_ && t->style_str_ == style_str_;
178 }
179
180 void
181 Articulation_req::do_print () const
182 {
183   DOUT << articulation_str_;
184 }
185
186 bool
187 Articulation_req::do_equal_b (Request*r) const
188 {
189   Articulation_req * a = dynamic_cast<Articulation_req*>(r);
190   
191   return a &&  articulation_str_ == a->articulation_str_;
192 }