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;
52 TChar
const *
const iTitle,
54 bool const iTransient) :
58 fTransient{iTransient}
76 TChar
const *
const iTitle,
77 TChar
const *
const iUnits,
78 ParamValue
const iDefaultNormalizedValue,
79 int32
const iStepCount,
82 TChar
const *
const iShortTitle,
83 int32
const iPrecision,
85 bool const iTransient) :
86 IParamDef(iParamID, iTitle, iOwner, iTransient),
88 fDefaultValue{
Utils::clampE(iDefaultNormalizedValue, 0.0, 1.0)},
89 fStepCount{iStepCount},
92 fShortTitle{iShortTitle},
93 fPrecision{iPrecision}
100 ParamValue res = fDefaultValue;
110 virtual void toString(ParamValue iNormalizedValue, String128 iString)
const 135 TChar
const *
const iTitle,
136 TChar
const *
const iUnits,
139 UnitID
const iUnitID,
140 TChar
const *
const iShortTitle,
141 int32
const iPrecision,
143 bool const iTransient,
148 iConverter ? iConverter->normalize(iDefaultValue) : 0,
149 iConverter ? iConverter->getStepCount() : 0,
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;
203 const TChar *
const iTitle,
205 bool const iTransient,
207 :
IParamDef(iParamID, iTitle, iOwner, iTransient),
211 virtual ~IJmbParamDef() =
default;
214 virtual void writeDefaultValue(std::ostream &oStreamer)
const = 0;
231 TChar
const *
const iTitle,
233 bool const iTransient,
237 IJmbParamDef(iParamID, 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
const TChar *const fUnits
Definition: ParamDef.h:116
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
JmbParamDef(ParamID const iParamID, TChar const *const iTitle, Owner const iOwner, bool const iTransient, bool const iShared, ParamType const &iDefaultValue, std::shared_ptr< IParamSerializer< ParamType >> iSerializer)
Definition: ParamDef.h:230
const int32 fStepCount
Definition: ParamDef.h:118
IJmbParamDef(const ParamID iParamID, const TChar *const iTitle, Owner const iOwner, bool const iTransient, bool const iShared)
Definition: ParamDef.h:202
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
ParamType denormalize(ParamValue iNormalizedValue) const
Definition: ParamDef.h:173
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 TChar *const fTitle
Definition: ParamDef.h:63
std::shared_ptr< RawVstParamDef > RawVstParam
Definition: ParamDef.h:359
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
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:90
const TChar *const fShortTitle
Definition: ParamDef.h:121
RawVstParamDef(ParamID const iParamID, TChar const *const iTitle, TChar const *const iUnits, ParamValue const iDefaultNormalizedValue, int32 const iStepCount, int32 const iFlags, UnitID const iUnitID, TChar const *const iShortTitle, int32 const iPrecision, Owner const iOwner, bool const iTransient)
Definition: ParamDef.h:75
Definition: ParamDef.h:129
VstParamDef(ParamID const iParamID, TChar const *const iTitle, TChar const *const iUnits, ParamType const iDefaultValue, int32 const iFlags, UnitID const iUnitID, TChar const *const iShortTitle, int32 const iPrecision, Owner const iOwner, bool const iTransient, std::shared_ptr< IParamConverter< ParamType >> iConverter)
Definition: ParamDef.h:134
const ParamType fDefaultValue
Definition: ParamDef.h:268
Definition: ParamDef.h:225
std::string computeMessageAttrID() const
Definition: ParamDef.h:262
IParamDef(ParamID const iParamID, TChar const *const iTitle, Owner const iOwner, bool const iTransient)
Definition: ParamDef.h:51
ParamValue readFromStream(IBStreamer &iStreamer) const
Definition: ParamDef.h:98
const ParamValue fDefaultValue
Definition: ParamDef.h:117
Definition: ParamConverters.h:50