]> git.donarmstrong.com Git - lilypond.git/blob - lily/command-request.cc
1aaaea84eac453af8abe05465444adbe3ba44aac
[lilypond.git] / lily / command-request.cc
1 /*
2   command-request.cc -- implement non-musical reqs
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 "command-request.hh"
10 #include "debug.hh"
11 #include "musical-request.hh"
12
13
14 Bar_req::Bar_req (String s)
15 {
16   set_mus_property ("type", ly_str02scm (s.ch_C()));
17 }
18
19 bool
20 Barcheck_req::do_equal_b (Request const *r) const
21 {
22   Barcheck_req  const*b = dynamic_cast<Barcheck_req const*> (r);
23   return b;
24 }
25
26 void
27 Clef_change_req::do_print () const
28 {
29 #ifndef NPRINT
30   DEBUG_OUT << clef_str_ ;
31 #endif
32 }
33
34 Clef_change_req::Clef_change_req (String s)
35 {
36   clef_str_ = s;
37 }
38
39
40 void
41 Time_signature_change_req::do_print () const
42 {
43 #ifndef NPRINT
44   DEBUG_OUT << beats_i_ << "/" << one_beat_i_;
45 #endif
46 }
47
48 bool
49 Time_signature_change_req::do_equal_b (Request const *r) const
50 {
51   Time_signature_change_req  const* m
52     = dynamic_cast <Time_signature_change_req  const*> (r);
53
54   return m && m->beats_i_ == beats_i_
55     && one_beat_i_ == m->one_beat_i_;
56 }
57
58 Time_signature_change_req::Time_signature_change_req ()
59 {
60   beats_i_ = 0;
61   one_beat_i_ =0;
62 }
63
64
65 Tempo_req::Tempo_req ()
66 {
67   metronome_i_ = 60;
68   dur_. durlog_i_ = 2;
69 }
70
71 void
72 Tempo_req::do_print () const
73 {
74   DEBUG_OUT << dur_.str () << " = " << metronome_i_;
75 }
76
77
78 bool
79 Tempo_req::do_equal_b (Request const *r) const
80 {
81   Tempo_req const *t = dynamic_cast <Tempo_req const*> (r);
82
83   return t&& t->dur_.length_mom ()== dur_.length_mom () && metronome_i_ == t->metronome_i_;
84 }
85
86
87
88
89 bool
90 Key_change_req::do_equal_b (Request const * req) const
91 {
92   Key_change_req const * k = dynamic_cast<Key_change_req const*> (req);
93   return k && scm_equal_p (get_mus_property ("pitch-alist"), k->get_mus_property ("pitch-alist"));
94 }
95
96
97 void
98 Key_change_req::transpose (Musical_pitch p)
99 {
100   SCM newlist = SCM_EOL;
101   SCM pa = get_mus_property ("pitch-alist");
102   for (SCM s = pa; gh_pair_p (s); s = gh_cdr (s))
103     {
104       SCM k = gh_caar (s);
105
106       if (gh_pair_p (k))
107         {
108           Musical_pitch orig (gh_list (gh_car (k), gh_cdr (k), gh_cdr (s), SCM_UNDEFINED));
109
110           orig.transpose (p);
111
112           SCM key = gh_cons (gh_int2scm (orig.octave_i_),
113                              gh_int2scm (orig.notename_i_));
114
115           newlist = gh_cons (gh_cons (key, gh_int2scm (orig.accidental_i_)),
116                              newlist);
117         }
118       else if (gh_number_p (k))
119         {
120           Musical_pitch orig (gh_list (gh_int2scm (0), k, gh_cdar (s), SCM_UNDEFINED));
121           orig.transpose (p);
122
123           SCM key =gh_int2scm (orig.notename_i_);
124           newlist = gh_cons (gh_cons (key, gh_int2scm (orig.accidental_i_)),
125                              newlist);
126         }
127     }
128
129   set_mus_property ("pitch-alist", newlist);
130 }
131
132 Break_req::Break_req ()
133 {
134 }
135
136
137 bool
138 Mark_req::do_equal_b (Request const * r) const
139 {
140   Mark_req const * other = dynamic_cast<Mark_req const*> (r);
141   return other && scm_equal_p (other->get_mus_property ("mark-label"),
142                                get_mus_property ("mark-label"));
143 }