]> git.donarmstrong.com Git - lilypond.git/blob - lily/musical-request.cc
d91e6d35ec12abad9c815af85c9c127d288e2c6e
[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
15 Tremolo_req::Tremolo_req ()
16 {
17   type_i_ = 0;
18 }
19
20
21 void
22 Melodic_req::transpose (Musical_pitch delta)
23 {
24   pitch_.transpose (delta);
25   
26   if (abs (pitch_.accidental_i_) > 2)
27     {
28         warning (_f ("Transposition by %s makes accidental larger than two",
29           delta.str ()));
30     }
31 }
32
33
34
35 bool
36 Melodic_req::do_equal_b (Request const* r) const
37 {
38   Melodic_req const* m= dynamic_cast <Melodic_req const*> (r);
39   return m&& !compare (*m, *this);
40 }
41
42 int
43 Melodic_req::compare (Melodic_req const &m1 , Melodic_req const&m2)
44 {
45   return Musical_pitch::compare (m1.pitch_, m2.pitch_);
46 }
47
48
49
50
51
52 int
53 Rhythmic_req::compare (Rhythmic_req const &r1, Rhythmic_req const &r2)
54 {
55   return (r1.length_mom () - r2.length_mom ());
56 }
57
58 bool
59 Rhythmic_req::do_equal_b (Request const* r) const
60 {
61   Rhythmic_req const* rh = dynamic_cast <Rhythmic_req const*> (r);
62
63   return rh && !compare (*this, *rh);
64 }
65
66
67
68 Moment
69 Rhythmic_req::length_mom () const
70 {
71   return duration_.length_mom ();
72 }
73
74 void
75 Rhythmic_req::compress (Moment m)
76 {
77   duration_.compress (m);
78 }
79
80
81
82 bool
83 Note_req::do_equal_b (Request const* r) const
84 {
85   Note_req const* n = dynamic_cast<Note_req const*> (r);
86   return n&& Rhythmic_req::do_equal_b (n) && Melodic_req::do_equal_b (n);
87 }
88
89
90 Note_req::Note_req ()
91 {
92   cautionary_b_ = false;
93   forceacc_b_ = false;
94 }
95
96
97
98
99
100 bool
101 Span_req::do_equal_b (Request const*r) const
102 {
103   Span_req const* s = dynamic_cast <Span_req const*> (r);
104   return s && span_dir_ == s->span_dir_;
105 }
106
107 Span_req::Span_req ()
108 {
109   span_dir_ = CENTER;
110 }
111
112
113 bool
114 Text_script_req::do_equal_b (Request const* r) const
115 {
116   Text_script_req const* t  = dynamic_cast<Text_script_req const*> (r);
117   return t && gh_equal_p (text_, t->text_);
118 }
119
120
121 bool
122 Articulation_req::do_equal_b (Request const* r) const
123 {
124   Articulation_req const* a = dynamic_cast<Articulation_req const*> (r);
125   
126   return a &&  articulation_str_ == a->articulation_str_;
127 }
128
129
130 Script_req::Script_req ()
131 {
132   set_direction (CENTER);
133 }