changeset 1195:c118d2022ffa spectrogram-minor-refactor

Scale range matching
author Chris Cannam
date Mon, 01 Aug 2016 15:06:16 +0100
parents 238780e92f86
children c7b9c902642f
files base/ColumnOp.h
diffstat 1 files changed, 17 insertions(+), 25 deletions(-) [+]
line wrap: on
line diff
--- a/base/ColumnOp.h	Wed Jul 20 13:40:23 2016 +0100
+++ b/base/ColumnOp.h	Mon Aug 01 15:06:16 2016 +0100
@@ -52,18 +52,26 @@
     typedef std::vector<float> Column;
 
     /**
+     * Scale the given column using the given gain multiplier.
+     */
+    static Column applyGain(const Column &in, float gain) {
+	
+	if (gain == 1.f) {
+	    return in;
+	}
+	Column out;
+	out.reserve(in.size());
+	for (auto v: in) {
+	    out.push_back(v * gain);
+	}
+	return out;
+    }
+
+    /**
      * Scale an FFT output by half the FFT size.
      */
     static Column fftScale(const Column &in, int fftSize) {
-	
-	Column out;
-	out.reserve(in.size());
-	float scale = 2.f / float(fftSize);
-	for (auto v: in) {
-	    out.push_back(v * scale);
-	}
-	
-	return out;
+        return applyGain(in, 2.f / float(fftSize));
     }
 
     /**
@@ -144,22 +152,6 @@
     }
 
     /**
-     * Scale the given column using the given gain multiplier.
-     */
-    static Column applyGain(const Column &in, float gain) {
-	
-	if (gain == 1.f) {
-	    return in;
-	}
-	Column out;
-	out.reserve(in.size());
-	for (auto v: in) {
-	    out.push_back(v * gain);
-	}
-	return out;
-    }
-
-    /**
      * Distribute the given column into a target vector of a different
      * size, optionally using linear interpolation. The binfory vector
      * contains a mapping from y coordinate (i.e. index into the