28 #include <public.sdk/source/vst/vstparameters.h> 32 namespace Debug {
class ParamDisplay; }
60 template<
typename Param>
66 template<
typename TView,
typename Param>
95 int32
fFlags = ParameterInfo::kCanAutomate;
99 IParamDef::Owner
fOwner = IParamDef::Owner::kRT;
129 template<
typename ParamConverter,
typename... Args>
133 VstParam<T>
add()
const;
140 int32
fFlags = ParameterInfo::kCanAutomate;
144 IParamDef::Owner
fOwner = IParamDef::Owner::kRT;
171 template<
typename ParamSerializer,
typename... Args>
175 JmbParam<T>
add()
const;
181 IParamDef::Owner
fOwner = IParamDef::Owner::kGUI;
212 template<
typename ParamConverter,
typename... Args>
218 template<
typename ParamConverter>
221 typename ParamConverter::ConstructorType initValue);
233 template<
typename ParamSerializer,
typename... Args>
239 template<
typename ParamSerializer>
242 typename ParamSerializer::ConstructorType initValue);
258 template<
typename... Args>
279 template<
typename... Args>
311 virtual std::unique_ptr<NormalizedState>
newRTState()
const;
322 std::shared_ptr<IJmbParamDef>
getJmbParamDef(ParamID iParamID)
const;
346 tresult
addVstParamDef(std::shared_ptr<RawVstParamDef> iParamDef);
353 std::map<ParamID, std::shared_ptr<RawVstParamDef>>
fVstParams{};
356 std::map<ParamID, std::shared_ptr<IJmbParamDef>>
fJmbParams{};
370 tresult
buildParamIDs(std::vector<ParamID> &iParamIDs) {
return kResultOk; }
373 template<
typename... Args>
374 tresult
buildParamIDs(std::vector<ParamID> &iParamIDs, ParamID
id, Args&& ...args);
377 template<
typename... Args>
378 tresult
buildParamIDs(std::vector<ParamID> &iParamIDs, std::shared_ptr<IJmbParamDef> &iParamDef, Args&& ...args)
380 return buildParamIDs(iParamIDs, iParamDef->fParamID, std::forward<Args>(args)...);
384 template<
typename T,
typename... Args>
385 tresult
buildParamIDs(std::vector<ParamID> &iParamIDs, std::shared_ptr<JmbParamDef<T>> &iParamDef, Args&& ...args)
387 return buildParamIDs(iParamIDs, iParamDef->fParamID, std::forward<Args>(args)...);
391 template<
typename ParamConverver,
typename... Args>
392 tresult
buildParamIDs(std::vector<ParamID> &iParamIDs, std::shared_ptr<VstParamDef<ParamConverver>> &iParamDef, Args&& ...args)
394 return buildParamIDs(iParamIDs, iParamDef->fParamID, std::forward<Args>(args)...);
398 template<
typename... Args>
399 tresult
buildParamIDs(std::vector<ParamID> &iParamIDs, std::shared_ptr<RawVstParamDef> &iParamDef, Args&& ...args)
401 return buildParamIDs(iParamIDs, iParamDef->fParamID, std::forward<Args>(args)...);
412 return fParameters->add(*
this);
421 return fParameters->add(*
this);
430 auto param = std::make_shared<VstParamDef<T>>(iBuilder.
fParamID,
444 DLOG_F(WARNING,
"No converter defined for non transient parameter [%d]", iBuilder.
fParamID);
459 auto param = std::make_shared<JmbParamDef<T>>(iBuilder.
fParamID,
469 DLOG_F(WARNING,
"No serializer defined for parameter [%d] (won't be able to be saved)", iBuilder.
fParamID);
474 DLOG_F(WARNING,
"No serializer defined for parameter [%d] (won't be able to be shared with peer)", iBuilder.
fParamID);
496 template<
typename ParamConverter,
typename... Args>
499 Args&& ...iConverterArgs)
501 auto builder = vstFromType<typename ParamConverter::ParamType>(iParamID, std::move(iTitle));
502 builder.template converter<ParamConverter>(std::forward<Args>(iConverterArgs)...);
509 template<
typename ParamConverter>
512 typename ParamConverter::ConstructorType initValue) {
513 auto builder = vstFromType<typename ParamConverter::ParamType>(iParamID, std::move(iTitle));
514 builder.template converter<ParamConverter>(initValue);
530 template<
typename ParamSerializer,
typename... Args>
533 Args&& ...iSerializerArgs)
535 auto builder = jmbFromType<typename ParamSerializer::ParamType>(iParamID, std::move(iTitle));
536 builder.template serializer<ParamSerializer>(std::forward<Args>(iSerializerArgs)...);
543 template<
typename ParamSerializer>
546 typename ParamSerializer::ConstructorType initValue) {
547 auto builder = jmbFromType<typename ParamSerializer::ParamType>(iParamID, std::move(iTitle));
548 builder.template serializer<ParamSerializer>(initValue);
555 template<
typename... Args>
558 tresult res = kResultOk;
563 iParamIDs.emplace_back(iParamID);
567 DLOG_F(ERROR,
"No such parameter [%d]", iParamID);
570 res |=
buildParamIDs(iParamIDs, std::forward<Args>(args)...);
577 template<
typename... Args>
580 std::vector<ParamID> ids{};
588 template<
typename... Args>
591 std::vector<ParamID> ids{};
VstParamDefBuilder & converter(std::shared_ptr< IParamConverter< T >> iConverter)
Definition: Parameters.h:128
std::shared_ptr< IParamConverter< T > > fConverter
Definition: Parameters.h:146
std::vector< ParamID > const & getAllRegistrationOrder() const
Definition: Parameters.h:328
std::shared_ptr< IParamSerializer< T > > fSerializer
Definition: Parameters.h:184
VstString16 fShortTitle
Definition: Parameters.h:142
VstString16 fShortTitle
Definition: Parameters.h:97
This is the class which maintains all the registered parameters.
Definition: Parameters.h:37
virtual ~Parameters()=default
VstString16 fUnits
Definition: Parameters.h:138
VstString16 fTitle
Definition: Parameters.h:137
int32 fFlags
Definition: Parameters.h:140
VstString16 fTitle
Definition: Parameters.h:91
NormalizedState::SaveOrder const & getRTSaveStateOrder() const
Definition: Parameters.h:292
std::function< void(TView *, Param &)> ChangeCallback2
A callback which will be invoked for changes with the view and param as arguments.
Definition: Parameters.h:67
tresult setGUISaveStateOrder(int16 iVersion, Args &&...args)
Used to change the default order (registration order) used when saving the GUI state (getState/setSta...
Definition: Parameters.h:589
Implements the builder pattern for ease of build.
Definition: Parameters.h:72
This helper class is used to display the parameters (vst/jmb) WARNING: this class is allocating memor...
Definition: ParamDisplay.h:33
std::shared_ptr< IJmbParamDef > getJmbParamDef(ParamID iParamID) const
Definition: Parameters.cpp:142
Implements the builder pattern for ease of build.
Definition: Parameters.h:162
std::function< void()> ChangeCallback
A callback that will be invoked for changes.
Definition: Parameters.h:55
RawVstParamDefBuilder & unitID(int32 iUnitID)
Definition: Parameters.h:79
tresult setRTSaveStateOrder(int16 iVersion, Args &&...args)
Used to change the default order (registration order) used when saving the RT state (getState/setStat...
Definition: Parameters.h:578
Maintains the order used to save/restore the RT and GUI state.
Definition: NormalizedState.h:44
std::shared_ptr< RawVstParamDef > RawVstParam
Definition: ParamDef.h:444
ParamID fParamID
Definition: Parameters.h:178
virtual ParamValue readNormalizedValue(ParamID iParamID, IBStreamer &iStreamer) const
Definition: Parameters.cpp:115
VstParamDefBuilder & converter(Args &&...iArgs)
Definition: Parameters.h:130
RawVstParamDefBuilder & shortTitle(VstString16 iShortTitle)
Definition: Parameters.h:80
bool fTransient
Definition: Parameters.h:145
VstParamDefBuilder & precision(int32 iPrecision)
Definition: Parameters.h:124
int32 fPrecision
Definition: Parameters.h:98
virtual tresult readRTState(IBStreamer &iStreamer, NormalizedState *oNormalizedState) const
This method is called to read the RTState from the stream.
Definition: Parameters.cpp:86
ParamValue fDefaultValue
Definition: Parameters.h:93
int32 fFlags
Definition: Parameters.h:95
VstParamDefBuilder & unitID(int32 iUnitID)
Definition: Parameters.h:122
std::vector< ParamID > fVstRegistrationOrder
Definition: Parameters.h:359
void registerVstParameters(Vst::ParameterContainer &iParameterContainer) const
This method is called from the GUI controller to register all the parameters to the ParameterContaine...
Definition: Parameters.cpp:55
NormalizedState::SaveOrder fRTSaveStateOrder
Definition: Parameters.h:365
RawVstParam add(RawVstParamDefBuilder const &iBuilder)
Definition: Parameters.cpp:376
Used to communicate the state between the UI and the RT and read/write to stream.
Definition: NormalizedState.h:38
NormalizedState::SaveOrder fGUISaveStateOrder
Definition: Parameters.h:366
Parameters * fParameters
Definition: Parameters.h:155
std::shared_ptr< RawVstParamDef > getRawVstParamDef(ParamID iParamID) const
Definition: Parameters.cpp:130
std::vector< ParamID > fAllRegistrationOrder
Definition: Parameters.h:362
UnitID fUnitID
Definition: Parameters.h:96
VstParamDefBuilder & flags(int32 iFlags)
Definition: Parameters.h:121
int32 fPrecision
Definition: Parameters.h:143
tresult buildParamIDs(std::vector< ParamID > &iParamIDs)
Definition: Parameters.h:370
Parameters * fParameters
Definition: Parameters.h:193
virtual std::unique_ptr< NormalizedState > newRTState() const
Definition: Parameters.cpp:67
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
JmbParamDefBuilder & serializer(Args &&...iArgs)
Definition: Parameters.h:172
VstString16 fUnits
Definition: Parameters.h:92
tresult buildParamIDs(std::vector< ParamID > &iParamIDs, std::shared_ptr< RawVstParamDef > &iParamDef, Args &&...args)
Definition: Parameters.h:399
std::vector< ParamID > const & getVstRegistrationOrder() const
Definition: Parameters.h:325
JmbParamDefBuilder< typename ParamSerializer::ParamType > jmb(ParamID iParamID, VstString16 iTitle, Args &&...iSerializerArgs)
Used from derived classes to build a non vst parameter (not convertible to a ParamValue)
Definition: Parameters.h:531
RawVstParamDefBuilder & units(VstString16 iUnits)
Definition: Parameters.h:75
RawVstParamDefBuilder & rtOwned()
Definition: Parameters.h:82
int32 fStepCount
Definition: Parameters.h:94
RawVstParamDefBuilder(Parameters *iParameters, ParamID iParamID, VstString16 iTitle)
Definition: Parameters.h:105
Parameters * fParameters
Definition: Parameters.h:109
UnitID fUnitID
Definition: Parameters.h:141
RawVstParamDefBuilder & precision(int32 iPrecision)
Definition: Parameters.h:81
RawVstParamDefBuilder & flags(int32 iFlags)
Definition: Parameters.h:78
tresult buildParamIDs(std::vector< ParamID > &iParamIDs, std::shared_ptr< JmbParamDef< T >> &iParamDef, Args &&...args)
Definition: Parameters.h:385
JmbParamDefBuilder & defaultValue(T const &iDefaultValue)
Definition: Parameters.h:165
A vst parameter is represented by a ParamValue type which is a double in the range [0,...
Definition: ParamSerializers.h:105
JmbParamDefBuilder< T > jmbFromType(ParamID iParamID, VstString16 iTitle)
Used from derived classes to build a non vst parameter (not convertible to a ParamValue).
Definition: Parameters.h:522
std::function< void(Param &)> ChangeCallback1
A callback which will be invoked for changes with the param as an argument.
Definition: Parameters.h:61
VstParamDefBuilder & rtOwned()
Definition: Parameters.h:125
VstString16 fTitle
Definition: Parameters.h:179
virtual void onParameterChange(ParamID iParamID)=0
NormalizedState::SaveOrder const & getGUISaveStateOrder() const
Definition: Parameters.h:270
bool fTransient
Definition: Parameters.h:100
JmbParamDefBuilder & rtOwned()
Definition: Parameters.h:167
RawVstParam add() const
Definition: Parameters.cpp:368
VstParamDefBuilder< typename ParamConverter::ParamType > vst(ParamID iParamID, VstString16 iTitle, Args &&...iConverterArgs)
Used from derived classes to build a parameter backed by a VST parameter.
Definition: Parameters.h:497
RawVstParamDefBuilder & defaultValue(ParamValue iDefaultValue)
Definition: Parameters.h:76
VstParamDefBuilder< T > vstFromType(ParamID iParamID, VstString16 iTitle)
Used from derived classes to build a parameter backed by a VST parameter.
Definition: Parameters.h:488
VstParam< T > add() const
Definition: Parameters.h:419
tresult addVstParamDef(std::shared_ptr< RawVstParamDef > iParamDef)
Definition: Parameters.cpp:155
JmbParamDefBuilder & serializer(std::shared_ptr< IParamSerializer< T >> iSerializer)
Definition: Parameters.h:170
RawVstParamDefBuilder & stepCount(int32 iStepCount)
Definition: Parameters.h:77
JmbParamDefBuilder & shared(bool iShared=true)
Definition: Parameters.h:169
tresult buildParamIDs(std::vector< ParamID > &iParamIDs, std::shared_ptr< IJmbParamDef > &iParamDef, Args &&...args)
Definition: Parameters.h:378
VstParamDefBuilder & defaultValue(T const &iDefaultValue)
Definition: Parameters.h:120
T fDefaultValue
Definition: Parameters.h:180
ParamID fParamID
Definition: Parameters.h:90
RawVstParamDefBuilder raw(ParamID iParamID, VstString16 iTitle)
Used from derived classes to build a parameter backed by a raw VST parameter.
Definition: Parameters.cpp:399
JmbParamDefBuilder & guiOwned()
Definition: Parameters.h:168
virtual tresult writeRTState(NormalizedState const *iNormalizedState, IBStreamer &oStreamer) const
This method is called to write the NormalizedState to the stream.
Definition: Parameters.cpp:106
IParamDef::Owner fOwner
Definition: Parameters.h:181
JmbParam< T > add() const
Definition: Parameters.h:410
ParamID fParamID
Definition: Parameters.h:136
tresult buildParamIDs(std::vector< ParamID > &iParamIDs, std::shared_ptr< VstParamDef< ParamConverver >> &iParamDef, Args &&...args)
Definition: Parameters.h:392
RawVstParamDefBuilder & guiOwned()
Definition: Parameters.h:83
VstParamDefBuilder & units(VstString16 iUnits)
Definition: Parameters.h:119
IParamDef::Owner fOwner
Definition: Parameters.h:99
bool fTransient
Definition: Parameters.h:182
tresult addJmbParamDef(std::shared_ptr< IJmbParamDef > iParamDef)
Definition: Parameters.cpp:190
JmbParamDefBuilder(Parameters *iParameters, ParamID iParamID, VstString16 iTitle)
Definition: Parameters.h:189
VstParamDefBuilder(Parameters *iParameters, ParamID iParamID, VstString16 iTitle)
Definition: Parameters.h:151
VstParamDefBuilder & shortTitle(VstString16 iShortTitle)
Definition: Parameters.h:123
T fDefaultValue
Definition: Parameters.h:139
IParamDef::Owner fOwner
Definition: Parameters.h:144
Implements the builder pattern for ease of build.
Definition: Parameters.h:116
std::map< ParamID, std::shared_ptr< IJmbParamDef > > fJmbParams
Definition: Parameters.h:356
Interface to implement to receive parameter changes.
Definition: Parameters.h:43
bool fShared
Definition: Parameters.h:183
A vst parameter is represented by a ParamValue type which is a double in the range [0,...
Definition: ParamConverters.h:53
std::map< ParamID, std::shared_ptr< RawVstParamDef > > fVstParams
Definition: Parameters.h:353
VstParamDefBuilder & guiOwned()
Definition: Parameters.h:126