keep DSP state variables finite.
[ardour.git] / libs / ardour / automation_control.cc
index 583f38807d2e2b5836128d5099c6cb4347f8bc47..3629345d941e7a9efe06fc805df15080ea07a939 100644 (file)
@@ -18,6 +18,7 @@
 
 */
 
+#include <math.h>
 #include <iostream>
 #include "ardour/automation_control.h"
 #include "ardour/automation_watch.h"
 
 #include "i18n.h"
 
+#ifdef COMPILER_MSVC
+#include <float.h>
+// C99 'isfinite()' is not available in MSVC.
+#define isfinite_local(val) (bool)_finite((double)val)
+#else
+#define isfinite_local isfinite
+#endif
+
 using namespace std;
 using namespace ARDOUR;
 using namespace PBD;
@@ -199,6 +208,9 @@ AutomationControl::internal_to_interface (double val) const
 double
 AutomationControl::interface_to_internal (double val) const
 {
+       if (!isfinite_local (val)) {
+               val = 0;
+       }
        if (_desc.logarithmic) {
                if (val <= 0) {
                        val = 0;