ASPiK SDK
Loading...
Searching...
No Matches
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
25const unsigned int PLUGIN_SIDE_BYPASS = 131072;
26const unsigned int XY_TRACKPAD = 131073;
27const unsigned int VECTOR_JOYSTICK = 131074;
28const unsigned int PRESET_NAME = 131075;
29const unsigned int WRITE_PRESET_FILE = 131076;
30const 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;
35const unsigned int CUSTOM_VIEW_BASE = 132000;
36
37// --- enum for the GUI object's message processing
38enum { tinyGUI, verySmallGUI, smallGUI, normalGUI, largeGUI, veryLargeGUI };
39
49inline bool isReservedTag(int tag)
50{
51 // --- these are reserved
52 if (tag >= 131072 && tag <= 131999)
53 return true;
54 return false;
55}
56
67inline bool isBonusParameter(int tag)
68{
69 // --- these are reserved
70 if (tag == XY_TRACKPAD ||
71 tag == VECTOR_JOYSTICK ||
72 tag == PRESET_NAME ||
73 tag == WRITE_PRESET_FILE ||
74 tag == SCALE_GUI_SIZE)
75 return true;
76
77 return false;
78}
79
80// --- typed enumeration helpers
90#define enumToInt(ENUM) static_cast<int>(ENUM)
91
102#define compareEnumToInt(ENUM,INT) (static_cast<int>(ENUM) == (INT))
103
115#define compareIntToEnum(INT,ENUM) ((INT) == static_cast<int>(ENUM))
116
128#define convertIntToEnum(INT,ENUM) static_cast<ENUM>(INT)
129
135const double kCTCoefficient = 5.0 / 12.0;
136
142const double kCTCorrFactorZero = pow(10.0, (-1.0/kCTCoefficient));
143
149const double kCTCorrFactorAnitZero = 1.0 / (1.0 - kCTCorrFactorZero);
150
156const double kCTCorrFactorUnity = 1.0 / (1.0 + kCTCoefficient*log10(1.0 + kCTCorrFactorZero));
157
163const double kCTCorrFactorAntiUnity = 1.0 / (1.0 + (-pow(10.0, (-1.0/kCTCoefficient))));
164
171
178
184const double kPi = 3.14159265358979323846264338327950288419716939937510582097494459230781640628620899;
185
191const double kTwoPi = 2.0*3.14159265358979323846264338327950288419716939937510582097494459230781640628620899;
192
193//-----------------------------------------------------------------------------
195//-----------------------------------------------------------------------------
198// ---
199const uint32_t ENVELOPE_DETECT_MODE_PEAK = 0;
200const uint32_t ENVELOPE_DETECT_MODE_MS = 1;
201const uint32_t ENVELOPE_DETECT_MODE_RMS = 2;
202const uint32_t ENVELOPE_DETECT_MODE_NONE = 3;
203
204const float ENVELOPE_DIGITAL_TC = -4.6051701859880913680359829093687;
205const float ENVELOPE_ANALOG_TC = -1.0023934309275667804345424248947;
210// ---
212const float GUI_METER_MIN_DB = -60.f;
216#define FLT_EPSILON_PLUS 1.192092896e-07
218#define FLT_EPSILON_MINUS -1.192092896e-07
220#define FLT_MIN_PLUS 1.175494351e-38
222#define FLT_MIN_MINUS -1.175494351e-38
223
224// --- for math.h constants
225#define _MATH_DEFINES_DEFINED
226
240enum class smoothingMethod { kLinearSmoother, kLPFSmoother };
241
255enum class taper { kLinearTaper, kLogTaper, kAntiLogTaper, kVoltOctaveTaper };
256
270enum class meterCal { kLinearMeter, kLogMeter };
271
288enum class controlVariableType { kFloat, kDouble, kInt, kTypedEnumStringList, kMeter, kNonVariableBoundControl };
289
290
304enum class boundVariableType { kFloat, kDouble, kInt, kUInt };
305
318template <class T>
320{
321public:
322 ParamSmoother() { a = 0.0; b = 0.0; z = 0.0; z2 = 0.0; }
323
327 void setSampleRate(T samplingRate)
328 {
329 sampleRate = samplingRate;
330
331 // --- for LPF smoother
332 a = exp(-kTwoPi / (smoothingTimeInMSec * 0.001 * sampleRate));
333 b = 1.0 - a;
334
335 // --- for linear smoother
336 linInc = (maxVal - minVal) / (smoothingTimeInMSec * 0.001 * sampleRate);
337 }
338
347 void initParamSmoother(T smoothingTimeInMs,
348 T samplingRate,
349 T initValue,
350 T minControlValue,
351 T maxControlValue,
352 smoothingMethod smoother = smoothingMethod::kLPFSmoother)
353 {
354 minVal = minControlValue;
355 maxVal = maxControlValue;
356 sampleRate = samplingRate;
357 smoothingTimeInMSec = smoothingTimeInMs;
358
359 setSampleRate(samplingRate);
360
361 // --- storage
362 z = initValue;
363 z2 = initValue;
364 }
365
371 inline bool smoothParameter(T in, T& out)
372 {
373 if (smootherType == smoothingMethod::kLPFSmoother)
374 {
375 z = (in * b) + (z * a);
376 if (z == z2)
377 {
378 out = in;
379 return false;
380 }
381 z2 = z;
382 out = z2;
383 return true;
384 }
385 else // if (smootherType == smoothingMethod::kLinearSmoother)
386 {
387 if (in == z)
388 {
389 out = in;
390 return false;
391 }
392 if (in > z)
393 {
394 z += linInc;
395 if (z > in) z = in;
396 }
397 else if (in < z)
398 {
399 z -= linInc;
400 if (z < in) z = in;
401 }
402 out = z;
403 return true;
404 }
405 }
406
407private:
408 T a = 0.0;
409 T b = 0.0;
410 T z = 0.0;
411 T z2 = 0.0;
412
413 T linInc = 0.0;
414
415 T minVal = 0.0;
416 T maxVal = 1.0;
417
418 T sampleRate = 44100;
419 T smoothingTimeInMSec = 100.0;
420
421 smoothingMethod smootherType = smoothingMethod::kLPFSmoother;
422};
423
424
425#endif
The ParamSmoother object performs parameter smoothing on GUI control information. You can choose line...
Definition: guiconstants.h:320
bool smoothParameter(T in, T &out)
Definition: guiconstants.h:371
void setSampleRate(T samplingRate)
Definition: guiconstants.h:327
void initParamSmoother(T smoothingTimeInMs, T samplingRate, T initValue, T minControlValue, T maxControlValue, smoothingMethod smoother=smoothingMethod::kLPFSmoother)
Definition: guiconstants.h:347
bool isReservedTag(int tag)
check to see if a tag is reserved: ASPiK defines several reserved control ID values.
Definition: guiconstants.h:49
bool isBonusParameter(int tag)
check to see if a tag is Bonus Parameter: these should NOT be added to API parameter lists
Definition: guiconstants.h:67
const double kCTCorrFactorUnity
concave/convex transform correction factor at x = 1
Definition: guiconstants.h:156
const double kCTCorrFactorAntiLogScale
concave/convex transform scaling factor
Definition: guiconstants.h:177
const double kCTCorrFactorAnitZero
inverse concave/convex transform factor at x = 0
Definition: guiconstants.h:149
const float ENVELOPE_DIGITAL_TC
ln(1%)
Definition: guiconstants.h:204
const double kCTCoefficient
concave and/or convex transform correction factor
Definition: guiconstants.h:135
smoothingMethod
Use this strongly typed enum to easily set the smoothing type.
Definition: guiconstants.h:240
const double kCTCorrFactorAntiUnity
inverse concave/convex transform correction factor at x = 1
Definition: guiconstants.h:163
controlVariableType
Use this strongly typed enum to easily set the control's behavior; this tells the PluginParameter obj...
Definition: guiconstants.h:288
meterCal
Use this strongly typed enum to easily set meter calibration.
Definition: guiconstants.h:270
boundVariableType
Use this strongly typed enum to easily set the control's linked variable datatype (for automatic vari...
Definition: guiconstants.h:304
const double kTwoPi
2pi to 80 decimal places
Definition: guiconstants.h:191
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
const uint32_t ENVELOPE_DETECT_MODE_RMS
SQRT((1/N)|x|^2)
Definition: guiconstants.h:201
taper
Use this strongly typed enum to easily set the control taper.
Definition: guiconstants.h:255
const float GUI_METER_UPDATE_INTERVAL_MSEC
repaint interval; larger = slower
Definition: guiconstants.h:211
const uint32_t ENVELOPE_DETECT_MODE_MS
(1/N)|x|^2
Definition: guiconstants.h:200
const uint32_t ENVELOPE_DETECT_MODE_PEAK
|x|
Definition: guiconstants.h:199
const float ENVELOPE_ANALOG_TC
ln(36.7%)
Definition: guiconstants.h:205
const double kPi
pi to 80 decimal places
Definition: guiconstants.h:184
const uint32_t ENVELOPE_DETECT_MODE_NONE
not used
Definition: guiconstants.h:202
const unsigned int PLUGIN_SIDE_BYPASS
RESERVED PARAMETER ID VALUE.
Definition: guiconstants.h:25
const unsigned int WRITE_PRESET_FILE
RESERVED PARAMETER ID VALUE.
Definition: guiconstants.h:29
const unsigned int SCALE_GUI_SIZE
RESERVED PARAMETER ID VALUE.
Definition: guiconstants.h:30
const unsigned int VECTOR_JOYSTICK
RESERVED PARAMETER ID VALUE.
Definition: guiconstants.h:27
const float GUI_METER_MIN_DB
min GUI value in dB
Definition: guiconstants.h:212
const unsigned int XY_TRACKPAD
RESERVED PARAMETER ID VALUE.
Definition: guiconstants.h:26
const unsigned int CUSTOM_VIEW_BASE
ID values for Custom Views (not necessarily required)
Definition: guiconstants.h:35
const unsigned int PRESET_NAME
RESERVED PARAMETER ID VALUE.
Definition: guiconstants.h:28