JUCE-7.0.12-0-g4f43011b96 JUCE-7.0.12-0-g4f43011b96
JUCE — C++ application framework with suport for VST, VST3, LV2 audio plug-ins

« « « Anklang Documentation
Loading...
Searching...
No Matches
vstparameters.h
Go to the documentation of this file.
1 //------------------------------------------------------------------------
2// Project : VST SDK
3//
4// Category : Helpers
5// Filename : public.sdk/source/vst/vstparameters.h
6// Created by : Steinberg, 03/2008
7// Description : VST Parameter Implementation
8//
9//-----------------------------------------------------------------------------
10// LICENSE
11// (c) 2023, Steinberg Media Technologies GmbH, All Rights Reserved
12//-----------------------------------------------------------------------------
13// Redistribution and use in source and binary forms, with or without modification,
14// are permitted provided that the following conditions are met:
15//
16// * Redistributions of source code must retain the above copyright notice,
17// this list of conditions and the following disclaimer.
18// * Redistributions in binary form must reproduce the above copyright notice,
19// this list of conditions and the following disclaimer in the documentation
20// and/or other materials provided with the distribution.
21// * Neither the name of the Steinberg Media Technologies nor the names of its
22// contributors may be used to endorse or promote products derived from this
23// software without specific prior written permission.
24//
25// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
26// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
27// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
28// IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
29// INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
30// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
31// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
32// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
33// OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
34// OF THE POSSIBILITY OF SUCH DAMAGE.
35//-----------------------------------------------------------------------------
36
37#pragma once
38
39#include "base/source/fobject.h"
42
43#include <map>
44#include <vector>
45
46//------------------------------------------------------------------------
47namespace Steinberg {
48namespace Vst {
49
50//------------------------------------------------------------------------
54class Parameter : public FObject
55{
56public:
57//------------------------------------------------------------------------
58 Parameter ();
59 Parameter (const ParameterInfo&);
60 Parameter (const TChar* title, ParamID tag, const TChar* units = nullptr,
61 ParamValue defaultValueNormalized = 0., int32 stepCount = 0,
62 int32 flags = ParameterInfo::kCanAutomate, UnitID unitID = kRootUnitId,
63 const TChar* shortTitle = nullptr);
64 ~Parameter () override;
65
67 virtual const ParameterInfo& getInfo () const { return info; }
68
70 virtual ParameterInfo& getInfo () { return info; }
71
73 virtual void setUnitID (UnitID id) { info.unitId = id; }
75 virtual UnitID getUnitID () { return info.unitId; }
76
78 ParamValue getNormalized () const { return valueNormalized; }
80 virtual bool setNormalized (ParamValue v);
81
83 virtual void toString (ParamValue valueNormalized, String128 string) const;
85 virtual bool fromString (const TChar* string, ParamValue& valueNormalized) const;
86
88 virtual ParamValue toPlain (ParamValue valueNormalized) const;
90 virtual ParamValue toNormalized (ParamValue plainValue) const;
91
93 virtual int32 getPrecision () const { return precision; }
96 virtual void setPrecision (int32 val) { precision = val; }
97
98 OBJ_METHODS (Parameter, FObject)
99//------------------------------------------------------------------------
100protected:
101 ParameterInfo info {0};
102 ParamValue valueNormalized {0.};
103 int32 precision {4};
104};
105
106//------------------------------------------------------------------------
111{
112public:
113//------------------------------------------------------------------------
114 RangeParameter (const ParameterInfo& paramInfo, ParamValue min, ParamValue max);
115 RangeParameter (const TChar* title, ParamID tag, const TChar* units = nullptr,
116 ParamValue minPlain = 0., ParamValue maxPlain = 1.,
117 ParamValue defaultValuePlain = 0., int32 stepCount = 0,
118 int32 flags = ParameterInfo::kCanAutomate, UnitID unitID = kRootUnitId,
119 const TChar* shortTitle = nullptr);
120
122 virtual ParamValue getMin () const { return minPlain; }
124 virtual void setMin (ParamValue value) { minPlain = value; }
126 virtual ParamValue getMax () const { return maxPlain; }
128 virtual void setMax (ParamValue value) { maxPlain = value; }
129
131 void toString (ParamValue _valueNormalized, String128 string) const SMTG_OVERRIDE;
133 bool fromString (const TChar* string, ParamValue& _valueNormalized) const SMTG_OVERRIDE;
134
136 ParamValue toPlain (ParamValue _valueNormalized) const SMTG_OVERRIDE;
138 ParamValue toNormalized (ParamValue plainValue) const SMTG_OVERRIDE;
139
140 OBJ_METHODS (RangeParameter, Parameter)
141//------------------------------------------------------------------------
142protected:
144
145 ParamValue minPlain;
146 ParamValue maxPlain;
147};
148
149//------------------------------------------------------------------------
154{
155public:
156//------------------------------------------------------------------------
157 StringListParameter (const ParameterInfo& paramInfo);
158 StringListParameter (const TChar* title, ParamID tag, const TChar* units = nullptr,
160 UnitID unitID = kRootUnitId, const TChar* shortTitle= nullptr);
161 ~StringListParameter () override;
162
164 virtual void appendString (const String128 string);
166 virtual bool replaceString (int32 index, const String128 string);
167
169 void toString (ParamValue _valueNormalized, String128 string) const SMTG_OVERRIDE;
171 bool fromString (const TChar* string, ParamValue& _valueNormalized) const SMTG_OVERRIDE;
172
174 ParamValue toPlain (ParamValue _valueNormalized) const SMTG_OVERRIDE;
176 ParamValue toNormalized (ParamValue plainValue) const SMTG_OVERRIDE;
177
178 OBJ_METHODS (StringListParameter, Parameter)
179//------------------------------------------------------------------------
180protected:
182 StringVector strings;
183};
184
185//------------------------------------------------------------------------
190{
191public:
192//------------------------------------------------------------------------
195
197 void init (int32 initialSize = 10, int32 resizeDelta = 100);
198
200 Parameter* addParameter (const ParameterInfo& info);
201
203 Parameter* addParameter (const TChar* title, const TChar* units = nullptr, int32 stepCount = 0,
204 ParamValue defaultValueNormalized = 0.,
205 int32 flags = ParameterInfo::kCanAutomate, int32 tag = -1,
206 UnitID unitID = kRootUnitId, const TChar* shortTitle = nullptr);
207
210
212 int32 getParameterCount () const { return params ? static_cast<int32> (params->size ()) : 0; }
213
215 Parameter* getParameterByIndex (int32 index) const;
216
218 void removeAll ()
219 {
220 if (params)
221 params->clear ();
222 id2index.clear ();
223 }
224
226 Parameter* getParameter (ParamID tag) const;
227
229 bool removeParameter (ParamID tag);
230 //------------------------------------------------------------------------
231protected:
232 using ParameterPtrVector = std::vector<IPtr<Parameter>>;
234 ParameterPtrVector* params {nullptr};
235 IndexMap id2index;
236};
237
238//------------------------------------------------------------------------
239} // namespace Vst
240} // namespace Steinberg
Implements FUnknown and IDependent.
Definition fobject.h:84
Collection of parameters.
int32 getParameterCount() const
Returns the count of parameters.
void init(int32 initialSize=10, int32 resizeDelta=100)
Init param array.
bool removeParameter(ParamID tag)
Remove a specific parameter by ID.
Parameter * getParameter(ParamID tag) const
Gets parameter by ID.
Parameter * addParameter(const ParameterInfo &info)
Creates and adds a new parameter from a ParameterInfo.
void removeAll()
Removes all parameters.
Parameter * getParameterByIndex(int32 index) const
Gets parameter by index.
Description of a Parameter.
virtual ParamValue toNormalized(ParamValue plainValue) const
Converts a plain value to a normalized value (e.g.
virtual bool setNormalized(ParamValue v)
Sets its normalized value [0.0, 1.0].
virtual ParameterInfo & getInfo()
Returns its writable info.
virtual ParamValue toPlain(ParamValue valueNormalized) const
Converts a normalized value to plain value (e.g.
virtual bool fromString(const TChar *string, ParamValue &valueNormalized) const
Converts a string to a normalized value.
ParamValue getNormalized() const
Gets its normalized value [0.0, 1.0].
virtual void toString(ParamValue valueNormalized, String128 string) const
Converts a normalized value to a string.
virtual const ParameterInfo & getInfo() const
Returns its read only info.
virtual void setPrecision(int32 val)
Sets the precision for string representation of float value (for example 4.34 with 2 as precision).
virtual int32 getPrecision() const
Gets the current precision (used for string representation of float).
virtual UnitID getUnitID()
Gets its associated UnitId.
virtual void setUnitID(UnitID id)
Sets its associated UnitId.
Description of a RangeParameter.
ParamValue toPlain(ParamValue _valueNormalized) const SMTG_OVERRIDE
Converts a normalized value to plain value (e.g.
virtual ParamValue getMin() const
Gets the minimum plain value, same as toPlain (0).
void toString(ParamValue _valueNormalized, String128 string) const SMTG_OVERRIDE
Converts a normalized value to a string.
ParamValue toNormalized(ParamValue plainValue) const SMTG_OVERRIDE
Converts a plain value to a normalized value (e.g.
virtual ParamValue getMax() const
Gets the maximum plain value, same as toPlain (1).
virtual void setMin(ParamValue value)
Sets the minimum plain value.
bool fromString(const TChar *string, ParamValue &_valueNormalized) const SMTG_OVERRIDE
Converts a string to a normalized value.
virtual void setMax(ParamValue value)
Sets the maximum plain value.
Description of a StringListParameter.
void toString(ParamValue _valueNormalized, String128 string) const SMTG_OVERRIDE
Converts a normalized value to a string.
virtual bool replaceString(int32 index, const String128 string)
Replaces the string at index.
ParamValue toNormalized(ParamValue plainValue) const SMTG_OVERRIDE
Converts a plain value to a normalized value (e.g.
virtual void appendString(const String128 string)
Appends a string and increases the stepCount.
bool fromString(const TChar *string, ParamValue &_valueNormalized) const SMTG_OVERRIDE
Converts a string to a normalized value.
ParamValue toPlain(ParamValue _valueNormalized) const SMTG_OVERRIDE
Converts a normalized value to plain value (e.g.
T clear(T... args)
Basic Object implementing FUnknown.
uint32 ParamID
parameter identifier
Definition vsttypes.h:81
TChar String128[128]
128 character UTF-16 string
Definition vsttypes.h:69
char16 TChar
UTF-16 character.
Definition vsttypes.h:68
double ParamValue
parameter value type
Definition vsttypes.h:80
int32 UnitID
unit identifier
Definition vsttypes.h:79
T size(T... args)
Controller Parameter Info.
UnitID unitId
id of unit this parameter belongs to (see vst3Units)
@ kIsList
parameter should be displayed as list in generic editor or automation editing [SDK 3....
@ kCanAutomate
parameter can be automated