26#include <base/source/fstreamer.h>
27#include <pluginterfaces/vst/vsttypes.h>
28#include <pluginterfaces/vst/ivsteditcontroller.h>
29#include <pluginterfaces/vst/ivstunits.h>
36using namespace Steinberg;
37using namespace Steinberg::Vst;
47class IParamDef :
public std::enable_shared_from_this<IParamDef>
65 bool const iTransient,
66 int16
const iDeprecatedSince) :
97 ParamValue
const iDefaultNormalizedValue,
98 int32
const iStepCount,
100 UnitID
const iUnitID,
102 int32
const iPrecision,
104 bool const iTransient,
105 int16
const iDeprecatedSince) :
106 IParamDef(iParamID, std::move(iTitle), iOwner, iTransient, iDeprecatedSince),
107 fUnits{std::move(iUnits)},
144 virtual void toString(ParamValue iNormalizedValue, String128 iString)
const
155 virtual std::string
toUTF8String(ParamValue iNormalizedValue, int32 iPrecision)
const
187 UnitID
const iUnitID,
189 int32
const iPrecision,
191 bool const iTransient,
192 int16
const iDeprecatedSince,
197 iConverter ? iConverter->
normalize(iDefaultValue) : 0,
198 iConverter ? iConverter->getStepCount() : 0,
201 std::move(iShortTitle),
238 return fConverter->denormalize(iNormalizedValue);
245 void toString(ParamValue iNormalizedValue, String128 iString)
const override
259 std::string
toUTF8String(ParamValue iNormalizedValue, int32 iPrecision)
const override
274 const std::shared_ptr<IParamConverter<ParamType>>
fConverter;
286 bool const iTransient,
287 int16
const iDeprecatedSince,
289 :
IParamDef(iParamID, std::move(iTitle), iOwner, iTransient, iDeprecatedSince),
301 virtual std::shared_ptr<GUI::Params::IGUIJmbParameter>
newGUIParam() = 0;
325 bool const iTransient,
326 int16
const iDeprecatedSince,
330 IJmbParamDef(iParamID, std::move(iTitle), iOwner, iTransient, iDeprecatedSince, iShared),
368 std::ostringstream s;
371 s.precision(iPrecision);
372 s.setf(std::ios::fixed);
389 return std::dynamic_pointer_cast<IDiscreteConverter<T>>(
fSerializer);
395 return "__param__" + std::to_string(
fParamID);
404 std::shared_ptr<GUI::Params::IGUIJmbParameter>
newGUIParam()
override;
424 return fSerializer->readFromStream(iStreamer, oValue);
450 return fSerializer->writeToStream(iValue, oStreamer);
512template<
typename T,
size_t N>
524template<
typename T,
size_t N>
Base class for a Jamba (Jmb) GUI parameter.
Definition GUIJmbParameter.h:42
virtual void writeDefaultValue(std::ostream &oStreamer) const =0
~IJmbParamDef() override=default
bool const fShared
Definition ParamDef.h:309
virtual bool isSerializable() const =0
IJmbParamDef(const ParamID iParamID, VstString16 iTitle, Owner const iOwner, bool const iTransient, int16 const iDeprecatedSince, bool const iShared)
Definition ParamDef.h:283
virtual std::shared_ptr< GUI::Params::IGUIJmbParameter > newGUIParam()=0
Create a new IGUIJmbParameter of the proper subtype.
A vst parameter is represented by a ParamValue type which is a double in the range [0,...
Definition ParamConverters.h:55
IParamDef(ParamID const iParamID, VstString16 iTitle, Owner const iOwner, bool const iTransient, int16 const iDeprecatedSince)
Definition ParamDef.h:62
bool isDeprecated() const
Returns true if the parameter is deprecated (meaning it can only be used to upgrade to latest version...
Definition ParamDef.h:77
const bool fTransient
Definition ParamDef.h:83
const int16 fDeprecatedSince
Definition ParamDef.h:84
Owner
Who owns the parameter (mostly for state saving purposes).
Definition ParamDef.h:53
@ kRT
Definition ParamDef.h:54
@ kGUI
Definition ParamDef.h:55
static constexpr int16 kVersionNotDeprecated
Special version indicating the parameter is not deprecated.
Definition ParamDef.h:59
const VstString16 fTitle
Definition ParamDef.h:81
const ParamID fParamID
Definition ParamDef.h:80
virtual ~IParamDef()=default
const Owner fOwner
Definition ParamDef.h:82
A vst parameter is represented by a ParamValue type which is a double in the range [0,...
Definition ParamSerializers.h:109
tresult writeToMessage(ParamType const &iValue, Message &oMessage) const
Definition ParamDef.h:497
bool isSerializable() const override
Definition ParamDef.h:409
tresult readFromMessage(Message const &iMessage, ParamType &oValue) const
Definition ParamDef.h:485
std::shared_ptr< IDiscreteConverter< T > > getDiscreteConverter() const
Definition ParamDef.h:385
std::string toUTF8String(ParamType const &iValue, int32 iPrecision) const
Return the value as a utf-8 string.
Definition ParamDef.h:360
std::string computeMessageAttrID() const
Definition ParamDef.h:393
const std::shared_ptr< IParamSerializer< ParamType > > fSerializer
Definition ParamDef.h:413
void writeDefaultValue(std::ostream &oStreamer) const override
Definition ParamDef.h:476
const ParamType fDefaultValue
Definition ParamDef.h:412
T ParamType
Definition ParamDef.h:320
JmbParamDef(ParamID const iParamID, VstString16 iTitle, Owner const iOwner, bool const iTransient, int16 const iDeprecatedSince, bool const iShared, ParamType const &iDefaultValue, std::shared_ptr< IParamSerializer< ParamType > > iSerializer)
Definition ParamDef.h:322
tresult writeToStream(ParamType const &iValue, IBStreamer &oStreamer) const override
This method should write iValue to the stream (aka serialization).
Definition ParamDef.h:447
tresult readFromStream(IBStreamer &iStreamer, ParamType &oValue) const override
This method should read from the stream and populate oValue accordingly (aka deserialization).
Definition ParamDef.h:420
std::shared_ptr< GUI::Params::IGUIJmbParameter > newGUIParam() override
Create a new IGUIJmbParameter of the proper subtype.
Definition GUIState.h:393
Simple wrapper class with better api.
Definition Messaging.h:46
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:152
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:170
Used to communicate the state between the UI and the RT and read/write to stream.
Definition NormalizedState.h:39
tresult getNormalizedValue(ParamID iParamID, ParamValue &oValue) const
Returns the normalized value for the given param id if it exists.
Definition NormalizedState.cpp:132
tresult setNormalizedValue(ParamID iParamID, ParamValue iValue)
Sets the normalized value for the given param id if it exists.
Definition NormalizedState.cpp:147
static void staticToString(ParamValue const &iValue, String128 oString, int32 iPrecision)
Definition ParamConverters.h:95
tresult writeToState(ParamValue iValue, NormalizedState &oState) const
Writes the provided value to the (normalized) state.
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, int16 const iDeprecatedSince)
Definition ParamDef.h:94
virtual void toString(ParamValue iNormalizedValue, String128 iString) const
Definition ParamDef.h:144
const int32 fPrecision
Definition ParamDef.h:170
const int32 fStepCount
Definition ParamDef.h:166
const VstString16 fShortTitle
Definition ParamDef.h:169
const ParamValue fDefaultValue
Definition ParamDef.h:165
const UnitID fUnitID
Definition ParamDef.h:168
ParamValue readFromStream(IBStreamer &iStreamer) const
Definition ParamDef.h:118
virtual std::string toUTF8String(ParamValue iNormalizedValue, int32 iPrecision) const
Return the value as a utf-8 string.
Definition ParamDef.h:155
const int32 fFlags
Definition ParamDef.h:167
ParamValue readFromState(NormalizedState const &iState) const
Read the value from the (normalized) state.
Definition ParamDef.h:130
const VstString16 fUnits
Definition ParamDef.h:164
ParamType denormalize(ParamValue iNormalizedValue) const
Definition ParamDef.h:235
ParamValue normalize(ParamType const &iValue) const
Definition ParamDef.h:227
const std::shared_ptr< IParamConverter< ParamType > > fConverter
Definition ParamDef.h:274
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, int16 const iDeprecatedSince, std::shared_ptr< IParamConverter< ParamType > > iConverter)
Definition ParamDef.h:182
const ParamType fDefaultValue
Definition ParamDef.h:273
std::string toUTF8String(ParamValue iNormalizedValue, int32 iPrecision) const override
Return the value as a utf-8 string.
Definition ParamDef.h:259
ParamType readFromState(NormalizedState const &iState) const
Read the value from the (normalized) state.
Definition ParamDef.h:212
ParamType getDefaultValue() const
Definition ParamDef.h:224
T ParamType
Definition ParamDef.h:180
tresult writeToState(ParamType const &iValue, NormalizedState &oState) const
Writes the provided value to the (normalized) state.
Definition ParamDef.h:218
void toString(ParamValue iNormalizedValue, String128 iString) const override
Using fConverter::toString.
Definition ParamDef.h:245
Definition CircularBuffer.h:26
constexpr auto is_operator_write_to_ostream_defined
Allows to detect whether a type defines ostream << x at compile time.
Definition Metaprogramming.h:115
tresult readDouble(IBStreamer &iStreamer, double &oValue)
Definition ParamSerializers.h:157
std::string toUT8String(VstString16 const &iString)
Converts a VstString16 to a regular std::string that is properly utf-8 encoded.
Definition Utils.h:35
std::array< VstParam< T >, N > VstParams
Definition ParamDef.h:513
std::array< JmbParam< T >, N > JmbParams
Definition ParamDef.h:525
std::array< RawVstParam, N > RawVstParams
Definition ParamDef.h:516
std::shared_ptr< JmbParamDef< T > > JmbParam
Definition ParamDef.h:522
std::shared_ptr< VstParamDef< T > > VstParam
Definition ParamDef.h:509
std::shared_ptr< RawVstParamDef > RawVstParam
Definition ParamDef.h:510
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:44