ASPiK SDK
Loading...
Searching...
No Matches
customparameters.h
Go to the documentation of this file.
1// -----------------------------------------------------------------------------
2// ASPiK VST Shell File: customparameters.h
3//
17// -----------------------------------------------------------------------------
18#pragma once
19#include "public.sdk/source/vst/vstparameters.h"
20#include "pluginterfaces/base/ibstream.h"
21#include "pluginterfaces/vst/ivstparameterchanges.h"
22#include "public.sdk/source/vst/vstaudioeffect.h"
23#include "pluginterfaces/base/ustring.h"
24#include "guiconstants.h"
25#include "math.h"
26
27namespace Steinberg {
28namespace Vst {
29namespace ASPiK {
30
42class PeakParameter : public Parameter
43{
44public:
45 PeakParameter (int32 flags, int32 id, const TChar* title);
46
47 virtual void toString (ParamValue normValue, String128 string) const;
48 virtual bool fromString (const TChar* string, ParamValue& normValue) const;
49};
50
51
63class LogParameter : public Parameter
64{
65public:
66 LogParameter(const TChar* title, ParamID tag, const TChar* units = 0,
67 ParamValue minPlain = 0., ParamValue maxPlain = 1., ParamValue defaultValuePlain = 0.,
68 int32 stepCount = 0, int32 flags = ParameterInfo::kCanAutomate, UnitID unitID = kRootUnitId);
69
70 virtual void toString (ParamValue normValue, String128 string) const;
71 virtual bool fromString (const TChar* string, ParamValue& normValue) const;
72 virtual ParamValue toPlain(ParamValue _valueNormalized) const;
73 virtual ParamValue toNormalized(ParamValue plainValue) const;
74 virtual ParamValue getMin () const {return minPlain;}
75 virtual void setMin (ParamValue value) {minPlain = value;}
76 virtual ParamValue getMax () const {return maxPlain;}
77 virtual void setMax (ParamValue value) {maxPlain = value;}
78
79protected:
80 ParamValue minPlain;
81 ParamValue maxPlain;
82
83 // fNormalizedParam = 0->1
84 // returns anti-log scaled 0->1 value
85 inline float calcLogParameter(float fNormalizedParam) const
86 {
87 if(fNormalizedParam <= 0.0) return 0.0;
88 if(fNormalizedParam >= 1.0) return 1.0;
89
90 // --- MMA Convex Transform Inverse
91 return kCTCorrFactorAnitZero * ( pow (10.0, (fNormalizedParam - 1.0) / kCTCoefficient) - kCTCorrFactorZero);
92 }
93
94 // fPluginValue = 0->1 log scaled value
95 // returns normal 0->1 value
96 inline float calcLogPluginValue(float fPluginValue) const
97 {
98 if(fPluginValue <= 0.0) return 0.0;
99 if(fPluginValue >= 1.0) return 1.0;
100
101 // --- MMA Convex Transform
102 return kCTCorrFactorUnity*(1.0 + kCTCoefficient*log10(fPluginValue + kCTCorrFactorZero));
103 }
104
105
106};
107
119class AntiLogParameter : public Parameter
120{
121public:
122 AntiLogParameter(const TChar* title, ParamID tag, const TChar* units = 0,
123 ParamValue minPlain = 0., ParamValue maxPlain = 1., ParamValue defaultValuePlain = 0.,
124 int32 stepCount = 0, int32 flags = ParameterInfo::kCanAutomate, UnitID unitID = kRootUnitId);
125
126 virtual void toString (ParamValue normValue, String128 string) const;
127 virtual bool fromString (const TChar* string, ParamValue& normValue) const;
128 virtual ParamValue toPlain(ParamValue _valueNormalized) const;
129 virtual ParamValue toNormalized(ParamValue plainValue) const;
130 virtual ParamValue getMin () const {return minPlain;}
131 virtual void setMin (ParamValue value) {minPlain = value;}
132 virtual ParamValue getMax () const {return maxPlain;}
133 virtual void setMax (ParamValue value) {maxPlain = value;}
134
135protected:
136 ParamValue minPlain;
137 ParamValue maxPlain;
138
139 // fNormalizedParam = 0->1
140 // returns anti-log scaled 0->1 value
141 inline float calcAntiLogParameter(float fNormalizedParam) const
142 {
143 if(fNormalizedParam <= 0.0) return 0.0;
144 if(fNormalizedParam >= 1.0) return 1.0;
145
146 // --- MMA Concave Transform Inverse
147 return (kCTCorrFactorAntiUnity)*(-pow(10.0, (-fNormalizedParam / kCTCoefficient)) + 1.0);
148 }
149
150 // fPluginValue = 0->1 log scaled value
151 // returns normal 0->1 value
152 inline float calcAntiLogPluginValue(float fPluginValue) const
153 {
154 if(fPluginValue <= 0.0) return 0.0;
155 if(fPluginValue >= 1.0) return 1.0;
156
157 // --- MMA Concave Transform
158 float transformed = -kCTCoefficient*kCTCorrFactorAntiLogScale*log10(1.0 - fPluginValue + kCTCorrFactorZero) + kCTCorrFactorAntiLog;
159 if(transformed >= 1.0) transformed = 1.0;
160 return transformed;
161 }
162};
163
176class VoltOctaveParameter : public Parameter
177{
178public:
179 VoltOctaveParameter(const TChar* title, ParamID tag, const TChar* units = 0,
180 ParamValue minPlain = 0., ParamValue maxPlain = 1., ParamValue defaultValuePlain = 0.,
181 int32 stepCount = 0, int32 flags = ParameterInfo::kCanAutomate, UnitID unitID = kRootUnitId);
182
183 virtual void toString (ParamValue normValue, String128 string) const;
184 virtual bool fromString (const TChar* string, ParamValue& normValue) const;
185 virtual ParamValue toPlain(ParamValue _valueNormalized) const;
186 virtual ParamValue toNormalized(ParamValue plainValue) const;
187 virtual ParamValue getMin () const {return minPlain;}
188 virtual void setMin (ParamValue value) {minPlain = value;}
189 virtual ParamValue getMax () const {return maxPlain;}
190 virtual void setMax (ParamValue value) {maxPlain = value;}
191
192protected:
193 ParamValue minPlain;
194 ParamValue maxPlain;
195
196 // cooked to VA Scaled 0->1 param
197 inline float calcVoltOctaveParameter(float fCookedParam) const
198 {
199 double dOctaves = log2(getMax()/getMin());
200 return log2( fCookedParam/getMin() )/dOctaves;
201 }
202
203 // fPluginValue = 0->1
204 // returns VA scaled version 0->1
205 inline float calcVoltOctavePluginValue(float fPluginValue) const
206 {
207 double dOctaves = log2(getMax()/getMin());
208 float fDisplay = getMin()*exp2(fPluginValue*dOctaves);
209 float fDiff = getMax() - getMin();
210 return (fDisplay - getMin())/fDiff;
211 }
212};
213
214
215}}}
The AntiLogParameter object encapsulates an anti-log parameter. Note that the standard log potentiome...
Definition: customparameters.h:120
The LogParameter object encapsulates a log parameter. Note that the standard log potentiometer in ele...
Definition: customparameters.h:64
The PeakParameter object encapsulates a uni-polar parameter such as a metering variable.
Definition: customparameters.h:43
The VoltOctaveParameter object encapsulates a Volt-per-Octave parameter for emulating analog synthesi...
Definition: customparameters.h:177
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 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