]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/musical-pitch.hh
079de76c8f650127501de88e1a6d82c7bdccc512
[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--2000 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 #include "lily-guile.hh" // we need SCM
16
17 /** A "tonal" pitch. This is a pitch as it figures in diatonal western
18    music (12 semitones in an octave), as opposed to a frequence in Hz
19    or a integer number of semitones.
20
21    It is not Music because, it has no duration associated.
22 */
23 struct Musical_pitch : public Input
24 {
25   Musical_pitch (int notename=0, int accidental=0, int octave=0);
26
27   /// construct from  '(octave name acc)
28   Musical_pitch (SCM);
29
30   /// 0 is c, 6 is b
31   int notename_i_;
32   
33   /// 0 natural, 1 sharp, etc
34   int accidental_i_;
35
36   /// 0 is central c
37   int octave_i_;
38
39   Musical_pitch to_relative_octave (Musical_pitch);
40   void transpose (Musical_pitch);
41   static int compare (Musical_pitch const&,Musical_pitch const&);
42   /// return large part of interval from central c
43   int steps() const;
44   /// return pitch from central c (in halfnotes)
45   int semitone_pitch() const; 
46   void up_to (int);
47   void down_to (int);
48   String str () const;
49   void print () const;
50   SCM to_scm () const;
51 };
52
53 #include "compare.hh"
54 INSTANTIATE_COMPARE(Musical_pitch, Musical_pitch::compare);
55
56 int compare (Array<Musical_pitch>*, Array<Musical_pitch>*);
57
58 #endif /* MUSICAL_PITCH_HH */
59