24 #include <base/source/fstreamer.h> 25 #include <pluginterfaces/vst/vsttypes.h> 26 #include <pluginterfaces/vst/ivsteditcontroller.h> 27 #include <pluginterfaces/vst/ivstunits.h> 34 using namespace Steinberg;
35 using namespace Steinberg::Vst;
38 namespace GUI::Params {
39 class IGUIJmbParameter;
45 class IParamDef :
public std::enable_shared_from_this<IParamDef>
57 bool const iTransient) :
59 fTitle{std::move(iTitle)},
61 fTransient{iTransient}
64 virtual ~IParamDef() =
default;
83 ParamValue
const iDefaultNormalizedValue,
84 int32
const iStepCount,
88 int32
const iPrecision,
90 bool const iTransient) :
91 IParamDef(iParamID, std::move(iTitle), iOwner, iTransient),
92 fUnits{std::move(iUnits)},
93 fDefaultValue{
Utils::clampE(iDefaultNormalizedValue, 0.0, 1.0)},
94 fStepCount{iStepCount},
97 fShortTitle{std::move(iShortTitle)},
98 fPrecision{iPrecision}
105 ParamValue res = fDefaultValue;
115 virtual void toString(ParamValue iNormalizedValue, String128 iString)
const 126 virtual std::string
toUTF8String(ParamValue iNormalizedValue, int32 iPrecision)
const 158 UnitID
const iUnitID,
160 int32
const iPrecision,
162 bool const iTransient,
167 iConverter ? iConverter->normalize(iDefaultValue) : 0,
168 iConverter ? iConverter->getStepCount() : 0,
171 std::move(iShortTitle),
175 fDefaultValue{iDefaultValue},
176 fConverter{std::move(iConverter)}
187 return fConverter->normalize(iValue);
195 return fConverter->denormalize(iNormalizedValue);
196 return fDefaultValue;
202 void toString(ParamValue iNormalizedValue, String128 iString)
const override 205 fConverter->toString(fConverter->denormalize(iNormalizedValue), iString, fPrecision);
207 RawVstParamDef::toString(iNormalizedValue, iString);
216 std::string
toUTF8String(ParamValue iNormalizedValue, int32 iPrecision)
const override 222 fConverter->toString(fConverter->denormalize(iNormalizedValue), s, iPrecision >= 0 ? iPrecision : fPrecision);
231 const std::shared_ptr<IParamConverter<ParamType>>
fConverter;
243 bool const iTransient,
245 :
IParamDef(iParamID, std::move(iTitle), iOwner, iTransient),
249 ~IJmbParamDef()
override =
default;
252 virtual void writeDefaultValue(std::ostream &oStreamer)
const = 0;
257 virtual std::shared_ptr<GUI::Params::IGUIJmbParameter> newGUIParam() = 0;
262 virtual bool isSerializable()
const = 0;
281 bool const iTransient,
285 IJmbParamDef(iParamID, std::move(iTitle), iOwner, iTransient, iShared),
286 fDefaultValue{iDefaultValue},
287 fSerializer{std::move(iSerializer)}
291 tresult readFromStream(IBStreamer &iStreamer, ParamType &oValue)
const override;
292 ParamType readFromStream(IBStreamer &iStreamer)
const;
295 tresult writeToStream(ParamType
const &iValue, IBStreamer &oStreamer)
const override;
298 void writeToStream(ParamType
const &iValue, std::ostream &oStreamer)
const override;
301 void writeDefaultValue(std::ostream &oStreamer)
const override;
304 tresult readFromMessage(Message
const &iMessage, ParamType &oValue)
const;
307 tresult writeToMessage(ParamType
const &iValue, Message &oMessage)
const;
318 return fSerializer->toString(iValue, iPrecision);
336 return "__param__" + std::to_string(fParamID);
345 std::shared_ptr<GUI::Params::IGUIJmbParameter> newGUIParam()
override;
378 if(readFromStream(iStreamer, value) != kResultOk)
379 value = fDefaultValue;
412 writeToStream(fDefaultValue, oStreamer);
tresult readDouble(IBStreamer &iStreamer, double &oValue)
Definition: ParamSerializers.h:144
const std::shared_ptr< IParamConverter< ParamType > > fConverter
Definition: ParamDef.h:231
const ParamType fDefaultValue
Definition: ParamDef.h:353
virtual std::string toUTF8String(ParamValue iNormalizedValue, int32 iPrecision) const
Return the value as a utf-8 string.
Definition: ParamDef.h:126
void toString(ParamValue iNormalizedValue, String128 iString) const override
Using fConverter::toString
Definition: ParamDef.h:202
const std::shared_ptr< IParamSerializer< ParamType > > fSerializer
Definition: ParamDef.h:354
tresult writeToStream(ParamType const &iValue, IBStreamer &oStreamer) const override
Definition: ParamDef.h:388
Base class for a raw vst parameter definition.
Definition: ParamDef.h:77
const Owner fOwner
Definition: ParamDef.h:69
Simple wrapper class with better api.
Definition: Messaging.h:42
static T clampE(const U &value, const T &lower, const T &upper)
Same as clamp except it will actually fail/assert in debug mode.
Definition: Misc.h:58
const ParamID fParamID
Definition: ParamDef.h:67
ParamType denormalize(ParamValue iNormalizedValue) const
Definition: ParamDef.h:192
tresult setSerializableValue(IAttributeList::AttrID id, IParamSerializer< T > const &iSerializer, T const &iValue)
Serializes the parameter value as an entry in the message.
Definition: Messaging.h:163
const int32 fFlags
Definition: ParamDef.h:138
RawVstParamDef(ParamID const iParamID, VstString16 iTitle, VstString16 iUnits, ParamValue const iDefaultNormalizedValue, int32 const iStepCount, int32 const iFlags, UnitID const iUnitID, VstString16 iShortTitle, int32 const iPrecision, Owner const iOwner, bool const iTransient)
Definition: ParamDef.h:80
std::shared_ptr< RawVstParamDef > RawVstParam
Definition: ParamDef.h:444
std::string toUTF8String(T const &iValue, Steinberg::int32 iPrecision)
This generic function will determine (at compilation time) whether T can be written to an ostream and...
Definition: Utils.h:49
std::string toUTF8String(ParamValue iNormalizedValue, int32 iPrecision) const override
Return the value as a utf-8 string.
Definition: ParamDef.h:216
ParamValue readFromStream(IBStreamer &iStreamer) const
Definition: ParamDef.h:103
const VstString16 fUnits
Definition: ParamDef.h:135
const ParamType fDefaultValue
Definition: ParamDef.h:230
T ParamType
Definition: ParamDef.h:151
const int32 fStepCount
Definition: ParamDef.h:137
T ParamType
Definition: ParamDef.h:276
static void staticToString(ParamValue const &iValue, String128 oString, int32 iPrecision)
Definition: ParamConverters.h:94
const ParamValue fDefaultValue
Definition: ParamDef.h:136
IJmbParamDef(const ParamID iParamID, VstString16 iTitle, Owner const iOwner, bool const iTransient, bool const iShared)
Definition: ParamDef.h:240
const bool fTransient
Definition: ParamDef.h:70
std::basic_string< Steinberg::char16 > VstString16
Strings made of char16 characters are represented by the native C++11 type std::basic_string<Steinber...
Definition: Types.h:43
VstParamDef(ParamID const iParamID, VstString16 iTitle, VstString16 iUnits, ParamType const iDefaultValue, int32 const iFlags, UnitID const iUnitID, VstString16 iShortTitle, int32 const iPrecision, Owner const iOwner, bool const iTransient, std::shared_ptr< IParamConverter< ParamType >> iConverter)
Definition: ParamDef.h:153
const VstString16 fTitle
Definition: ParamDef.h:68
tresult readFromStream(IBStreamer &iStreamer, ParamType &oValue) const override
Definition: ParamDef.h:361
Interface that defines a converter from a type T to an int32 given a number of steps (provided by get...
Definition: ParamSerializers.h:45
const VstString16 fShortTitle
Definition: ParamDef.h:140
bool const fShared
Definition: ParamDef.h:265
A vst parameter is represented by a ParamValue type which is a double in the range [0,...
Definition: ParamSerializers.h:105
JmbParamDef(ParamID const iParamID, VstString16 iTitle, Owner const iOwner, bool const iTransient, bool const iShared, ParamType const &iDefaultValue, std::shared_ptr< IParamSerializer< ParamType >> iSerializer)
Definition: ParamDef.h:278
std::string computeMessageAttrID() const
Definition: ParamDef.h:334
Base class for all ParamDef.
Definition: ParamDef.h:45
ParamType getDefaultValue() const
Definition: ParamDef.h:181
std::shared_ptr< VstParamDef< T > > VstParam
Definition: ParamDef.h:443
ParamValue normalize(ParamType const &iValue) const
Definition: ParamDef.h:184
virtual void toString(ParamValue iNormalizedValue, String128 iString) const
Definition: ParamDef.h:115
Owner
Definition: ParamDef.h:48
Typed parameter definition.
Definition: ParamDef.h:148
const int32 fPrecision
Definition: ParamDef.h:141
IParamDef(ParamID const iParamID, VstString16 iTitle, Owner const iOwner, bool const iTransient)
Definition: ParamDef.h:54
bool isSerializable() const override
Definition: ParamDef.h:350
const UnitID fUnitID
Definition: ParamDef.h:139
std::string toUTF8String(ParamType const &iValue, int32 iPrecision) const
Return the value as a utf-8 string.
Definition: ParamDef.h:315
Base class for all non vst parameters (need to provide serialization/deserialization)
Definition: ParamDef.h:273
tresult getSerializableValue(IAttributeList::AttrID id, IParamSerializer< T > const &iSerializer, T &oValue) const
Deserializes the parameter value from an entry in the message.
Definition: Messaging.h:182
std::shared_ptr< JmbParamDef< T > > JmbParam
Definition: ParamDef.h:450
std::shared_ptr< IDiscreteConverter< T > > getDiscreteConverter() const
Definition: ParamDef.h:326
Base class for jamba parameters (non templated)
Definition: ParamDef.h:237
std::string toUT8String(VstString16 const &iString)
Converts a VstString16 to a regular std::string that is properly utf-8 encoded.
Definition: Utils.h:34
A vst parameter is represented by a ParamValue type which is a double in the range [0,...
Definition: ParamConverters.h:53