]> git.donarmstrong.com Git - lilypond.git/blob - lily/pitch-interval.cc
Merge branch 'master' of git://git.sv.gnu.org/lilypond
[lilypond.git] / lily / pitch-interval.cc
1 /*
2   pitch-interval.cc -- implement Pitch_interval
3
4   source file of the GNU LilyPond music typesetter
5
6   (c) 2004--2007 Han-Wen Nienhuys <hanwen@xs4all.nl>
7 */
8
9 #include "pitch-interval.hh"
10
11 #include "interval.tcc"
12
13 Pitch_interval::Pitch_interval (Pitch p1, Pitch p2)
14 {
15   at (LEFT) = p1;
16   at (RIGHT) = p2;
17 }
18
19 Pitch_interval::Pitch_interval ()
20 {
21   at (LEFT) = Pitch (100, 0, 0);
22   at (RIGHT) = Pitch (-100, 0, 0);
23 }
24
25 bool
26 Pitch_interval::is_empty () const
27 {
28   return at (LEFT) > at (RIGHT);
29 }
30
31 Direction
32 Pitch_interval::add_point (Pitch p)
33 {
34   if (at (LEFT).tone_pitch () > p.tone_pitch ())
35     {
36       at (LEFT) = p;
37       return LEFT;
38     }
39   else if (at (RIGHT).tone_pitch () < p.tone_pitch ())
40     {
41       at (RIGHT) = p;
42       return RIGHT;
43     }
44   else
45     return CENTER;
46 }
47
48
49 Pitch_lexicographic_interval::Pitch_lexicographic_interval (Pitch p1, Pitch p2)
50 {
51   at (LEFT) = p1;
52   at (RIGHT) = p2;
53 }
54
55 Pitch_lexicographic_interval::Pitch_lexicographic_interval ()
56 {
57   at (LEFT) = Pitch (100, 0, 0);
58   at (RIGHT) = Pitch (-100, 0, 0);
59 }
60
61 bool
62 Pitch_lexicographic_interval::is_empty () const
63 {
64   return at (LEFT) > at (RIGHT);
65 }
66
67 Direction
68 Pitch_lexicographic_interval::add_point (Pitch p)
69 {
70   if (at (LEFT) > p)
71     {
72       at (LEFT) = p;
73       return LEFT;
74     }
75   else if (at (RIGHT) < p)
76     {
77       at (RIGHT) = p;
78       return RIGHT;
79     }
80   else
81     return CENTER;
82 }