]> git.donarmstrong.com Git - lilypond.git/blob - lily/newkey-def.cc
patch::: 1.3.59.uu2.jcn1
[lilypond.git] / lily / newkey-def.cc
1 /*   
2   newkey-def.cc --  implement Newkey_def
3   
4   source file of the GNU LilyPond music typesetter
5   
6   (c) 2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7   
8  */
9
10 #include "newkey-def.hh"
11 #include "misc.hh"
12
13
14 Newkey_def::Newkey_def()
15 {
16   pitch_alist_ = SCM_EOL;
17 }
18
19 void
20 Newkey_def::transpose (Musical_pitch p) 
21 {
22   SCM newlist = SCM_EOL;
23   for (SCM s = pitch_alist_; gh_pair_p (s); s = gh_cdr (s))
24     {
25       SCM k = gh_caar (s);
26
27       if (gh_pair_p (k))
28         {
29           Musical_pitch orig (gh_list (gh_car (k), gh_cdr (k), gh_cdr (s), SCM_UNDEFINED));
30
31           orig.transpose (p);
32
33           SCM key = gh_cons (gh_int2scm (orig.octave_i_),
34                              gh_int2scm (orig.notename_i_));
35
36           newlist = gh_cons (gh_cons (key, gh_int2scm (orig.accidental_i_)),
37                              newlist);
38         }
39       else if (gh_number_p (k))
40         {
41           Musical_pitch orig (gh_list (gh_int2scm (0), k, gh_cdar (s), SCM_UNDEFINED));
42           orig.transpose (p);
43
44           SCM key =gh_int2scm (orig.notename_i_);
45           newlist = gh_cons (gh_cons (key, gh_int2scm (orig.accidental_i_)),
46                              newlist);
47         }
48     }
49
50   pitch_alist_ = newlist;
51 }