]> git.donarmstrong.com Git - lilypond.git/blob - lily/musical-request.cc
release: 1.1.45
[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 << span_dir_;
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 #ifndef NPRINT
114   Rhythmic_req::do_print ();
115   DOUT <<  "text = " << text_str_;
116 #endif
117 }
118
119
120 bool
121 Note_req::do_equal_b (Request*r) const
122 {
123   Note_req *n = dynamic_cast<Note_req*> (r);
124   return n&& Rhythmic_req::do_equal_b (n) && Melodic_req::do_equal_b (n);
125 }
126
127
128 Note_req::Note_req ()
129 {
130   cautionary_b_ = false;
131   forceacc_b_ = false;
132 }
133
134
135
136 void
137 Note_req::do_print () const
138 {
139 #ifndef NPRINT
140   Melodic_req::do_print ();
141   if (cautionary_b_)
142     {
143         DOUT << " force cautionary accidental\n";
144     }
145   else if (forceacc_b_)
146     {
147         DOUT << " force accidental\n";
148     }
149   Rhythmic_req::do_print ();
150 #endif
151 }
152
153
154 bool
155 Span_req::do_equal_b (Request*r) const
156 {
157   Span_req * s = dynamic_cast <Span_req *> (r);
158   return s && span_dir_ == s->span_dir_;
159 }
160
161 Span_req::Span_req ()
162 {
163   span_dir_ = CENTER;
164 }
165
166
167 void
168 Text_script_req::do_print () const
169 {
170   DOUT << "text" << text_str_
171        << ", style = " << style_str_;
172 }
173
174 bool
175 Text_script_req::do_equal_b (Request *r) const
176 {
177   Text_script_req * t  = dynamic_cast<Text_script_req*>(r);
178   return t && t->text_str_ == text_str_ && t->style_str_ == style_str_;
179 }
180
181 void
182 Articulation_req::do_print () const
183 {
184   DOUT << articulation_str_;
185 }
186
187 bool
188 Articulation_req::do_equal_b (Request*r) const
189 {
190   Articulation_req * a = dynamic_cast<Articulation_req*>(r);
191   
192   return a &&  articulation_str_ == a->articulation_str_;
193 }