2 command-request.cc -- implement non-musical reqs
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2002 Han-Wen Nienhuys <hanwen@cs.uu.nl>
9 #include "command-request.hh"
11 #include "musical-request.hh"
15 LY_DEFINE(transpose_key_alist,"transpose-key-alist",
16 2, 0,0, (SCM l, SCM pitch),
17 "Make a new key alist of @var{l} transposed by pitch @var{pitch}")
19 SCM newlist = SCM_EOL;
20 Pitch *p = unsmob_pitch (pitch);
22 for (SCM s = l; gh_pair_p (s); s = ly_cdr (s))
24 SCM key = ly_caar (s);
25 SCM alter = ly_cdar (s);
28 Pitch orig (gh_scm2int (ly_car (key)),
29 gh_scm2int (ly_cdr (key)),
34 SCM key = gh_cons (scm_int2num (orig.get_octave ()),
35 scm_int2num (orig.notename_));
37 newlist = gh_cons (gh_cons (key, scm_int2num (orig.alteration_)),
40 else if (gh_number_p (key))
42 Pitch orig (0, gh_scm2int (key), gh_scm2int (alter));
45 key =scm_int2num (orig.notename_);
46 alter = scm_int2num (orig.alteration_);
47 newlist = gh_cons (gh_cons (key, alter), newlist);
50 return scm_reverse_x (newlist, SCM_EOL);
54 Key_change_req::transpose (Pitch p)
56 SCM pa = get_mus_property ("pitch-alist");
58 set_mus_property ("pitch-alist", transpose_key_alist (pa, p.smobbed_copy()));
63 alist_equal_p (SCM a, SCM b)
66 gh_pair_p (s); s = ly_cdr (s))
68 SCM key = ly_caar (s);
69 SCM val = ly_cdar (s);
70 SCM l = scm_assoc (key, b);
73 || !gh_equal_p ( ly_cdr (l), val))
81 Key_change_req::do_equal_b (Request const * m )const
83 Key_change_req const * kc =dynamic_cast<Key_change_req const*> (m);
87 return alist_equal_p (get_mus_property ("pitch-alist"),
88 kc->get_mus_property ("pitch-alist"));
93 ADD_MUSIC (Articulation_req);
94 ADD_MUSIC (Key_change_req);
95 ADD_MUSIC (Lyric_req);
96 ADD_MUSIC (Porrectus_req);
97 ADD_MUSIC (Rhythmic_req);
98 ADD_MUSIC (Script_req);
100 ADD_MUSIC (Text_script_req);
101 ADD_MUSIC (Tremolo_req);