]> git.donarmstrong.com Git - lilypond.git/blob - lily/pitch-interval.cc
Web-ja: update introduction
[lilypond.git] / lily / pitch-interval.cc
1 /*
2   This file is part of LilyPond, the GNU music typesetter.
3
4   Copyright (C) 2004--2015 Han-Wen Nienhuys <hanwen@xs4all.nl>
5
6   LilyPond is free software: you can redistribute it and/or modify
7   it under the terms of the GNU General Public License as published by
8   the Free Software Foundation, either version 3 of the License, or
9   (at your option) any later version.
10
11   LilyPond is distributed in the hope that it will be useful,
12   but WITHOUT ANY WARRANTY; without even the implied warranty of
13   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14   GNU General Public License for more details.
15
16   You should have received a copy of the GNU General Public License
17   along with LilyPond.  If not, see <http://www.gnu.org/licenses/>.
18 */
19
20 #include "pitch-interval.hh"
21
22 #include "interval.tcc"
23
24 Pitch_interval::Pitch_interval (Pitch p1, Pitch p2)
25 {
26   at (LEFT) = p1;
27   at (RIGHT) = p2;
28 }
29
30 Pitch_interval::Pitch_interval ()
31 {
32   at (LEFT) = Pitch (100, 0);
33   at (RIGHT) = Pitch (-100, 0);
34 }
35
36 bool
37 Pitch_interval::is_empty () const
38 {
39   return at (LEFT) > at (RIGHT);
40 }
41
42 Drul_array<bool>
43 Pitch_interval::add_point (Pitch p)
44 {
45   Drul_array<bool> expansions (false, false);
46   if (at (LEFT).tone_pitch () > p.tone_pitch ())
47     {
48       at (LEFT) = p;
49       expansions [LEFT] = true;
50     }
51   if (at (RIGHT).tone_pitch () < p.tone_pitch ())
52     {
53       at (RIGHT) = p;
54       expansions [RIGHT] = true;
55     }
56   return expansions;
57 }
58
59 Pitch_lexicographic_interval::Pitch_lexicographic_interval (Pitch p1, Pitch p2)
60 {
61   at (LEFT) = p1;
62   at (RIGHT) = p2;
63 }
64
65 Pitch_lexicographic_interval::Pitch_lexicographic_interval ()
66 {
67   at (LEFT) = Pitch (100, 0);
68   at (RIGHT) = Pitch (-100, 0);
69 }
70
71 bool
72 Pitch_lexicographic_interval::is_empty () const
73 {
74   return at (LEFT) > at (RIGHT);
75 }
76
77 Drul_array<bool>
78 Pitch_lexicographic_interval::add_point (Pitch p)
79 {
80   Drul_array<bool> expansions (false, false);
81   if (at (LEFT) > p)
82     {
83       at (LEFT) = p;
84       expansions [LEFT] = true;
85     }
86   if (at (RIGHT) < p)
87     {
88       at (RIGHT) = p;
89       expansions [RIGHT] = true;
90     }
91   return expansions;
92 }