interval (Pitch const & from , Pitch const & to )
{
int sound = to.semitone_pitch() - from.semitone_pitch ();
- Pitch pt ;
- pt.octave_ = to.octave_ - from.octave_;
- pt.notename_ = to.notename_ - from.notename_;
- pt.alteration_ = to.alteration_ - from.alteration_;
- pt.alteration_ += sound - pt.semitone_pitch();
+ Pitch pt (to.get_octave () - from.get_octave (),
+ to.get_notename() - from.get_notename(),
+ to.get_alteration() - from.get_alteration());
- return pt;
+ return pt.transposed (Pitch(0,0,sound - pt.semitone_pitch()));
}
return copy of resulting pitch
*/
Pitch
-Pitch::to_relative_octave (Pitch p)
+Pitch::to_relative_octave (Pitch p) const
{
int oct_mod = octave_ + 1; // account for c' = octave 1 iso. 0 4
Pitch up_pitch (p);
n = down_pitch;
n.octave_ += oct_mod;
-
- *this = n;
- return *this;
+ return n;
}
void
SCM_ASSERT_TYPE(t, p, SCM_ARG1, __FUNCTION__, "pitch") ;
SCM_ASSERT_TYPE(d, delta, SCM_ARG1, __FUNCTION__, "pitch") ;
- Pitch tp =*t;
- tp.transpose (*d);
- return tp.smobbed_copy ();
+ return t->transposed (*d).smobbed_copy ();
}
/****************************************************************/
return alteration_;
}
+Pitch
+Pitch::transposed (Pitch d) const
+{
+ Pitch p =*this;
+ p.transpose (d);
+ return p;
+}