Skeleton tests for BBT_Time.
[ardour.git] / libs / ardour / utils.cc
index c598a3d27965c060bfad00d9e5f2ff8c710a12ab..f7a4e1431604a68797c9872602811a44fbfbe3b7 100644 (file)
 
 */
 
+#ifdef WAF_BUILD
+#include "libardour-config.h"
+#endif
+
 #define __STDC_FORMAT_MACROS 1
 #include <stdint.h>
 
 #include <wordexp.h>
 #endif
 
-#include <pbd/error.h>
-#include <pbd/stacktrace.h>
-#include <pbd/xml++.h>
-#include <pbd/basename.h>
-#include <ardour/utils.h>
+#include "pbd/error.h"
+#include "pbd/stacktrace.h"
+#include "pbd/xml++.h"
+#include "pbd/basename.h"
+#include "ardour/utils.h"
 
 #include "i18n.h"
 
@@ -206,7 +210,7 @@ path_is_paired (ustring path, ustring& pair_base)
                path = path.substr(pos+1);
        }
 
-       /* remove filename suffixes etc. */
+       /* remove filename suffixes etc. */
 
        if ((pos = path.find_last_of ('.')) != string::npos) {
                path = path.substr (0, pos);
@@ -282,7 +286,7 @@ compute_equal_power_fades (nframes_t nframes, float* in, float* out)
 {
        double step;
 
-       step = 1.0/nframes;
+       step = 1.0/(nframes-1);
 
        in[0] = 0.0f;
 
@@ -378,19 +382,6 @@ slave_source_to_string (SlaveSource src)
        }
 }
 
-/* I don't really like hard-coding these falloff rates here
- * Probably should use a map of some kind that could be configured
- * These rates are db/sec.
-*/
-
-#define METER_FALLOFF_OFF     0.0f
-#define METER_FALLOFF_SLOWEST 6.6f // BBC standard
-#define METER_FALLOFF_SLOW    8.6f // BBC standard
-#define METER_FALLOFF_MEDIUM  20.0f
-#define METER_FALLOFF_FAST    32.0f
-#define METER_FALLOFF_FASTER  46.0f
-#define METER_FALLOFF_FASTEST 70.0f
-
 float
 meter_falloff_to_float (MeterFalloff falloff)
 {
@@ -434,28 +425,12 @@ meter_falloff_from_float (float val)
        }
        else if (val <= METER_FALLOFF_FASTER) {
                return MeterFalloffFaster;
-       }
+       }
        else {
                return MeterFalloffFastest;
        }
 }
 
-float
-meter_hold_to_float (MeterHold hold)
-{
-       switch (hold) {
-       case MeterHoldOff:
-               return 0.0f;
-       case MeterHoldShort:
-               return 40.0f;
-       case MeterHoldMedium:
-               return 100.0f;
-       case MeterHoldLong:
-       default:
-               return 200.0f;
-       }
-}
-
 AutoState
 ARDOUR::string_to_auto_state (std::string str)
 {
@@ -531,6 +506,20 @@ ARDOUR::auto_style_to_string (AutoStyle as)
        return "";
 }
 
+std::string
+bool_as_string (bool yn)
+{
+       return (yn ? "yes" : "no");
+}
+
+bool
+string_is_affirmative (const std::string& str)
+{
+       /* to be used only with XML data - not intended to handle user input */
+
+       return str == "1" || str == "y" || str == "Y" || (!g_strncasecmp(str.c_str(), "yes", str.length()));
+}
+
 extern "C" {
        void c_stacktrace() { stacktrace (cerr); }
 }