]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/musical-pitch.hh
release: 1.0.8
[lilypond.git] / lily / include / musical-pitch.hh
1 /*   
2   musical-pitch.hh -- declare Musical_pitch
3   
4   source file of the GNU LilyPond music typesetter
5   
6   (c) 1998 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 "input.hh"
15
16 /** A "tonal" pitch. This is a pitch as it figures in diatonal western
17    music (12 semitones in an octave), as opposed to a frequence in Hz
18    or a integer number of semitones.
19
20    It is not Music because, it has no duration associated.
21 */
22 struct Musical_pitch : public Input
23 {
24   Musical_pitch ();
25
26   /// 0 is c, 6 is b
27   int notename_i_;
28   /// 0 is central c
29   int octave_i_;
30   /// 0 natural, 1 sharp, etc
31   int accidental_i_;
32
33   void init () ;
34   Musical_pitch to_relative_octave (Musical_pitch);
35   void transpose (Musical_pitch);
36   static int compare (Musical_pitch const&,Musical_pitch const&);
37   /// return large part of interval from central c
38   int steps() const;
39   /// return pitch from central c (in halfnotes)
40   int semitone_pitch() const; 
41   void up_to (int);
42   void down_to (int);
43   String str () const;
44   void print () const;
45 };
46
47 #include "compare.hh"
48 INSTANTIATE_COMPARE(Musical_pitch, Musical_pitch::compare);
49
50 #endif /* MUSICAL_PITCH_HH */
51