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