From ecbff8fee2fc7e1e9c6e4f5efd0083b5a66fe252 Mon Sep 17 00:00:00 2001 From: mchinen Date: Sat, 29 Jan 2011 22:32:39 +0000 Subject: [PATCH] bug 172 followup: display correct semitones and restore non-inverted tempo values for Sliding Time Effect --- src/effects/TimeScale.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/effects/TimeScale.cpp b/src/effects/TimeScale.cpp index 1155ce3e1..6369934b1 100644 --- a/src/effects/TimeScale.cpp +++ b/src/effects/TimeScale.cpp @@ -103,10 +103,15 @@ bool EffectTimeScale::TransferParameters( Shuttle & shuttle ) return true; } +inline double InvertedPercentChangeToRatio(double percentChange) +{ + //mchinen hack: invert the ratio so it works with the sbsms bug which requires the reciprocal number. + return 1.0/(1.0 + percentChange / 100.0); +} + inline double PercentChangeToRatio(double percentChange) { - //mchinen hack: invert the ratio so it works with the sbsms bug. - return 1.0/(1.0 + percentChange / 100.0); + return 1.0 + percentChange / 100.0; } inline double HalfStepsToPercentChange(double halfSteps) @@ -116,13 +121,16 @@ inline double HalfStepsToPercentChange(double halfSteps) inline double PercentChangeToHalfSteps(double percentChange) { + // mchinen: hack: take the negative of this so the correct value is displayed + // (see the InvertedPercentChangeToRatio hack for why this is needed) return 17.312340490667560888319096172023 * log(PercentChangeToRatio(percentChange)); } bool EffectTimeScale::Process() { - double pitchStart = PercentChangeToRatio(m_PitchPercentChangeStart); - double pitchEnd = PercentChangeToRatio(m_PitchPercentChangeEnd); + // The pitch part of sbsms is backwards, so use an inverted function + double pitchStart = InvertedPercentChangeToRatio(m_PitchPercentChangeStart); + double pitchEnd = InvertedPercentChangeToRatio(m_PitchPercentChangeEnd); double rateStart = PercentChangeToRatio(m_RatePercentChangeStart); double rateEnd = PercentChangeToRatio(m_RatePercentChangeEnd); this->EffectSBSMS::setParameters(rateStart,rateEnd,pitchStart,pitchEnd,m_PreAnalyze);