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