]> git.donarmstrong.com Git - lilypond.git/blob - lily/command-request.cc
release: 1.3.107
[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 bool
15 Barcheck_req::do_equal_b (Request const *r) const
16 {
17   Barcheck_req  const*b = dynamic_cast<Barcheck_req const*> (r);
18   return b;
19 }
20
21
22
23
24 Tempo_req::Tempo_req ()
25 {
26   set_mus_property ("duration", Duration(2,0).smobbed_copy ());
27 }
28
29
30
31 bool
32 Tempo_req::do_equal_b (Request const *r) const
33 {
34   Tempo_req const *t = dynamic_cast <Tempo_req const*> (r);
35
36   return t&& t->dur_.length_mom ()== dur_.length_mom ();
37   // && metronome_i_ == t->metronome_i_;
38 }
39
40
41
42
43 bool
44 Key_change_req::do_equal_b (Request const * req) const
45 {
46   Key_change_req const * k = dynamic_cast<Key_change_req const*> (req);
47   return k && scm_equal_p (get_mus_property ("pitch-alist"), k->get_mus_property ("pitch-alist"));
48 }
49
50
51 void
52 Key_change_req::transpose (Musical_pitch p)
53 {
54   SCM newlist = SCM_EOL;
55   SCM pa = get_mus_property ("pitch-alist");
56   for (SCM s = pa; gh_pair_p (s); s = gh_cdr (s))
57     {
58       SCM key = gh_caar (s);
59       SCM alter = gh_cdar (s);
60       if (gh_pair_p (key))
61         {
62           Musical_pitch orig (gh_scm2int (gh_car (key)),
63                               gh_scm2int (gh_cdr (key)),
64                               gh_scm2int (alter));
65
66           orig.transpose (p);
67
68           SCM key = gh_cons (gh_int2scm (orig.octave_i () ),
69                              gh_int2scm (orig.notename_i_));
70
71           newlist = gh_cons (gh_cons (key, gh_int2scm (orig.alteration_i_)),
72                              newlist);
73         }
74       else if (gh_number_p (key))
75         {
76           Musical_pitch orig (0, gh_scm2int (key), gh_scm2int (alter));
77           orig.transpose (p);
78
79           key =gh_int2scm (orig.notename_i_);
80           alter = gh_int2scm (orig.alteration_i_);
81           newlist = gh_cons (gh_cons (key, alter), newlist);
82         }
83     }
84
85   set_mus_property ("pitch-alist", newlist);
86 }
87
88 Break_req::Break_req ()
89 {
90 }
91
92
93 bool
94 Mark_req::do_equal_b (Request const * r) const
95 {
96   Mark_req const * other = dynamic_cast<Mark_req const*> (r);
97   return other && scm_equal_p (other->get_mus_property ("mark-label"),
98                                get_mus_property ("mark-label"));
99 }