[SCM] calf/master: + Framework: added new scale - logarithmic with (fake) infinity (fake to avoid breaking Ingen etc.)

js at users.alioth.debian.org js at users.alioth.debian.org
Tue May 7 15:38:05 UTC 2013


The following commit has been merged in the master branch:
commit f693ac91678eb605e2ec403a29b053f617576e48
Author: Krzysztof Foltman <wdev at foltman.com>
Date:   Fri Oct 31 23:02:11 2008 +0000

    + Framework: added new scale - logarithmic with (fake) infinity (fake to avoid breaking Ingen etc.)

diff --git a/src/calf/giface.h b/src/calf/giface.h
index 77b3dff..55a1003 100644
--- a/src/calf/giface.h
+++ b/src/calf/giface.h
@@ -65,6 +65,7 @@ enum parameter_flags
   PF_SCALE_GAIN = 0x30, ///< gain = -96dB..0 or -inf dB
   PF_SCALE_PERC = 0x40, ///< percent
   PF_SCALE_QUAD = 0x50, ///< quadratic scale (decent for some gain/amplitude values)
+  PF_SCALE_LOG_INF = 0x60, ///< log scale + +inf (FAKE_INFINITY)
 
   PF_CTLMASK =     0x0F00,
   PF_CTL_DEFAULT = 0x0000,
@@ -103,6 +104,9 @@ enum parameter_flags
   PF_UNIT_RPM     = 0x0B000000,  ///< revolutions per minute
 };
 
+#define FAKE_INFINITY (65536.0 * 65536.0)
+#define IS_FAKE_INFINITY(value) (fabs(value-FAKE_INFINITY) < 1.0)
+
 class null_audio_module;
 
 struct plugin_command_info
diff --git a/src/giface.cpp b/src/giface.cpp
index 91d541d..8ce4dd3 100644
--- a/src/giface.cpp
+++ b/src/giface.cpp
@@ -69,6 +69,13 @@ float parameter_properties::from_01(double value01) const
             value = rmin * pow(double(max / rmin), value01);
         }
         break;
+    case PF_SCALE_LOG_INF:
+        assert(step);
+        if (value01 > (step - 1.0) / step)
+            value = FAKE_INFINITY;
+        else
+            value = min * pow(double(max / min), value01 * step / (step - 1.0));
+        break;
     }
     switch(flags & PF_TYPEMASK)
     {
@@ -99,6 +106,12 @@ double parameter_properties::to_01(float value) const
     case PF_SCALE_LOG:
         value /= min;
         return log((double)value) / log((double)max / min);
+    case PF_SCALE_LOG_INF:
+        if (IS_FAKE_INFINITY(value))
+            return max;
+        value /= min;
+        assert(step);
+        return (step - 1.0) * log((double)value) / (step * log((double)max / min));
     case PF_SCALE_GAIN:
         if (value < 1.0 / 1024.0) // new bottom limit - 60 dB
             return 0;
@@ -151,7 +164,6 @@ std::string parameter_properties::to_string(float value) const
         sprintf(buf, "%0.1f dB", 6.0 * log(value) / log(2));
         return string(buf);
     }
-    
     switch(flags & PF_TYPEMASK)
     {
     case PF_INT:
@@ -162,7 +174,10 @@ std::string parameter_properties::to_string(float value) const
         break;
     }
 
-    sprintf(buf, "%g", value);
+    if ((flags & PF_SCALEMASK) == PF_SCALE_LOG_INF && IS_FAKE_INFINITY(value))
+        sprintf(buf, "+inf"); // XXXKF change to utf-8 infinity
+    else
+        sprintf(buf, "%g", value);
     
     switch(flags & PF_UNITMASK) {
     case PF_UNIT_DB: return string(buf) + " dB";

-- 
calf audio plugins packaging



More information about the pkg-multimedia-commits mailing list