18 #ifndef __PONGASOFT_VST_PARAM_DEF_H__ 19 #define __PONGASOFT_VST_PARAM_DEF_H__ 25 #include <base/source/fstreamer.h> 26 #include <pluginterfaces/vst/vsttypes.h> 27 #include <pluginterfaces/vst/ivsteditcontroller.h> 28 #include <pluginterfaces/vst/ivstunits.h> 36 using namespace Steinberg;
37 using namespace Steinberg::Vst;
54 bool const iTransient) :
56 fTitle{std::move(iTitle)},
58 fTransient{iTransient}
78 ParamValue
const iDefaultNormalizedValue,
79 int32
const iStepCount,
83 int32
const iPrecision,
85 bool const iTransient) :
86 IParamDef(iParamID, std::move(iTitle), iOwner, iTransient),
87 fUnits{std::move(iUnits)},
88 fDefaultValue{
Utils::clampE(iDefaultNormalizedValue, 0.0, 1.0)},
89 fStepCount{iStepCount},
92 fShortTitle{std::move(iShortTitle)},
93 fPrecision{iPrecision}
100 ParamValue res = fDefaultValue;
110 virtual void toString(ParamValue iNormalizedValue, String128 iString)
const 139 UnitID
const iUnitID,
141 int32
const iPrecision,
143 bool const iTransient,
148 iConverter ? iConverter->normalize(iDefaultValue) : 0,
149 iConverter ? iConverter->getStepCount() : 0,
152 std::move(iShortTitle),
156 fDefaultValue{iDefaultValue},
157 fConverter{std::move(iConverter)}
168 return fConverter->normalize(iValue);
176 return fConverter->denormalize(iNormalizedValue);
177 return fDefaultValue;
183 void toString(ParamValue iNormalizedValue, String128 iString)
const override 186 fConverter->toString(fConverter->denormalize(iNormalizedValue), iString, fPrecision);
193 const std::shared_ptr<IParamConverter<ParamType>>
fConverter;
205 bool const iTransient,
207 :
IParamDef(iParamID, std::move(iTitle), iOwner, iTransient),
211 virtual ~IJmbParamDef() =
default;
214 virtual void writeDefaultValue(std::ostream &oStreamer)
const = 0;
233 bool const iTransient,
237 IJmbParamDef(iParamID, std::move(iTitle), iOwner, iTransient, iShared),
238 fDefaultValue{iDefaultValue},
239 fSerializer{std::move(iSerializer)}
243 tresult readFromStream(IBStreamer &iStreamer, ParamType &oValue)
const override;
244 ParamType readFromStream(IBStreamer &iStreamer)
const;
247 tresult writeToStream(ParamType
const &iValue, IBStreamer &oStreamer)
const override;
250 void writeToStream(ParamType
const &iValue, std::ostream &oStreamer)
const override;
253 void writeDefaultValue(std::ostream &oStreamer)
const override;
256 tresult readFromMessage(Message
const &iMessage, ParamType &oValue)
const;
259 tresult writeToMessage(ParamType
const &iValue, Message &oMessage)
const;
264 return "__param__" + std::to_string(fParamID);
280 return fSerializer->readFromStream(iStreamer, oValue);
293 if(readFromStream(iStreamer, value) != kResultOk)
294 value = fDefaultValue;
306 return fSerializer->writeToStream(iValue, oStreamer);
318 fSerializer->writeToStream(iValue, oStreamer);
327 writeToStream(fDefaultValue, oStreamer);
370 #endif // __PONGASOFT_VST_PARAM_DEF_H__ const UnitID fUnitID
Definition: ParamDef.h:120
const ParamType fDefaultValue
Definition: ParamDef.h:192
tresult readDouble(IBStreamer &iStreamer, double &oValue)
Definition: ParamSerializers.h:67
const Owner fOwner
Definition: ParamDef.h:64
const int32 fFlags
Definition: ParamDef.h:119
std::shared_ptr< VstParamDef< T > > VstParam
Definition: ParamDef.h:358
tresult readFromMessage(Message const &iMessage, ParamType &oValue) const
Definition: ParamDef.h:334
const ParamID fParamID
Definition: ParamDef.h:62
Definition: ParamDef.h:199
T ParamType
Definition: ParamDef.h:228
void toString(ParamValue iNormalizedValue, String128 iString) const override
Definition: ParamDef.h:183
tresult readFromStream(IBStreamer &iStreamer, ParamType &oValue) const override
Definition: ParamDef.h:276
Definition: Messaging.h:43
static T clampE(const U &value, const T &lower, const T &upper)
Definition: Misc.h:58
const int32 fStepCount
Definition: ParamDef.h:118
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:75
tresult getSerializableValue(IAttributeList::AttrID id, IParamSerializer< T > const &iSerializer, T &oValue) const
Definition: Messaging.h:178
ParamValue normalize(ParamType const &iValue) const
Definition: ParamDef.h:165
const bool fTransient
Definition: ParamDef.h:65
const int32 fPrecision
Definition: ParamDef.h:122
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:134
ParamType denormalize(ParamValue iNormalizedValue) const
Definition: ParamDef.h:173
std::basic_string< Steinberg::char16 > VstString16
Definition: Types.h:37
const std::shared_ptr< IParamSerializer< ParamType > > fSerializer
Definition: ParamDef.h:269
Definition: ParamDef.h:42
virtual void toString(ParamValue iNormalizedValue, String128 iString) const
Definition: ParamDef.h:110
tresult writeToMessage(ParamType const &iValue, Message &oMessage) const
Definition: ParamDef.h:346
ParamType getDefaultValue() const
Definition: ParamDef.h:162
std::shared_ptr< JmbParamDef< T > > JmbParam
Definition: ParamDef.h:365
const VstString16 fUnits
Definition: ParamDef.h:116
const VstString16 fTitle
Definition: ParamDef.h:63
const VstString16 fShortTitle
Definition: ParamDef.h:121
std::shared_ptr< RawVstParamDef > RawVstParam
Definition: ParamDef.h:359
IParamDef(ParamID const iParamID, VstString16 iTitle, Owner const iOwner, bool const iTransient)
Definition: ParamDef.h:51
void writeDefaultValue(std::ostream &oStreamer) const override
Definition: ParamDef.h:325
Definition: ParamDef.h:72
tresult writeToStream(ParamType const &iValue, IBStreamer &oStreamer) const override
Definition: ParamDef.h:303
bool const fShared
Definition: ParamDef.h:217
Definition: ParamSerializers.h:43
Owner
Definition: ParamDef.h:45
tresult setSerializableValue(IAttributeList::AttrID id, IParamSerializer< T > const &iSerializer, T const &iValue)
Definition: Messaging.h:159
IJmbParamDef(const ParamID iParamID, VstString16 iTitle, Owner const iOwner, bool const iTransient, bool const iShared)
Definition: ParamDef.h:202
const std::shared_ptr< IParamConverter< ParamType > > fConverter
Definition: ParamDef.h:193
T ParamType
Definition: ParamDef.h:132
static void staticToString(ParamValue const &iValue, String128 oString, int32 iPrecision)
Definition: ParamConverters.h:92
Definition: ParamDef.h:129
const ParamType fDefaultValue
Definition: ParamDef.h:268
Definition: ParamDef.h:225
std::string computeMessageAttrID() const
Definition: ParamDef.h:262
ParamValue readFromStream(IBStreamer &iStreamer) const
Definition: ParamDef.h:98
const ParamValue fDefaultValue
Definition: ParamDef.h:117
Definition: ParamConverters.h:52
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:230