]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/pitch.hh
string() -> to_string()
[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--2002 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
17    music (12 semitones in an octave), as opposed to a frequency in Hz
18    or a 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    - abstract out the representation of alteration_, so we can
29    put micropitches (quartertones, etc.) in the Pitch object
30 */
31 class Pitch
32 {
33 private:                                // fixme
34   /*
35     TODO: use SCM
36    */
37
38     /// 0 is c, 6 is b
39   int notename_;
40   
41   /// 0 natural, 1 sharp, etc
42   int alteration_;
43
44   /// 0 is central c
45   int octave_;
46  
47   void transpose (Pitch);
48   void up_to (int);
49   void down_to (int);
50   void normalise ();
51
52 public:
53   
54   int get_octave () const;
55   int get_notename () const;
56   int get_alteration () const;
57
58   Pitch (int octave, int notename,int accidental);
59   Pitch ();
60
61   Pitch transposed (Pitch) const;
62   Pitch to_relative_octave (Pitch) const;
63
64   static int compare (Pitch const&,Pitch const&);
65   /// return large part of interval from central c
66   int steps () const;
67   /// return pitch from central c (in halfnotes)
68   int semitone_pitch () const; 
69   String to_string () const;
70
71   SCM smobbed_copy () const;
72   DECLARE_SCHEME_CALLBACK (less_p, (SCM a, SCM b));
73   DECLARE_SIMPLE_SMOBS (Pitch,);
74 };
75
76 SCM ly_pitch_transpose (SCM p, SCM delta);
77 DECLARE_UNSMOB(Pitch,pitch);
78
79 #include "compare.hh"
80 INSTANTIATE_COMPARE (Pitch, Pitch::compare);
81
82 int compare (Array<Pitch>*, Array<Pitch>*);
83 extern SCM pitch_less_proc;
84 Pitch interval (Pitch const & from , Pitch const & to );
85
86 #endif /* MUSICAL_PITCH_HH */
87
88