lilypond-1.4.4
[lilypond.git] / lily / command-request.cc
blobaac1ebe576fc16d628f3f26a10c83293197bc40f
1 /*
2 command-request.cc -- implement non-musical reqs
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2001 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 */
9 #include "command-request.hh"
10 #include "debug.hh"
11 #include "musical-request.hh"
13 bool
14 Barcheck_req::do_equal_b (Request const *r) const
16 Barcheck_req const*b = dynamic_cast<Barcheck_req const*> (r);
17 return b;
20 Tempo_req::Tempo_req ()
22 set_mus_property ("duration", Duration (2,0).smobbed_copy ());
25 void
26 Key_change_req::transpose (Pitch p)
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))
32 SCM key = gh_caar (s);
33 SCM alter = gh_cdar (s);
34 if (gh_pair_p (key))
36 Pitch orig (gh_scm2int (gh_car (key)),
37 gh_scm2int (gh_cdr (key)),
38 gh_scm2int (alter));
40 orig.transpose (p);
42 SCM key = gh_cons (gh_int2scm (orig.octave_i ()),
43 gh_int2scm (orig.notename_i_));
45 newlist = gh_cons (gh_cons (key, gh_int2scm (orig.alteration_i_)),
46 newlist);
48 else if (gh_number_p (key))
50 Pitch orig (0, gh_scm2int (key), gh_scm2int (alter));
51 orig.transpose (p);
53 key =gh_int2scm (orig.notename_i_);
54 alter = gh_int2scm (orig.alteration_i_);
55 newlist = gh_cons (gh_cons (key, alter), newlist);
59 set_mus_property ("pitch-alist", newlist);
63 bool
64 alist_equal_p (SCM a, SCM b)
66 for (SCM s = a;
67 gh_pair_p (s); s = gh_cdr (s))
69 SCM key = gh_caar (s);
70 SCM val = gh_cdar (s);
71 SCM l = scm_assoc (key, b);
73 if (l == SCM_BOOL_F
74 || !gh_equal_p ( gh_cdr (l), val))
76 return false;
78 return true;
81 bool
82 Key_change_req::do_equal_b (Request const * m )const
84 Key_change_req const * kc =dynamic_cast<Key_change_req const*> (m);
86 if(!kc)
87 return false;
88 return alist_equal_p (get_mus_property ("pitch-alist"),
89 kc->get_mus_property ("pitch-alist"));
94 bool
95 Mark_req::do_equal_b (Request const * r) const
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;
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);