]> git.donarmstrong.com Git - lilypond.git/blob - lily/key.cc
release: 0.1.54
[lilypond.git] / lily / key.cc
1 /*
2   key.cc -- implement Key, Octave_key
3
4   source file of the GNU LilyPond music typesetter
5
6   (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
7
8   TODO
9   transposition.
10 */
11
12 #include "key.hh"
13 #include "debug.hh"
14
15 const int OCTAVES=14;           // ugh..
16 const int ZEROOCTAVE=7;
17
18
19 void
20 Octave_key::print () const
21 {
22   for (int i= 0; i < 7 ; i++)
23     DOUT << "note " << i << " acc: " << accidental_i_arr_[i] << "\n";
24 }
25
26
27
28 Octave_key::Octave_key()
29 {
30   accidental_i_arr_.set_size (7);
31   clear ();
32 }
33
34 void
35 Octave_key::clear ()
36 {
37   for (int i= 0; i < 7 ; i++)
38     accidental_i_arr_[i] = 0;
39 }
40
41 Key::Key()
42 {
43   multi_octave_b_ = false;
44   octaves.set_size (OCTAVES);
45 }
46
47 Octave_key&
48 Key::oct (int i)
49 {
50   return octaves[i+ZEROOCTAVE];    
51 }
52
53
54 void
55 Octave_key::set (int i, int a)
56 {
57   assert (a > -3 && a < 3);
58   accidental_i_arr_[i]=a;
59 }
60
61 void
62 Key::set (int o, int n , int a)
63 {
64   octaves[o + ZEROOCTAVE].set (n,a);
65 }
66
67 void
68 Key::set (int n, int a)
69 {
70   for (int i= 0; i < OCTAVES ; i++)
71     octaves[i].set (n,a);
72 }
73 void
74 Key::clear ()
75 {
76   for (int i= 0; i < OCTAVES ; i++)
77     octaves[i].clear ();
78 }
79 void
80 Key::print () const
81 {
82   for (int i= 0; i < OCTAVES ; i++)
83     {
84       DOUT << "octave " << i - ZEROOCTAVE << " Octave_key { ";
85       octaves[i].print ();
86       DOUT << "}\n";
87     }
88 }