]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/pitch.hh
* lily/lyric-phrasing-engraver.cc: remove
[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--2004 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_diff (SCM pitch, SCM  root);
82 SCM ly_pitch_transpose (SCM p, SCM delta);
83 DECLARE_UNSMOB(Pitch,pitch);
84
85 #include "compare.hh"
86 INSTANTIATE_COMPARE (Pitch, Pitch::compare);
87
88 int compare (Array<Pitch>*, Array<Pitch>*);
89 extern SCM pitch_less_proc;
90 Pitch interval (Pitch const & from , Pitch const & to );
91
92 #endif /* MUSICAL_PITCH_HH */
93
94