]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/pitch.hh
* Documentation/topdocs/NEWS.texi (Top): add quarter tones.
[lilypond.git] / lily / include / pitch.hh
1 /*   
2   pitch.hh -- declare Pitch
3   
4   source file of the GNU LilyPond music typesetter
5   
6   (c)  1998--2003 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7   
8  */
9
10 #ifndef MUSICAL_PITCH_HH
11 #define MUSICAL_PITCH_HH
12
13 #include "lily-proto.hh"
14 #include "smobs.hh"
15
16 /** A "tonal" pitch. This is a pitch used in diatonal western music
17    (24 quartertones in an octave), as opposed to a frequency in Hz or a
18    integer number of semitones.
19
20   Pitch is lexicographically ordered by (octave, notename,
21     alteration).    
22   
23
24    TODO:
25
26    - add indeterminate octaves, so it can be used as a key in keySigature
27
28 */
29 class Pitch
30 {
31 private:                                // fixme
32   /*
33     TODO: use SCM
34    */
35
36   int notename_;
37   int alteration_;
38   int octave_;
39  
40   void transpose (Pitch);
41   void up_to (int);
42   void down_to (int);
43   void normalise ();
44
45 public:
46   
47   int get_octave () const;
48   int get_notename () const;
49   int get_alteration () const;
50
51   Pitch (int octave, int notename,int accidental);
52   Pitch ();
53
54   Pitch transposed (Pitch) const;
55   Pitch to_relative_octave (Pitch) const;
56
57   static int compare (Pitch const&,Pitch const&);
58
59   int steps () const;
60   int semitone_pitch () const; 
61   int quartertone_pitch () const; 
62   String to_string () const;
63
64   SCM smobbed_copy () const;
65   DECLARE_SCHEME_CALLBACK (less_p, (SCM a, SCM b));
66   DECLARE_SIMPLE_SMOBS (Pitch,);
67 };
68
69 enum {
70   DOUBLE_FLAT = -4,
71   THREE_Q_FLAT,
72   FLAT ,
73   SEMI_FLAT,
74   NATURAL,
75   SEMI_SHARP,
76   SHARP ,
77   THREE_Q_SHARP,
78   DOUBLE_SHARP  ,
79 };
80
81 SCM ly_pitch_transpose (SCM p, SCM delta);
82 DECLARE_UNSMOB(Pitch,pitch);
83
84 #include "compare.hh"
85 INSTANTIATE_COMPARE (Pitch, Pitch::compare);
86
87 int compare (Array<Pitch>*, Array<Pitch>*);
88 extern SCM pitch_less_proc;
89 Pitch interval (Pitch const & from , Pitch const & to );
90
91 #endif /* MUSICAL_PITCH_HH */
92
93