changeset 1197:fbe0fd84cb50 spectrogram-minor-refactor

Float/double conversion fixes
author Chris Cannam
date Mon, 01 Aug 2016 16:25:06 +0100
parents c7b9c902642f
children b494439a301c
files base/ColumnOp.h
diffstat 1 files changed, 5 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/base/ColumnOp.h	Mon Aug 01 16:21:01 2016 +0100
+++ b/base/ColumnOp.h	Mon Aug 01 16:25:06 2016 +0100
@@ -54,15 +54,15 @@
     /**
      * Scale the given column using the given gain multiplier.
      */
-    static Column applyGain(const Column &in, float gain) {
+    static Column applyGain(const Column &in, double gain) {
 	
-	if (gain == 1.f) {
+	if (gain == 1.0) {
 	    return in;
 	}
 	Column out;
 	out.reserve(in.size());
 	for (auto v: in) {
-	    out.push_back(v * gain);
+	    out.push_back(float(v * gain));
 	}
 	return out;
     }
@@ -71,7 +71,7 @@
      * Scale an FFT output by half the FFT size.
      */
     static Column fftScale(const Column &in, int fftSize) {
-        return applyGain(in, 2.f / float(fftSize));
+        return applyGain(in, 2.0 / fftSize);
     }
 
     /**
@@ -140,15 +140,8 @@
                 }
             }
         }
-    
-	std::vector<float> out;
-	out.reserve(in.size());
 
-	for (auto v: in) {
-	    out.push_back(v * scale);
-	}
-        
-	return out;
+        return applyGain(in, scale);
     }
 
     /**