]> git.donarmstrong.com Git - lilypond.git/blob - lily/command-request.cc
release: 1.3.93
[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
27 Clef_change_req::Clef_change_req (String s)
28 {
29   clef_str_ = s;
30 }
31
32
33 bool
34 Time_signature_change_req::do_equal_b (Request const *r) const
35 {
36   Time_signature_change_req  const* m
37     = dynamic_cast <Time_signature_change_req  const*> (r);
38
39   return m && m->beats_i_ == beats_i_
40     && one_beat_i_ == m->one_beat_i_;
41 }
42
43 Time_signature_change_req::Time_signature_change_req ()
44 {
45   beats_i_ = 0;
46   one_beat_i_ =0;
47 }
48
49
50 Tempo_req::Tempo_req ()
51 {
52   metronome_i_ = 60;
53   dur_. durlog_i_ = 2;
54 }
55
56
57
58 bool
59 Tempo_req::do_equal_b (Request const *r) const
60 {
61   Tempo_req const *t = dynamic_cast <Tempo_req const*> (r);
62
63   return t&& t->dur_.length_mom ()== dur_.length_mom () && metronome_i_ == t->metronome_i_;
64 }
65
66
67
68
69 bool
70 Key_change_req::do_equal_b (Request const * req) const
71 {
72   Key_change_req const * k = dynamic_cast<Key_change_req const*> (req);
73   return k && scm_equal_p (get_mus_property ("pitch-alist"), k->get_mus_property ("pitch-alist"));
74 }
75
76
77 void
78 Key_change_req::transpose (Musical_pitch p)
79 {
80   SCM newlist = SCM_EOL;
81   SCM pa = get_mus_property ("pitch-alist");
82   for (SCM s = pa; gh_pair_p (s); s = gh_cdr (s))
83     {
84       SCM k = gh_caar (s);
85
86       if (gh_pair_p (k))
87         {
88           Musical_pitch orig (gh_list (gh_car (k), gh_cdr (k), gh_cdr (s), SCM_UNDEFINED));
89
90           orig.transpose (p);
91
92           SCM key = gh_cons (gh_int2scm (orig.octave_i_),
93                              gh_int2scm (orig.notename_i_));
94
95           newlist = gh_cons (gh_cons (key, gh_int2scm (orig.accidental_i_)),
96                              newlist);
97         }
98       else if (gh_number_p (k))
99         {
100           Musical_pitch orig (gh_list (gh_int2scm (0), k, gh_cdar (s), SCM_UNDEFINED));
101           orig.transpose (p);
102
103           SCM key =gh_int2scm (orig.notename_i_);
104           newlist = gh_cons (gh_cons (key, gh_int2scm (orig.accidental_i_)),
105                              newlist);
106         }
107     }
108
109   set_mus_property ("pitch-alist", newlist);
110 }
111
112 Break_req::Break_req ()
113 {
114 }
115
116
117 bool
118 Mark_req::do_equal_b (Request const * r) const
119 {
120   Mark_req const * other = dynamic_cast<Mark_req const*> (r);
121   return other && scm_equal_p (other->get_mus_property ("mark-label"),
122                                get_mus_property ("mark-label"));
123 }