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