]> git.donarmstrong.com Git - lilypond.git/blob - lily/command-request.cc
* input/trip.ly (fugaIILeft): add arpeggio
[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
11 #include "musical-request.hh"
12
13
14
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}")
18 {
19   SCM newlist = SCM_EOL;
20   Pitch *p = unsmob_pitch (pitch);
21   
22   for (SCM s = l; gh_pair_p (s); s = ly_cdr (s))
23     {
24       SCM key = ly_caar (s);
25       SCM alter = ly_cdar (s);
26       if (gh_pair_p (key))
27         {
28           Pitch orig (gh_scm2int (ly_car (key)),
29                               gh_scm2int (ly_cdr (key)),
30                               gh_scm2int (alter));
31
32           orig.transpose (*p);
33
34           SCM key = gh_cons (scm_int2num (orig.get_octave ()),
35                              scm_int2num (orig.notename_));
36
37           newlist = gh_cons (gh_cons (key, scm_int2num (orig.alteration_)),
38                              newlist);
39         }
40       else if (gh_number_p (key))
41         {
42           Pitch orig (0, gh_scm2int (key), gh_scm2int (alter));
43           orig.transpose (*p);
44
45           key =scm_int2num (orig.notename_);
46           alter = scm_int2num (orig.alteration_);
47           newlist = gh_cons (gh_cons (key, alter), newlist);
48         }
49     }
50   return scm_reverse_x (newlist, SCM_EOL);
51 }
52
53 void
54 Key_change_req::transpose (Pitch p)
55 {
56   SCM pa = get_mus_property ("pitch-alist");
57
58   set_mus_property ("pitch-alist", transpose_key_alist (pa, p.smobbed_copy()));
59 }
60
61
62 bool
63 alist_equal_p (SCM a, SCM b)
64 {
65   for (SCM s = a;
66        gh_pair_p (s); s = ly_cdr (s))
67     {
68       SCM key = ly_caar (s);
69       SCM val = ly_cdar (s);
70       SCM l = scm_assoc (key, b);
71
72       if (l == SCM_BOOL_F
73           || !gh_equal_p ( ly_cdr (l), val))
74
75         return false;
76     }
77   return true;
78 }
79
80 bool
81 Key_change_req::do_equal_b (Request const * m )const
82 {
83   Key_change_req const * kc =dynamic_cast<Key_change_req const*> (m);
84
85   if(!kc)
86     return false;
87   return alist_equal_p (get_mus_property ("pitch-alist"),
88                         kc->get_mus_property ("pitch-alist"));
89 }
90
91
92
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);
99 ADD_MUSIC (Span_req);
100 ADD_MUSIC (Text_script_req);
101 ADD_MUSIC (Tremolo_req);