diff audioio/PlaySpeedRangeMapper.cpp @ 450:d9d132c0e240 alignment_view

Merge from default branch
author Chris Cannam
date Mon, 20 Apr 2015 09:21:32 +0100
parents 72c662fe7ea3
children 45054b36ddbf
line wrap: on
line diff
--- a/audioio/PlaySpeedRangeMapper.cpp	Fri Nov 28 10:33:25 2014 +0000
+++ b/audioio/PlaySpeedRangeMapper.cpp	Mon Apr 20 09:21:32 2015 +0100
@@ -25,23 +25,23 @@
 }
 
 int
-PlaySpeedRangeMapper::getPositionForValue(float value) const
+PlaySpeedRangeMapper::getPositionForValue(double value) const
 {
     // value is percent
-    float factor = getFactorForValue(value);
+    double factor = getFactorForValue(value);
     int position = getPositionForFactor(factor);
     return position;
 }
 
 int
-PlaySpeedRangeMapper::getPositionForValueUnclamped(float value) const
+PlaySpeedRangeMapper::getPositionForValueUnclamped(double value) const
 {
     // We don't really provide this
     return getPositionForValue(value);
 }
 
 int
-PlaySpeedRangeMapper::getPositionForFactor(float factor) const
+PlaySpeedRangeMapper::getPositionForFactor(double factor) const
 {
     bool slow = (factor > 1.0);
 
@@ -49,8 +49,8 @@
     
     int half = (m_maxpos + m_minpos) / 2;
 
-    factor = sqrtf((factor - 1.0) * 1000.f);
-    int position = lrintf(((factor * (half - m_minpos)) / 100.0) + m_minpos);
+    factor = sqrt((factor - 1.0) * 1000.0);
+    int position = int(lrint(((factor * (half - m_minpos)) / 100.0) + m_minpos));
 
     if (slow) {
         position = half - position;
@@ -63,37 +63,37 @@
     return position;
 }
 
-float
+double
 PlaySpeedRangeMapper::getValueForPosition(int position) const
 {
-    float factor = getFactorForPosition(position);
-    float pc = getValueForFactor(factor);
+    double factor = getFactorForPosition(position);
+    double pc = getValueForFactor(factor);
     return pc;
 }
 
-float
+double
 PlaySpeedRangeMapper::getValueForPositionUnclamped(int position) const
 {
     // We don't really provide this
     return getValueForPosition(position);
 }
 
-float
-PlaySpeedRangeMapper::getValueForFactor(float factor) const
+double
+PlaySpeedRangeMapper::getValueForFactor(double factor) const
 {
-    float pc;
+    double pc;
     if (factor < 1.0) pc = ((1.0 / factor) - 1.0) * 100.0;
     else pc = (1.0 - factor) * 100.0;
 //    cerr << "position = " << position << " percent = " << pc << endl;
     return pc;
 }
 
-float
-PlaySpeedRangeMapper::getFactorForValue(float value) const
+double
+PlaySpeedRangeMapper::getFactorForValue(double value) const
 {
     // value is percent
     
-    float factor;
+    double factor;
 
     if (value <= 0) {
         factor = 1.0 - (value / 100.0);
@@ -105,7 +105,7 @@
     return factor;
 }
 
-float
+double
 PlaySpeedRangeMapper::getFactorForPosition(int position) const
 {
     bool slow = false;
@@ -124,7 +124,7 @@
 
     // position is between min and half (inclusive)
 
-    float factor;
+    double factor;
 
     if (position == m_minpos) {
         factor = 1.0;