From 98c36749623f8f21fbd5804c8b33097f718ada5d Mon Sep 17 00:00:00 2001 From: Han-Wen Nienhuys Date: Thu, 7 Jun 2007 23:14:04 -0300 Subject: [PATCH] Fix #368 Use tone_pitch() for ordering pitches. --- input/regression/ambitus-pitch-ordering.ly | 13 ++++++++++ lily/include/pitch-interval.hh | 9 +++++++ lily/pitch-interval.cc | 28 ++++++++++++++++++++++ lily/pitch.cc | 4 ++++ 4 files changed, 54 insertions(+) create mode 100644 input/regression/ambitus-pitch-ordering.ly diff --git a/input/regression/ambitus-pitch-ordering.ly b/input/regression/ambitus-pitch-ordering.ly new file mode 100644 index 0000000000..d56c533d3c --- /dev/null +++ b/input/regression/ambitus-pitch-ordering.ly @@ -0,0 +1,13 @@ +\header { + texidoc = "Ambituses use actual pitch not lexicographic ordering." + } + +\version "2.10.25" + +\paper { + ragged-right=##t +} + +\new Voice \with { \consists "Ambitus_engraver" } { + \clef F c eis fes +} diff --git a/lily/include/pitch-interval.hh b/lily/include/pitch-interval.hh index ab8b51edde..947e418ea0 100644 --- a/lily/include/pitch-interval.hh +++ b/lily/include/pitch-interval.hh @@ -20,4 +20,13 @@ public: bool is_empty () const; }; +class Pitch_lexicographic_interval : public Drul_array +{ +public: + Pitch_lexicographic_interval (); + Pitch_lexicographic_interval (Pitch, Pitch); + void add_point (Pitch); + bool is_empty () const; +}; + #endif /* PITCH_INTERVAL_HH */ diff --git a/lily/pitch-interval.cc b/lily/pitch-interval.cc index 064c634327..f871e7e185 100644 --- a/lily/pitch-interval.cc +++ b/lily/pitch-interval.cc @@ -30,6 +30,34 @@ Pitch_interval::is_empty () const void Pitch_interval::add_point (Pitch p) +{ + if (at (LEFT).tone_pitch () > p.tone_pitch ()) + at (LEFT) = p; + if (at (RIGHT).tone_pitch () < p.tone_pitch ()) + at (RIGHT) = p; +} + + +Pitch_lexicographic_interval::Pitch_lexicographic_interval (Pitch p1, Pitch p2) +{ + at (LEFT) = p1; + at (RIGHT) = p2; +} + +Pitch_lexicographic_interval::Pitch_lexicographic_interval () +{ + at (LEFT) = Pitch (100, 0, 0); + at (RIGHT) = Pitch (-100, 0, 0); +} + +bool +Pitch_lexicographic_interval::is_empty () const +{ + return at (LEFT) > at (RIGHT); +} + +void +Pitch_lexicographic_interval::add_point (Pitch p) { if (at (LEFT) > p) at (LEFT) = p; diff --git a/lily/pitch.cc b/lily/pitch.cc index fa68b2d1ba..bc8a9e45a6 100644 --- a/lily/pitch.cc +++ b/lily/pitch.cc @@ -67,6 +67,10 @@ Pitch::tone_pitch () const o--; } + /* + we're effictively hardcoding the octave to 6 whole-tones, + which is as arbitrary as coding it to 1200 cents + */ Rational tones ((o + n / scale_->step_tones_.size ()) * 6, 1); tones += scale_->step_tones_[n % scale_->step_tones_.size ()]; -- 2.39.5