]> git.donarmstrong.com Git - lilypond.git/blob - lily/command-request.cc
release: 1.3.148
[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--2001 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 bool
14 Barcheck_req::do_equal_b (Request const *r) const
15 {
16   Barcheck_req  const*b = dynamic_cast<Barcheck_req const*> (r);
17   return b;
18 }
19
20 Tempo_req::Tempo_req ()
21 {
22   set_mus_property ("duration", Duration (2,0).smobbed_copy ());
23 }
24
25 void
26 Key_change_req::transpose (Pitch p)
27 {
28   SCM newlist = SCM_EOL;
29   SCM pa = get_mus_property ("pitch-alist");
30   for (SCM s = pa; gh_pair_p (s); s = gh_cdr (s))
31     {
32       SCM key = gh_caar (s);
33       SCM alter = gh_cdar (s);
34       if (gh_pair_p (key))
35         {
36           Pitch orig (gh_scm2int (gh_car (key)),
37                               gh_scm2int (gh_cdr (key)),
38                               gh_scm2int (alter));
39
40           orig.transpose (p);
41
42           SCM key = gh_cons (gh_int2scm (orig.octave_i ()),
43                              gh_int2scm (orig.notename_i_));
44
45           newlist = gh_cons (gh_cons (key, gh_int2scm (orig.alteration_i_)),
46                              newlist);
47         }
48       else if (gh_number_p (key))
49         {
50           Pitch orig (0, gh_scm2int (key), gh_scm2int (alter));
51           orig.transpose (p);
52
53           key =gh_int2scm (orig.notename_i_);
54           alter = gh_int2scm (orig.alteration_i_);
55           newlist = gh_cons (gh_cons (key, alter), newlist);
56         }
57     }
58
59   set_mus_property ("pitch-alist", newlist);
60 }
61
62
63 bool
64 alist_equal_p (SCM a, SCM b)
65 {
66   for (SCM s = a;
67        gh_pair_p (s); s = gh_cdr (s))
68     {
69       SCM key = gh_caar (s);
70       SCM val = gh_cdar (s);
71       SCM l = scm_assoc (key, b);
72
73       if (l == SCM_BOOL_F
74           || !gh_equal_p ( gh_cdr (l), val))
75
76         return false;
77     }
78   return true;
79 }
80
81 bool
82 Key_change_req::do_equal_b (Request const * m )const
83 {
84   Key_change_req const * kc =dynamic_cast<Key_change_req const*> (m);
85
86   if(!kc)
87     return false;
88   return alist_equal_p (get_mus_property ("pitch-alist"),
89                         kc->get_mus_property ("pitch-alist"));
90 }
91
92
93
94 bool
95 Mark_req::do_equal_b (Request const * r) const
96 {
97   Mark_req const * other = dynamic_cast<Mark_req const*> (r);
98   return other && scm_equal_p (other->get_mus_property ("label"),
99                                get_mus_property ("label")) == SCM_BOOL_T;
100 }
101
102
103 ADD_MUSIC (Articulation_req);
104 ADD_MUSIC (Barcheck_req);
105 ADD_MUSIC (Break_req);
106 ADD_MUSIC (Breathing_sign_req);
107 ADD_MUSIC (Busy_playing_req);
108 ADD_MUSIC (Extender_req);
109 ADD_MUSIC (Glissando_req);
110 ADD_MUSIC (Hyphen_req);
111 ADD_MUSIC (Key_change_req);
112 ADD_MUSIC (Lyric_req);
113 ADD_MUSIC (Mark_req);
114 ADD_MUSIC (Melisma_playing_req);
115 ADD_MUSIC (Melisma_req);
116 ADD_MUSIC (Melodic_req);
117 ADD_MUSIC (Note_req);
118 ADD_MUSIC (Rest_req);
119 ADD_MUSIC (Rhythmic_req);
120 ADD_MUSIC (Script_req);
121 ADD_MUSIC (Skip_req);
122 ADD_MUSIC (Span_req);
123 ADD_MUSIC (Tempo_req);
124 ADD_MUSIC (Text_script_req);
125 ADD_MUSIC (Tie_req);
126 ADD_MUSIC (Tremolo_req);