Update from Andrew: tweaks for cross-staff chords snippet.
[lilypond.git] / lily / pitch-interval.cc
bloba7390aa282cb0825f2bc744520db6c7627e5b6c5
1 /*
2 pitch-interval.cc -- implement Pitch_interval
4 source file of the GNU LilyPond music typesetter
6 (c) 2004--2007 Han-Wen Nienhuys <hanwen@xs4all.nl>
7 */
9 #include "pitch-interval.hh"
11 #include "interval.tcc"
13 Pitch_interval::Pitch_interval (Pitch p1, Pitch p2)
15 at (LEFT) = p1;
16 at (RIGHT) = p2;
19 Pitch_interval::Pitch_interval ()
21 at (LEFT) = Pitch (100, 0, 0);
22 at (RIGHT) = Pitch (-100, 0, 0);
25 bool
26 Pitch_interval::is_empty () const
28 return at (LEFT) > at (RIGHT);
31 Drul_array<bool>
32 Pitch_interval::add_point (Pitch p)
34 Drul_array<bool> expansions(false,false);
35 if (at (LEFT).tone_pitch () > p.tone_pitch ())
37 at (LEFT) = p;
38 expansions [LEFT] = true;
40 if (at (RIGHT).tone_pitch () < p.tone_pitch ())
42 at (RIGHT) = p;
43 expansions [RIGHT] = true;
45 return expansions;
49 Pitch_lexicographic_interval::Pitch_lexicographic_interval (Pitch p1, Pitch p2)
51 at (LEFT) = p1;
52 at (RIGHT) = p2;
55 Pitch_lexicographic_interval::Pitch_lexicographic_interval ()
57 at (LEFT) = Pitch (100, 0, 0);
58 at (RIGHT) = Pitch (-100, 0, 0);
61 bool
62 Pitch_lexicographic_interval::is_empty () const
64 return at (LEFT) > at (RIGHT);
67 Drul_array<bool>
68 Pitch_lexicographic_interval::add_point (Pitch p)
70 Drul_array<bool> expansions(false,false);
71 if (at (LEFT) > p)
73 at (LEFT) = p;
74 expansions [LEFT] = true;
76 if (at (RIGHT) < p)
78 at (RIGHT) = p;
79 expansions [RIGHT] = true;
81 return expansions;