ASPiK SDK
Loading...
Searching...
No Matches
AntiLogTaperDelegate.h
Go to the documentation of this file.
1// -----------------------------------------------------------------------------
2// ASPiK AAX Shell File: antilogtaperdelegate.h
3//
18// -----------------------------------------------------------------------------
19#ifndef __ANTILOGTAPERDELEGATE_H
20#define __ANTILOGTAPERDELEGATE_H
21
22#include "AAX_ITaperDelegate.h"
23#include "AAX_UtilsNative.h"
24#include "AAX.h" //for types
25
26#include <cmath> //for floor(), log()
27
28#include "guiconstants.h"
29
30template <typename T, int32_t RealPrecision=1000>
31
47class AntiLogTaperDelegate : public AAX_ITaperDelegate<T>
48{
49public:
50 AntiLogTaperDelegate(T minValue=0, T maxValue=1);
51
52 // --- Virtual Overrides
54 T GetMinimumValue() const { return mMinValue; }
55 T GetMaximumValue() const { return mMaxValue; }
56 T ConstrainRealValue(T value) const;
57 T NormalizedToReal(double normalizedValue) const;
58 double RealToNormalized(T realValue) const;
59
60protected:
61 T Round(double iValue) const;
62
63 // --- fNormalizedParam = 0->1
64 // returns antilog scaled 0->1 value
65 inline double calcAntiLogParameter(double fNormalizedParam) const
66 {
67 if(fNormalizedParam <= 0.0) return 0.0;
68 if(fNormalizedParam >= 1.0) return 1.0;
69
70 // --- MMA Concave Transform Inverse
71 return (kCTCorrFactorAntiUnity)*(-pow(10.0, (-fNormalizedParam / kCTCoefficient)) + 1.0);
72 }
73
74 // --- fPluginValue = 0->1 antilog scaled value
75 // returns normal 0-> value
76 inline double calcAntiLogPluginValue(double fPluginValue) const
77 {
78 if(fPluginValue <= 0.0) return 0.0;
79 if(fPluginValue >= 1.0) return 1.0;
80
81 // --- MMA Concave Transform
82 float transformed = -kCTCoefficient*kCTCorrFactorAntiLogScale*log10(1.0 - fPluginValue + kCTCorrFactorZero) + kCTCorrFactorAntiLog;
83 if(transformed >= 1.0) transformed = 1.0;
84 return transformed;
85 }
86
87private:
88 T mMinValue;
89 T mMaxValue;
90};
91
92template <typename T, int32_t RealPrecision>
94{
95 double precision = RealPrecision;
96 if (precision > 0)
97 return static_cast<T>(floor(iValue * precision + 0.5) / precision);
98 return static_cast<T>(iValue);
99}
100
101template <typename T, int32_t RealPrecision>
102AntiLogTaperDelegate<T, RealPrecision>::AntiLogTaperDelegate(T minValue, T maxValue) : AAX_ITaperDelegate<T>(),
103 mMinValue(minValue),
104 mMaxValue(maxValue)
105{
106
107}
108
109template <typename T, int32_t RealPrecision>
111{
112 return new AntiLogTaperDelegate(*this);
113}
114
115template <typename T, int32_t RealPrecision>
117{
118 if (RealPrecision)
119 value = Round(value); //reduce the precision to get proper rounding behavior with integers.
120
121 if (value > mMaxValue)
122 return mMaxValue;
123 if (value < mMinValue)
124 return mMinValue;
125 return value;
126}
127
128template <typename T, int32_t RealPrecision>
130{
131 normalizedValue = calcAntiLogPluginValue(normalizedValue);
132 double doubleRealValue = normalizedValue*(mMaxValue - mMinValue) + mMinValue;
133
134 T realValue = (T) doubleRealValue;
135
136 return ConstrainRealValue(realValue);
137}
138
139template <typename T, int32_t RealPrecision>
141{
142 double normValue = (realValue - mMinValue)/(mMaxValue - mMinValue);
143 return calcAntiLogParameter(normValue);
144}
145
146#endif // __ANTILOGTAPERDELEGATE_H
The AntiLogTaperDelegate object encapsulates an anti-log parameter. Note that the standard log potent...
Definition: AntiLogTaperDelegate.h:48
const double kCTCorrFactorAntiLogScale
concave/convex transform scaling factor
Definition: guiconstants.h:177
const double kCTCoefficient
concave and/or convex transform correction factor
Definition: guiconstants.h:135
const double kCTCorrFactorAntiUnity
inverse concave/convex transform correction factor at x = 1
Definition: guiconstants.h:163
const double kCTCorrFactorAntiLog
concave/convex transform correction factor
Definition: guiconstants.h:170
const double kCTCorrFactorZero
concave/convex transform correction factor at x = 0
Definition: guiconstants.h:142
globally utilized constants and enumerations