+ return (octave_i_ + sign_safe_div (notename_i_, 7)) * 12
+ + pitch_byte_a[notename_i_ % 7]
+ + alteration_i_;
+}
+
+void
+Pitch::normalise ()
+{
+ int pitch = semitone_pitch ();
+ while (notename_i_ >= 7)
+ {
+ notename_i_ -= 7;
+ octave_i_++;
+ alteration_i_ -= semitone_pitch () - pitch;
+ }
+ while (notename_i_ < 0)
+ {
+ notename_i_ += 7;
+ octave_i_--;
+ alteration_i_ -= semitone_pitch () - pitch;
+ }
+ while (alteration_i_ >= 3)
+ {
+ if (notename_i_ == 6)
+ {
+ notename_i_ = 0;
+ octave_i_++;
+ }
+ else
+ notename_i_++;
+
+ alteration_i_ = 0;
+ alteration_i_ -= semitone_pitch () - pitch;
+ }
+ while (alteration_i_ <= -3)
+ {
+ if (notename_i_ == 0)
+ {
+ notename_i_ = 6;
+ octave_i_--;
+ }
+ else
+ notename_i_--;
+
+ alteration_i_ = 0;
+ alteration_i_ -= semitone_pitch () - pitch;
+ }