]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/pitch.hh
(Composite_music): new transpose syntax,
[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 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_;
30   
31   /// 0 natural, 1 sharp, etc
32   int alteration_;
33
34   /// 0 is central c
35   int octave_;
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 get_octave () const;
46   int get_notename () const;
47   int get_alteration () const;
48
49   void normalise ();
50   /*
51     Pitch is lexicographically ordered by (octave, notename,
52     alteration).    
53    */
54   Pitch (int octave, int notename,int accidental);
55   Pitch ();
56
57   Pitch to_relative_octave (Pitch);
58
59   static int compare (Pitch const&,Pitch const&);
60   /// return large part of interval from central c
61   int steps () const;
62   /// return pitch from central c (in halfnotes)
63   int semitone_pitch () const; 
64   String string () const;
65
66   SCM smobbed_copy () const;
67   DECLARE_SCHEME_CALLBACK (less_p, (SCM a, SCM b));
68   DECLARE_SIMPLE_SMOBS (Pitch,);
69 };
70
71 SCM ly_pitch_transpose (SCM p, SCM delta);
72 DECLARE_UNSMOB(Pitch,pitch);
73
74 #include "compare.hh"
75 INSTANTIATE_COMPARE (Pitch, Pitch::compare);
76
77 int compare (Array<Pitch>*, Array<Pitch>*);
78 extern SCM pitch_less_proc;
79 Pitch interval (Pitch const & from , Pitch const & to );
80
81 #endif /* MUSICAL_PITCH_HH */
82
83