Correct left text alignment of DynamicTextSpanner.
[lilypond.git] / lily / include / pitch.hh
blob4ab7cb5ea5734d41358ec341fe110367b4040f40
1 /*
2 pitch.hh -- declare Pitch
4 source file of the GNU LilyPond music typesetter
6 (c) 1998--2007 Han-Wen Nienhuys <hanwen@xs4all.nl>
7 */
9 #ifndef MUSICAL_PITCH_HH
10 #define MUSICAL_PITCH_HH
12 #include "lily-proto.hh"
13 #include "smobs.hh"
14 #include "rational.hh"
17 /** A "tonal" pitch. This is a pitch used in diatonal western music
18 (24 quartertones in an octave), as opposed to a frequency in Hz or a
19 integer number of semitones.
21 Pitch is lexicographically ordered by (octave, notename,
22 alteration).
25 class Pitch
27 private:
28 int octave_;
29 int notename_;
30 Rational alteration_;
31 Scale *scale_;
33 void transpose (Pitch);
34 void up_to (int);
35 void down_to (int);
36 void normalize_octave ();
37 void normalize_alteration ();
38 void normalize ();
40 public:
41 int get_octave () const;
42 int get_notename () const;
43 Rational get_alteration () const;
45 Pitch (int octave, int notename, Rational accidental);
46 Pitch (int octave, int notename);
47 Pitch ();
49 Pitch transposed (Pitch) const;
50 Pitch to_relative_octave (Pitch) const;
52 static int compare (Pitch const &, Pitch const &);
54 int steps () const;
55 Rational tone_pitch () const;
56 int rounded_semitone_pitch () const;
57 int rounded_quartertone_pitch () const;
58 Pitch negated () const;
59 string to_string () const;
61 DECLARE_SCHEME_CALLBACK (less_p, (SCM a, SCM b));
62 DECLARE_SIMPLE_SMOBS (Pitch);
66 enum {
67 DOUBLE_FLAT = -4,
68 THREE_Q_FLAT,
69 FLAT,
70 SEMI_FLAT,
71 NATURAL,
72 SEMI_SHARP,
73 SHARP,
74 THREE_Q_SHARP,
75 DOUBLE_SHARP,
78 extern Rational DOUBLE_FLAT_ALTERATION;
79 extern Rational THREE_Q_FLAT_ALTERATION;
80 extern Rational FLAT_ALTERATION;
81 extern Rational SEMI_FLAT_ALTERATION;
82 extern Rational NATURAL_ALTERATION;
83 extern Rational SEMI_SHARP_ALTERATION;
84 extern Rational SHARP_ALTERATION;
85 extern Rational THREE_Q_SHARP_ALTERATION;
86 extern Rational DOUBLE_SHARP_ALTERATION;
88 SCM ly_pitch_diff (SCM pitch, SCM root);
89 SCM ly_pitch_transpose (SCM p, SCM delta);
90 DECLARE_UNSMOB (Pitch, pitch);
92 INSTANTIATE_COMPARE (Pitch, Pitch::compare);
94 extern SCM pitch_less_proc;
95 Pitch pitch_interval (Pitch const &from, Pitch const &to);
97 #endif /* MUSICAL_PITCH_HH */