xiRetimer

fit recorded audio to a tempo
git clone https://git.ce9e.org/xiRetimer.git

commit
cf81b5e1e4dfab8d886373078b3ac2afdb2cd9e6
parent
414ac1a5e14b8aab82b26d4ea6ae024e67dd523e
Author
Tobias Bengfort <tobias.bengfort@posteo.de>
Date
2019-12-27 07:38
rm unused getRatio

Diffstat

M src/marker.cpp 48 +-----------------------------------------------
M src/marker.h 2 --

2 files changed, 1 insertions, 49 deletions


diff --git a/src/marker.cpp b/src/marker.cpp

@@ -89,52 +89,6 @@ float Marker::getLengthf() {
   89    89 }
   90    90 
   91    91 
   92    -1 float Marker::getRatio(float o) {
   93    -1 	// deprecated
   94    -1 	// derivate of old2new
   95    -1 	// hardcode the derivate to improve performance
   96    -1 	switch (getInterpolationMode()) {
   97    -1 		// linear
   98    -1 		case 0: {
   99    -1 			int i = getAreaOld(o);
  100    -1 			if (i < 0 || i + 1 > getLength() - 1) {
  101    -1 				return 0;
  102    -1 			}
  103    -1 			float dold = (getOld(i + 1) - getOld(i));
  104    -1 			if (dold <= 0) {
  105    -1 				return 0;
  106    -1 			}
  107    -1 			return (getNew(i + 1) - getNew(i)) / dold;
  108    -1 		} break;
  109    -1 		default: {
  110    -1 			// approxmiate ratio
  111    -1 			float n = 100;  // TODO automate this
  112    -1 
  113    -1 			float o1 = o - 1 / n;
  114    -1 			if (o1 < 0) {
  115    -1 				o1 = 0;
  116    -1 			}
  117    -1 			if (o1 > 1) {
  118    -1 				return 0;
  119    -1 			}
  120    -1 
  121    -1 			float o2 = o + 1 / n;
  122    -1 			if (o2 < 0) {
  123    -1 				return 0;
  124    -1 			}
  125    -1 			if (o2 > 1) {
  126    -1 				o2 = 1;
  127    -1 			}
  128    -1 			if (o2 - o1 <= 0) {
  129    -1 				return 0;
  130    -1 			}
  131    -1 
  132    -1 			return ((old2new(o2) - old2new(o1)) / (o2 - o1));
  133    -1 		}
  134    -1 	}
  135    -1 }
  136    -1 
  137    -1 
  138    92 int Marker::getLength() {
  139    93 	return anew.getLength();
  140    94 }
@@ -174,7 +128,7 @@ int Marker::resort(int pi) {
  174   128 float Marker::old2new(float o) {
  175   129 	// this one does all the interpolation!
  176   130 	// for performance reasons you should also hard code the interpolation modes
  177    -1 	// to getRatio(float) and new2old
   -1   131 	// to new2old
  178   132 	switch (getInterpolationMode()) {
  179   133 		// case 0: // linear is default
  180   134 		case 1: {  // polynominal spline

diff --git a/src/marker.h b/src/marker.h

@@ -15,7 +15,6 @@
   15    15  * For different modes of interpolation you have to edit 3 functions:
   16    16  * old2new
   17    17  * new2old - inverse of old2new
   18    -1  * getRatio - derivate of old2new
   19    18  */
   20    19 
   21    20 /*
@@ -46,7 +45,6 @@ class Marker {
   46    45 		int getAreaNew(float n);
   47    46 		int getAreaOld(float o);
   48    47 		float getLengthf();  // factor by which the length is changed;
   49    -1 		float getRatio(float o);  // factor by which is stretched on this place;
   50    48 		int getInterpolationMode();
   51    49 		void setInterpolationMode(int m);
   52    50 		// used by interpolation modes to determine if data has to be updated