]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/musical-pitch.hh
release: 1.3.107
[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 "smobs.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    
21
22    
23 */
24 class Musical_pitch
25 {
26 public:                         // fixme
27   
28   /// 0 is c, 6 is b
29   int notename_i_;
30   
31   /// 0 natural, 1 sharp, etc
32   int alteration_i_;
33
34   /// 0 is central c
35   int octave_i_;
36 public:
37
38   int octave_i () const;
39   int notename_i () const;
40   int alteration_i () const;
41
42   /*
43     Musical_pitch is lexicographically ordered by (octave, notename,
44     alteration).    
45    */
46   Musical_pitch (int octave, int notename,int accidental);
47   Musical_pitch ();
48
49   Musical_pitch to_relative_octave (Musical_pitch);
50   void transpose (Musical_pitch);
51   static int compare (Musical_pitch const&,Musical_pitch const&);
52   /// return large part of interval from central c
53   int steps() const;
54   /// return pitch from central c (in halfnotes)
55   int semitone_pitch() const; 
56   void up_to (int);
57   void down_to (int);
58   String str () const;
59
60   SCM smobbed_copy () const;
61   DECLARE_SCHEME_CALLBACK(less_p, (SCM a, SCM b));
62   DECLARE_SIMPLE_SMOBS(Musical_pitch,);
63 };
64
65 Musical_pitch* unsmob_pitch (SCM);
66
67 #include "compare.hh"
68 INSTANTIATE_COMPARE(Musical_pitch, Musical_pitch::compare);
69
70 int compare (Array<Musical_pitch>*, Array<Musical_pitch>*);
71
72 #endif /* MUSICAL_PITCH_HH */
73