prepare for update to waf 1.8
[ardour.git] / libs / vamp-plugins / SpectralCentroid.cpp
index 82d80b81000532bc518c31f2b4bfb76a34e096b9..0550307969e5cf36383062d8f8b9ba8ef0427916 100644 (file)
@@ -7,7 +7,7 @@
 
     Centre for Digital Music, Queen Mary, University of London.
     Copyright 2006 Chris Cannam.
-  
+
     Permission is hereby granted, free of charge, to any person
     obtaining a copy of this software and associated documentation
     files (the "Software"), to deal in the Software without
     authorization.
 */
 
+#include <cmath>
+
+#ifdef COMPILER_MSVC
+#include <float.h>
+
+// 'std::isinf()' and 'std::isnan()' are not available in MSVC.
+#define isinf_local(val) !((bool)_finite((double)val))
+#define isnan_local(val) (bool)_isnan((double)val)
+#else
+#define isinf_local std::isinf
+#define isnan_local std::isnan
+#endif
+
 #include "SpectralCentroid.h"
 
 using std::string;
@@ -41,8 +54,6 @@ using std::vector;
 using std::cerr;
 using std::endl;
 
-#include <cmath>
-
 
 SpectralCentroid::SpectralCentroid(float inputSampleRate) :
     Plugin(inputSampleRate),
@@ -165,13 +176,13 @@ SpectralCentroid::process(const float *const *inputBuffers, Vamp::RealTime)
 
        Feature feature;
        feature.hasTimestamp = false;
-        if (!std::isnan(centroidLog) && !std::isinf(centroidLog)) {
+        if (!isnan_local(centroidLog) && !isinf_local(centroidLog)) {
             feature.values.push_back(centroidLog);
         }
        returnFeatures[0].push_back(feature);
 
         feature.values.clear();
-        if (!std::isnan(centroidLin) && !std::isinf(centroidLin)) {
+        if (!isnan_local(centroidLin) && !isinf_local(centroidLin)) {
             feature.values.push_back(centroidLin);
         }
        returnFeatures[1].push_back(feature);