]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/pitch.hh
Fix some bugs in the dynamic engraver and PostScript backend
[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--2006 Han-Wen Nienhuys <hanwen@xs4all.nl>
7 */
8
9 #ifndef MUSICAL_PITCH_HH
10 #define MUSICAL_PITCH_HH
11
12 #include "lily-proto.hh"
13 #include "smobs.hh"
14
15 /** A "tonal" pitch. This is a pitch used in diatonal western music
16     (24 quartertones in an octave), as opposed to a frequency in Hz or a
17     integer number of semitones.
18
19     Pitch is lexicographically ordered by (octave, notename,
20     alteration).
21
22
23     TODO:
24
25     - add indeterminate octaves, so it can be used as a key in keySigature
26 */
27 class Pitch
28 {
29 private:                                // fixme
30   /*
31     TODO: use SCM
32   */
33
34   int notename_;
35   int alteration_;
36   int octave_;
37
38   void transpose (Pitch);
39   void up_to (int);
40   void down_to (int);
41   void normalise ();
42
43 public:
44
45   int get_octave () const;
46   int get_notename () const;
47   int get_alteration () const;
48
49   Pitch (int octave, int notename, int accidental);
50   Pitch ();
51
52   Pitch transposed (Pitch) const;
53   Pitch to_relative_octave (Pitch) const;
54
55   static int compare (Pitch const &, Pitch const &);
56
57   int steps () const;
58   int semitone_pitch () const;
59   int quartertone_pitch () const;
60   string to_string () const;
61
62   DECLARE_SCHEME_CALLBACK (less_p, (SCM a, SCM b));
63   DECLARE_SIMPLE_SMOBS (Pitch,);
64 };
65
66 enum
67   {
68     DOUBLE_FLAT = -4,
69     THREE_Q_FLAT,
70     FLAT,
71     SEMI_FLAT,
72     NATURAL,
73     SEMI_SHARP,
74     SHARP,
75     THREE_Q_SHARP,
76     DOUBLE_SHARP,
77   };
78
79 SCM ly_pitch_diff (SCM pitch, SCM root);
80 SCM ly_pitch_transpose (SCM p, SCM delta);
81 DECLARE_UNSMOB (Pitch, pitch);
82
83 INSTANTIATE_COMPARE (Pitch, Pitch::compare);
84
85 extern SCM pitch_less_proc;
86 Pitch pitch_interval (Pitch const &from, Pitch const &to);
87
88 #endif /* MUSICAL_PITCH_HH */
89