]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/pitch.hh
release: 1.3.108
[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--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 class Pitch
22 {
23 public:                         // fixme
24   /*
25     TODO: use SCM -- (make private?)
26    */
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   /*
37     mutators, so JUNKME.
38    */
39   void transpose (Pitch);
40   void up_to (int);
41   void down_to (int);
42
43 public:
44
45   int octave_i () const;
46   int notename_i () const;
47   int alteration_i () const;
48
49   /*
50     Pitch is lexicographically ordered by (octave, notename,
51     alteration).    
52    */
53   Pitch (int octave, int notename,int accidental);
54   Pitch ();
55
56   Pitch to_relative_octave (Pitch);
57
58   static int compare (Pitch const&,Pitch const&);
59   /// return large part of interval from central c
60   int steps() const;
61   /// return pitch from central c (in halfnotes)
62   int semitone_pitch() const; 
63   String str () const;
64
65   static SCM transpose (SCM p, SCM delta);
66
67   SCM smobbed_copy () const;
68   DECLARE_SCHEME_CALLBACK(less_p, (SCM a, SCM b));
69   DECLARE_SIMPLE_SMOBS(Pitch,);
70
71
72 };
73
74 Pitch* unsmob_pitch (SCM);
75
76 #include "compare.hh"
77 INSTANTIATE_COMPARE(Pitch, Pitch::compare);
78
79 int compare (Array<Pitch>*, Array<Pitch>*);
80
81 #endif /* MUSICAL_PITCH_HH */
82
83