ASPiK SDK
guiconstants.h
Go to the documentation of this file.
1 // -----------------------------------------------------------------------------
2 // ASPiK Plugin Kernel File: guiconstants.h
3 //
12 // -----------------------------------------------------------------------------
13 #ifndef _guiconstants_h
14 #define _guiconstants_h
15 
16 #define _MATH_DEFINES_DEFINED
17 
18 #include <stdint.h>
19 #include <stdlib.h>
20 #include <vector>
21 #include <string>
22 #include <math.h>
23 
24 // --- RESERVED PARAMETER ID VALUES
25 const unsigned int PLUGIN_SIDE_BYPASS = 131072;
26 const unsigned int XY_TRACKPAD = 131073;
27 const unsigned int VECTOR_JOYSTICK = 131074;
28 const unsigned int PRESET_NAME = 131075;
29 const unsigned int WRITE_PRESET_FILE = 131076;
30 const unsigned int SCALE_GUI_SIZE = 131077;
31 // --- 131078 -through- 131999 are RESERVED ///<RESERVED PARAMETER ID VALUE
32 
33 // --- custom views may be added using the base here: e.g.
34 // const unsigned int CUSTOM_SPECTRUM_VIEW = CUSTOM_VIEW_BASE + 1;
35 const unsigned int CUSTOM_VIEW_BASE = 132000;
36 
37 // --- enum for the GUI object's message processing
38 enum { tinyGUI, verySmallGUI, smallGUI, normalGUI, largeGUI, veryLargeGUI };
39 
49 inline bool isReservedTag(int tag)
50 {
51  if (tag == PLUGIN_SIDE_BYPASS ||
52  tag == XY_TRACKPAD ||
53  tag == VECTOR_JOYSTICK ||
54  tag == PRESET_NAME ||
55  tag == WRITE_PRESET_FILE ||
56  tag == SCALE_GUI_SIZE)
57  return true;
58 
59  return false;
60 }
61 
62 // --- typed enumeration helpers
72 #define enumToInt(ENUM) static_cast<int>(ENUM)
73 
84 #define compareEnumToInt(ENUM,INT) (static_cast<int>(ENUM) == (INT))
85 
97 #define compareIntToEnum(INT,ENUM) ((INT) == static_cast<int>(ENUM))
98 
110 #define convertIntToEnum(INT,ENUM) static_cast<ENUM>(INT)
111 
117 const double kCTCoefficient = 5.0 / 12.0;
118 
124 const double kCTCorrFactorZero = pow(10.0, (-1.0/kCTCoefficient));
125 
131 const double kCTCorrFactorAnitZero = 1.0 / (1.0 - kCTCorrFactorZero);
132 
138 const double kCTCorrFactorUnity = 1.0 / (1.0 + kCTCoefficient*log10(1.0 + kCTCorrFactorZero));
139 
145 const double kCTCorrFactorAntiUnity = 1.0 / (1.0 + (-pow(10.0, (-1.0/kCTCoefficient))));
146 
153 
160 
166 const double kPi = 3.14159265358979323846264338327950288419716939937510582097494459230781640628620899;
167 
173 const double kTwoPi = 2.0*3.14159265358979323846264338327950288419716939937510582097494459230781640628620899;
174 
175 //-----------------------------------------------------------------------------
177 //-----------------------------------------------------------------------------
180 // ---
181 const uint32_t ENVELOPE_DETECT_MODE_PEAK = 0;
182 const uint32_t ENVELOPE_DETECT_MODE_MS = 1;
183 const uint32_t ENVELOPE_DETECT_MODE_RMS = 2;
184 const uint32_t ENVELOPE_DETECT_MODE_NONE = 3;
185 
186 const float ENVELOPE_DIGITAL_TC = -4.6051701859880913680359829093687;
187 const float ENVELOPE_ANALOG_TC = -1.0023934309275667804345424248947;
188 
192 // ---
193 const float GUI_METER_UPDATE_INTERVAL_MSEC = 50.f;
194 const float GUI_METER_MIN_DB = -60.f;
195 
198 #define FLT_EPSILON_PLUS 1.192092896e-07
199 
200 #define FLT_EPSILON_MINUS -1.192092896e-07
201 
202 #define FLT_MIN_PLUS 1.175494351e-38
203 
204 #define FLT_MIN_MINUS -1.175494351e-38
205 
206 // --- for math.h constants
207 #define _MATH_DEFINES_DEFINED
208 
222 enum class smoothingMethod { kLinearSmoother, kLPFSmoother };
223 
237 enum class taper { kLinearTaper, kLogTaper, kAntiLogTaper, kVoltOctaveTaper };
238 
252 enum class meterCal { kLinearMeter, kLogMeter };
253 
270 enum class controlVariableType { kFloat, kDouble, kInt, kTypedEnumStringList, kMeter, kNonVariableBoundControl };
271 
272 
286 enum class boundVariableType { kFloat, kDouble, kInt, kUInt };
287 
300 template <class T>
302 {
303 public:
304  ParamSmoother() { a = 0.0; b = 0.0; z = 0.0; z2 = 0.0; }
305 
309  void setSampleRate(T samplingRate)
310  {
311  sampleRate = samplingRate;
312 
313  // --- for LPF smoother
314  a = exp(-kTwoPi / (smoothingTimeInMSec * 0.001 * sampleRate));
315  b = 1.0 - a;
316 
317  // --- for linear smoother
318  linInc = (maxVal - minVal) / (smoothingTimeInMSec * 0.001 * sampleRate);
319  }
320 
329  void initParamSmoother(T smoothingTimeInMs,
330  T samplingRate,
331  T initValue,
332  T minControlValue,
333  T maxControlValue,
334  smoothingMethod smoother = smoothingMethod::kLPFSmoother)
335  {
336  minVal = minControlValue;
337  maxVal = maxControlValue;
338  sampleRate = samplingRate;
339  smoothingTimeInMSec = smoothingTimeInMs;
340 
341  setSampleRate(samplingRate);
342 
343  // --- storage
344  z = initValue;
345  z2 = initValue;
346  }
347 
353  inline bool smoothParameter(T in, T& out)
354  {
355  if (smootherType == smoothingMethod::kLPFSmoother)
356  {
357  z = (in * b) + (z * a);
358  if (z == z2)
359  {
360  out = in;
361  return false;
362  }
363  z2 = z;
364  out = z2;
365  return true;
366  }
367  else // if (smootherType == smoothingMethod::kLinearSmoother)
368  {
369  if (in == z)
370  {
371  out = in;
372  return false;
373  }
374  if (in > z)
375  {
376  z += linInc;
377  if (z > in) z = in;
378  }
379  else if (in < z)
380  {
381  z -= linInc;
382  if (z < in) z = in;
383  }
384  out = z;
385  return true;
386  }
387  }
388 
389 private:
390  T a = 0.0;
391  T b = 0.0;
392  T z = 0.0;
393  T z2 = 0.0;
394 
395  T linInc = 0.0;
396 
397  T minVal = 0.0;
398  T maxVal = 1.0;
399 
400  T sampleRate = 44100;
401  T smoothingTimeInMSec = 100.0;
402 
403  smoothingMethod smootherType = smoothingMethod::kLPFSmoother;
404 };
405 
406 
407 #endif
const unsigned int WRITE_PRESET_FILE
RESERVED PARAMETER ID VALUE.
Definition: guiconstants.h:29
void initParamSmoother(T smoothingTimeInMs, T samplingRate, T initValue, T minControlValue, T maxControlValue, smoothingMethod smoother=smoothingMethod::kLPFSmoother)
Definition: guiconstants.h:329
const double kCTCorrFactorAntiLogScale
concave/convex transform scaling factor
Definition: guiconstants.h:159
bool smoothParameter(T in, T &out)
Definition: guiconstants.h:353
const unsigned int PRESET_NAME
RESERVED PARAMETER ID VALUE.
Definition: guiconstants.h:28
const double kTwoPi
2pi to 80 decimal places
Definition: guiconstants.h:173
smoothingMethod
Use this strongly typed enum to easily set the smoothing type.
Definition: guiconstants.h:222
const double kCTCorrFactorZero
concave/convex transform correction factor at x = 0
Definition: guiconstants.h:124
The ParamSmoother object performs parameter smoothing on GUI control information. You can choose line...
Definition: guiconstants.h:301
const double kCTCorrFactorAntiLog
concave/convex transform correction factor
Definition: guiconstants.h:152
meterCal
Use this strongly typed enum to easily set meter calibration.
Definition: guiconstants.h:252
const uint32_t ENVELOPE_DETECT_MODE_PEAK
|x|
Definition: guiconstants.h:181
controlVariableType
Use this strongly typed enum to easily set the control&#39;s behavior; this tells the PluginParameter obj...
Definition: guiconstants.h:270
const double kPi
pi to 80 decimal places
Definition: guiconstants.h:166
const unsigned int VECTOR_JOYSTICK
RESERVED PARAMETER ID VALUE.
Definition: guiconstants.h:27
const float GUI_METER_UPDATE_INTERVAL_MSEC
repaint interval; larger = slower
Definition: guiconstants.h:193
bool isReservedTag(int tag)
check to see if a tag is reserved: ASPiK defines several reserved control ID values.
Definition: guiconstants.h:49
const double kCTCoefficient
concave and/or convex transform correction factor
Definition: guiconstants.h:117
const float ENVELOPE_DIGITAL_TC
ln(1%)
Definition: guiconstants.h:186
const float GUI_METER_MIN_DB
min GUI value in dB
Definition: guiconstants.h:194
const unsigned int SCALE_GUI_SIZE
RESERVED PARAMETER ID VALUE.
Definition: guiconstants.h:30
const unsigned int XY_TRACKPAD
RESERVED PARAMETER ID VALUE.
Definition: guiconstants.h:26
boundVariableType
Use this strongly typed enum to easily set the control&#39;s linked variable datatype (for automatic vari...
Definition: guiconstants.h:286
const double kCTCorrFactorAnitZero
inverse concave/convex transform factor at x = 0
Definition: guiconstants.h:131
const double kCTCorrFactorAntiUnity
inverse concave/convex transform correction factor at x = 1
Definition: guiconstants.h:145
const uint32_t ENVELOPE_DETECT_MODE_NONE
not used
Definition: guiconstants.h:184
const uint32_t ENVELOPE_DETECT_MODE_MS
(1/N)|x|^2
Definition: guiconstants.h:182
const unsigned int CUSTOM_VIEW_BASE
ID values for Custom Views (not necessarily required)
Definition: guiconstants.h:35
void setSampleRate(T samplingRate)
Definition: guiconstants.h:309
const uint32_t ENVELOPE_DETECT_MODE_RMS
SQRT((1/N)|x|^2)
Definition: guiconstants.h:183
const unsigned int PLUGIN_SIDE_BYPASS
RESERVED PARAMETER ID VALUE.
Definition: guiconstants.h:25
const double kCTCorrFactorUnity
concave/convex transform correction factor at x = 1
Definition: guiconstants.h:138
const float ENVELOPE_ANALOG_TC
ln(36.7%)
Definition: guiconstants.h:187
taper
Use this strongly typed enum to easily set the control taper.
Definition: guiconstants.h:237