]> git.donarmstrong.com Git - lilypond.git/blob - lily/musical-request.cc
cdcda7ac0160ae4c634aa92163c461e23d9a774b
[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--2000 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   DEBUG_OUT << 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   DEBUG_OUT << "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 const* r) const
51 {
52   Melodic_req const* m= dynamic_cast <Melodic_req const*> (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 const* r) const
79 {
80   Rhythmic_req const* rh = dynamic_cast <Rhythmic_req const*> (r);
81
82   return rh && !compare (*this, *rh);
83 }
84
85 void
86 Rhythmic_req::do_print () const
87 {
88 #ifndef NPRINT
89   DEBUG_OUT << "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   DEBUG_OUT <<  "text = " << text_str_;
112 #endif
113 }
114
115
116 bool
117 Note_req::do_equal_b (Request const* r) const
118 {
119   Note_req const* n = dynamic_cast<Note_req const*> (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         DEBUG_OUT << " force cautionary accidental\n";
140     }
141   else if (forceacc_b_)
142     {
143         DEBUG_OUT << " force accidental\n";
144     }
145   Rhythmic_req::do_print ();
146 #endif
147 }
148
149
150 bool
151 Span_req::do_equal_b (Request const*r) const
152 {
153   Span_req const* s = dynamic_cast <Span_req const*> (r);
154   return s && span_dir_ == s->span_dir_;
155 }
156
157 Span_req::Span_req ()
158 {
159   span_dir_ = CENTER;
160 }
161
162 void
163 Text_script_req::do_print () const
164 {
165   DEBUG_OUT << "text" << text_str_
166        << ", style = " << style_str_;
167 }
168
169 bool
170 Text_script_req::do_equal_b (Request const* r) const
171 {
172   Text_script_req const* t  = dynamic_cast<Text_script_req const*> (r);
173   return t && t->text_str_ == text_str_ && t->style_str_ == style_str_;
174 }
175
176 void
177 Articulation_req::do_print () const
178 {
179   DEBUG_OUT << articulation_str_;
180 }
181
182 bool
183 Articulation_req::do_equal_b (Request const* r) const
184 {
185   Articulation_req const* a = dynamic_cast<Articulation_req const*> (r);
186   
187   return a &&  articulation_str_ == a->articulation_str_;
188 }
189
190
191 Script_req::Script_req ()
192 {
193   set_direction (CENTER);
194 }