Jamba C++ API  5.0.0
Parameters.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018-2020 pongasoft
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5  * use this file except in compliance with the License. You may obtain a copy of
6  * the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13  * License for the specific language governing permissions and limitations under
14  * the License.
15  *
16  * @author Yan Pujante
17  */
18 #pragma once
19 
20 #include "ParamDef.h"
21 #include "NormalizedState.h"
22 
23 #include <map>
24 #include <vector>
25 #include <set>
26 #include <functional>
27 
28 #include <public.sdk/source/vst/vstparameters.h>
29 
30 namespace pongasoft::VST {
31 
32 namespace Debug { class ParamDisplay; }
33 
38 {
39 public:
44  {
45  public:
46  virtual void onParameterChange(ParamID iParamID) = 0;
47  };
48 
55  using ChangeCallback = std::function<void()>;
56 
60  template<typename Param>
61  using ChangeCallback1 = std::function<void(Param &)>;
62 
66  template<typename TView, typename Param>
67  using ChangeCallback2 = std::function<void(TView *, Param &)>;
68 
69 public:
73  {
74  // builder methods
75  RawVstParamDefBuilder &units(VstString16 iUnits) { fUnits = std::move(iUnits); return *this; }
76  RawVstParamDefBuilder &defaultValue(ParamValue iDefaultValue) { fDefaultValue = iDefaultValue; return *this;}
77  RawVstParamDefBuilder &stepCount(int32 iStepCount) { fStepCount = iStepCount; return *this;}
78  RawVstParamDefBuilder &flags(int32 iFlags) { fFlags = iFlags; return *this; }
79  RawVstParamDefBuilder &unitID(int32 iUnitID) { fUnitID = iUnitID; return *this; }
80  RawVstParamDefBuilder &shortTitle(VstString16 iShortTitle) { fShortTitle = std::move(iShortTitle); return *this; }
81  RawVstParamDefBuilder &precision(int32 iPrecision) { fPrecision = iPrecision; return *this; }
82  RawVstParamDefBuilder &rtOwned() { fOwner = IParamDef::Owner::kRT; return *this; }
83  RawVstParamDefBuilder &guiOwned() { fOwner = IParamDef::Owner::kGUI; return *this; }
84  RawVstParamDefBuilder &transient(bool iTransient = true) { fTransient = iTransient; return *this; }
85  RawVstParamDefBuilder &deprecatedSince(int16 iVersion) { fDeprecatedSince = iVersion; return *this; }
86 
87  // parameter factory method
88  RawVstParam add() const;
89 
90  // fields
91  ParamID fParamID;
94  ParamValue fDefaultValue{};
95  int32 fStepCount{0};
96  int32 fFlags{ParameterInfo::kCanAutomate};
97  UnitID fUnitID{kRootUnitId};
99  int32 fPrecision{4};
100  IParamDef::Owner fOwner{IParamDef::Owner::kRT};
101  bool fTransient{false};
102  int16 fDeprecatedSince{IParamDef::kVersionNotDeprecated};
103 
104  friend class Parameters;
105 
106  protected:
107  RawVstParamDefBuilder(Parameters *iParameters, ParamID iParamID, VstString16 iTitle) :
108  fParamID{iParamID}, fTitle{std::move(iTitle)}, fParameters{iParameters} {}
109 
110  private:
112  };
113 
117  template<typename T>
119  {
120  // builder methods
121  VstParamDefBuilder &units(VstString16 iUnits) { fUnits = std::move(iUnits); return *this; }
122  VstParamDefBuilder &defaultValue(T const &iDefaultValue) { fDefaultValue = iDefaultValue; return *this;}
123  VstParamDefBuilder &flags(int32 iFlags) { fFlags = iFlags; return *this; }
124  VstParamDefBuilder &unitID(int32 iUnitID) { fUnitID = iUnitID; return *this; }
125  VstParamDefBuilder &shortTitle(VstString16 iShortTitle) { fShortTitle = std::move(iShortTitle); return *this; }
126  VstParamDefBuilder &precision(int32 iPrecision) { fPrecision = iPrecision; return *this; }
127  VstParamDefBuilder &rtOwned() { fOwner = IParamDef::Owner::kRT; return *this; }
128  VstParamDefBuilder &guiOwned() { fOwner = IParamDef::Owner::kGUI; return *this; }
129  VstParamDefBuilder &transient(bool iTransient = true) { fTransient = iTransient; return *this; }
130  VstParamDefBuilder &deprecatedSince(int16 iVersion) { fDeprecatedSince = iVersion; return *this; }
131  VstParamDefBuilder &converter(std::shared_ptr<IParamConverter<T>> iConverter) { fConverter = std::move(iConverter); return *this; }
132  template<typename ParamConverter, typename... Args>
133  VstParamDefBuilder &converter(Args&& ...iArgs) { fConverter = std::make_shared<ParamConverter>(std::forward<Args>(iArgs)...); return *this; }
134 
135  // parameter factory method
136  VstParam<T> add() const;
137 
138  // fields
139  ParamID fParamID;
143  int32 fFlags{ParameterInfo::kCanAutomate};
144  UnitID fUnitID{kRootUnitId};
146  int32 fPrecision{4};
147  IParamDef::Owner fOwner{IParamDef::Owner::kRT};
148  bool fTransient{false};
149  int16 fDeprecatedSince{IParamDef::kVersionNotDeprecated};
150  std::shared_ptr<IParamConverter<T>> fConverter{};
151 
152  friend class Parameters;
153 
154  protected:
155  VstParamDefBuilder(Parameters *iParameters, ParamID iParamID, VstString16 iTitle) :
156  fParamID{iParamID}, fTitle{std::move(iTitle)}, fParameters{iParameters} {}
157 
158  private:
160  };
161 
165  template<typename T>
167  {
168  // builder methods
169  JmbParamDefBuilder &defaultValue(T const &iDefaultValue) { fDefaultValue = iDefaultValue; return *this;}
170  JmbParamDefBuilder &transient(bool iTransient = true) { fTransient = iTransient; return *this; }
171  JmbParamDefBuilder &deprecatedSince(int16 iVersion) { fDeprecatedSince = iVersion; return *this; }
172  JmbParamDefBuilder &rtOwned() { fOwner = IParamDef::Owner::kRT; return *this; }
173  JmbParamDefBuilder &guiOwned() { fOwner = IParamDef::Owner::kGUI; return *this; }
174  JmbParamDefBuilder &shared(bool iShared = true) { fShared = iShared; return *this; }
175  JmbParamDefBuilder &serializer(std::shared_ptr<IParamSerializer<T>> iSerializer) { fSerializer = std::move(iSerializer); return *this; }
176  template<typename ParamSerializer, typename... Args>
177  JmbParamDefBuilder &serializer(Args&& ...iArgs) { fSerializer = std::make_shared<ParamSerializer>(std::forward<Args>(iArgs)...); return *this; }
178 
179  // parameter factory method
180  JmbParam<T> add() const;
181 
182  // fields
183  ParamID fParamID;
186  IParamDef::Owner fOwner{IParamDef::Owner::kGUI};
187  bool fTransient{false};
188  int16 fDeprecatedSince{IParamDef::kVersionNotDeprecated};
189  bool fShared{false};
190  std::shared_ptr<IParamSerializer<T>> fSerializer{};
191 
192  friend class Parameters;
193 
194  protected:
195  JmbParamDefBuilder(Parameters *iParameters, ParamID iParamID, VstString16 iTitle) :
196  fParamID{iParamID}, fTitle{std::move(iTitle)}, fParameters{iParameters} {}
197 
198  private:
200  };
201 
202 public:
203  // Constructor
204  explicit Parameters() = default;
205 
206  // Ensure the class is polymorphinc
207  virtual ~Parameters() = default;
208 
209 
213  RawVstParamDefBuilder raw(ParamID iParamID, VstString16 iTitle);
214 
218  template<typename ParamConverter, typename... Args>
219  VstParamDefBuilder<typename ParamConverter::ParamType> vst(ParamID iParamID, VstString16 iTitle, Args&& ...iConverterArgs);
220 
224  template<typename ParamConverter>
226  VstString16 iTitle,
227  typename ParamConverter::ConstructorType initValue);
228 
233  template<typename T>
234  VstParamDefBuilder<T> vstFromType(ParamID iParamID, VstString16 iTitle);
235 
239  template<typename ParamSerializer, typename... Args>
240  JmbParamDefBuilder<typename ParamSerializer::ParamType> jmb(ParamID iParamID, VstString16 iTitle, Args&& ...iSerializerArgs);
241 
245  template<typename ParamSerializer>
247  VstString16 iTitle,
248  typename ParamSerializer::ConstructorType initValue);
249 
254  template<typename T>
255  JmbParamDefBuilder<T> jmbFromType(ParamID iParamID, VstString16 iTitle);
256 
264  template<typename... Args>
265  tresult setRTSaveStateOrder(int16 iVersion, Args&& ...args);
266 
271  tresult setRTSaveStateOrder(NormalizedState::SaveOrder const &iSaveOrder);
272 
286  template<typename... Args>
287  tresult setRTDeprecatedSaveStateOrder(int16 iVersion, Args&& ...args);
288 
293 
301  template<typename... Args>
302  tresult setGUISaveStateOrder(int16 iVersion, Args&& ...args);
303 
308  NormalizedState::SaveOrder const *getGUIDeprecatedSaveStateOrder(int16 iVersion) const;
309 
323  template<typename... Args>
324  tresult setGUIDeprecatedSaveStateOrder(int16 iVersion, Args&& ...args);
325 
330  tresult setGUISaveStateOrder(NormalizedState::SaveOrder const &iSaveOrder);
331 
337 
342  void registerVstParameters(Vst::ParameterContainer &iParameterContainer) const;
343 
346  virtual tresult readRTState(IBStreamer &iStreamer, NormalizedState *oNormalizedState) const;
347 
350  virtual tresult writeRTState(NormalizedState const *iNormalizedState, IBStreamer &oStreamer) const;
351 
355  virtual std::unique_ptr<NormalizedState> newRTState() const;
356 
360  virtual std::unique_ptr<NormalizedState> newRTState(NormalizedState::SaveOrder const *iSaveOrder) const;
361 
365  virtual ParamValue readNormalizedValue(ParamID iParamID, IBStreamer &iStreamer) const;
366 
367  // getParamDef - nullptr when not found
368  std::shared_ptr<RawVstParamDef> getRawVstParamDef(ParamID iParamID) const;
369 
370  // getJmbParamDef - nullptr when not found
371  std::shared_ptr<IJmbParamDef> getJmbParamDef(ParamID iParamID) const;
372 
373  // getVstRegistrationOrder
374  std::vector<ParamID> const &getVstRegistrationOrder() const { return fVstRegistrationOrder; }
375 
376  // getAllRegistrationOrder
377  std::vector<ParamID> const &getAllRegistrationOrder() const { return fAllRegistrationOrder; }
378 
416  virtual tresult handleRTStateUpgrade(NormalizedState const &iDeprecatedState, NormalizedState &oNewState) const
417  {
418  return kResultTrue;
419  }
420 
421  // gives access for debug
422  friend class Debug::ParamDisplay;
423 
424 protected:
425  // internally called by the builder
426  RawVstParam add(RawVstParamDefBuilder const &iBuilder);
427 
428  // internally called by the builder
429  template<typename T>
430  VstParam<T> add(VstParamDefBuilder<T> const &iBuilder);
431 
432  // internally called by the builder
433  template<typename T>
434  JmbParam<T> add(JmbParamDefBuilder<T> const &iBuilder);
435 
436  // addVstParamDef
437  tresult addVstParamDef(std::shared_ptr<RawVstParamDef> iParamDef);
438 
439  // addJmbParamDef
440  tresult addJmbParamDef(std::shared_ptr<IJmbParamDef> iParamDef);
441 
444  virtual tresult readDeprecatedRTState(uint16 iVersion, IBStreamer &iStreamer, NormalizedState *oNormalizedState) const;
445 
446 private:
447  // contains all the registered (raw type) parameters (unique ID, will be checked on add)
448  std::map<ParamID, std::shared_ptr<RawVstParamDef>> fVstParams{};
449 
450  // contains all the registered (serializable type) parameters (unique ID, will be checked on add)
451  std::map<ParamID, std::shared_ptr<IJmbParamDef>> fJmbParams{};
452 
453  // order in which the parameters will be registered in the vst world
454  std::vector<ParamID> fVstRegistrationOrder{};
455 
456  // order in which the parameters were registered
457  std::vector<ParamID> fAllRegistrationOrder{};
458 
459  // The "latest" order for both RT and GUI
462 
463  // Keep track of deprecated state orders used for upgrade
464  std::map<int16, NormalizedState::SaveOrder> fRTDeprecatedSaveStateOrders{};
465  std::map<int16, NormalizedState::SaveOrder> fGUIDeprecatedSaveStateOrders{};
466 
467 private:
468  // leaf of templated calls to build a list of ParamIDs from ParamID or ParamDefs
469  tresult buildParamIDs(std::vector<ParamID> &iParamIDs) { return kResultOk; }
470 
471  // case when ParamID
472  template<typename... Args>
473  tresult buildParamIDs(std::vector<ParamID> &iParamIDs, ParamID id, Args&& ...args);
474 
475  // case when IJmbParamDef
476  template<typename... Args>
477  tresult buildParamIDs(std::vector<ParamID> &iParamIDs, std::shared_ptr<IJmbParamDef> &iParamDef, Args&& ...args)
478  {
479  return buildParamIDs(iParamIDs, iParamDef->fParamID, std::forward<Args>(args)...);
480  }
481 
482  // case when IJmbParamDef
483  template<typename T, typename... Args>
484  tresult buildParamIDs(std::vector<ParamID> &iParamIDs, std::shared_ptr<JmbParamDef<T>> &iParamDef, Args&& ...args)
485  {
486  return buildParamIDs(iParamIDs, iParamDef->fParamID, std::forward<Args>(args)...);
487  }
488 
489  // case when VstParamDef
490  template<typename ParamConverver, typename... Args>
491  tresult buildParamIDs(std::vector<ParamID> &iParamIDs, std::shared_ptr<VstParamDef<ParamConverver>> &iParamDef, Args&& ...args)
492  {
493  return buildParamIDs(iParamIDs, iParamDef->fParamID, std::forward<Args>(args)...);
494  }
495 
496  // case when RawVstParamDef
497  template<typename... Args>
498  tresult buildParamIDs(std::vector<ParamID> &iParamIDs, std::shared_ptr<RawVstParamDef> &iParamDef, Args&& ...args)
499  {
500  return buildParamIDs(iParamIDs, iParamDef->fParamID, std::forward<Args>(args)...);
501  }
502 
506 
510 };
511 
512 //------------------------------------------------------------------------
513 // Parameters::JmbParamDefBuilder::add
514 //------------------------------------------------------------------------
515 template<typename T>
517 {
518  return fParameters->add(*this);
519 }
520 
521 //------------------------------------------------------------------------
522 // Parameters::VstParamDefBuilder::add
523 //------------------------------------------------------------------------
524 template<typename T>
526 {
527  return fParameters->add(*this);
528 }
529 
530 //------------------------------------------------------------------------
531 // Parameters::add (called by the builder)
532 //------------------------------------------------------------------------
533 template<typename T>
534 VstParam<T> Parameters::add(VstParamDefBuilder<T> const &iBuilder)
535 {
536  auto param = std::make_shared<VstParamDef<T>>(iBuilder.fParamID,
537  iBuilder.fTitle,
538  iBuilder.fUnits,
539  iBuilder.fDefaultValue,
540  iBuilder.fFlags,
541  iBuilder.fUnitID,
542  iBuilder.fShortTitle,
543  iBuilder.fPrecision,
544  iBuilder.fOwner,
545  iBuilder.fTransient,
546  iBuilder.fDeprecatedSince,
547  iBuilder.fConverter);
548 
549  if(!iBuilder.fTransient && !iBuilder.fConverter)
550  {
551  DLOG_F(WARNING, "No converter defined for non transient parameter [%d]", iBuilder.fParamID);
552  }
553 
554  if(addVstParamDef(param) == kResultOk)
555  return param;
556  else
557  return nullptr;
558 }
559 
560 //------------------------------------------------------------------------
561 // Parameters::add (called by the builder)
562 //------------------------------------------------------------------------
563 template<typename T>
565 {
566  auto param = std::make_shared<JmbParamDef<T>>(iBuilder.fParamID,
567  iBuilder.fTitle,
568  iBuilder.fOwner,
569  iBuilder.fTransient,
570  iBuilder.fDeprecatedSince,
571  iBuilder.fShared,
572  iBuilder.fDefaultValue,
573  iBuilder.fSerializer);
574 
575  if(!iBuilder.fTransient && !iBuilder.fSerializer)
576  {
577  DLOG_F(WARNING, "No serializer defined for parameter [%d] (won't be able to be saved)", iBuilder.fParamID);
578  }
579 
580  if(iBuilder.fShared && !iBuilder.fSerializer)
581  {
582  DLOG_F(WARNING, "No serializer defined for parameter [%d] (won't be able to be shared with peer)", iBuilder.fParamID);
583  }
584 
585  if(addJmbParamDef(param) == kResultOk)
586  return param;
587  else
588  return nullptr;
589 }
590 
591 
592 //------------------------------------------------------------------------
593 // Parameters::vstFromType
594 //------------------------------------------------------------------------
595 template<typename T>
597 {
598  return Parameters::VstParamDefBuilder<T>(this, iParamID, std::move(iTitle));
599 }
600 
601 //------------------------------------------------------------------------
602 // Parameters::vst
603 //------------------------------------------------------------------------
604 template<typename ParamConverter, typename... Args>
606  VstString16 iTitle,
607  Args&& ...iConverterArgs)
608 {
609  auto builder = vstFromType<typename ParamConverter::ParamType>(iParamID, std::move(iTitle));
610  builder.template converter<ParamConverter>(std::forward<Args>(iConverterArgs)...);
611  return builder;
612 }
613 
614 //------------------------------------------------------------------------
615 // Parameters::vst
616 //------------------------------------------------------------------------
617 template<typename ParamConverter>
619  VstString16 iTitle,
620  typename ParamConverter::ConstructorType initValue) {
621  auto builder = vstFromType<typename ParamConverter::ParamType>(iParamID, std::move(iTitle));
622  builder.template converter<ParamConverter>(initValue);
623  return builder;
624 }
625 
626 //------------------------------------------------------------------------
627 // Parameters::jmbFromType
628 //------------------------------------------------------------------------
629 template<typename T>
631 {
632  return Parameters::JmbParamDefBuilder<T>(this, iParamID, std::move(iTitle));
633 }
634 
635 //------------------------------------------------------------------------
636 // Parameters::jmb
637 //------------------------------------------------------------------------
638 template<typename ParamSerializer, typename... Args>
640  VstString16 iTitle,
641  Args&& ...iSerializerArgs)
642 {
643  auto builder = jmbFromType<typename ParamSerializer::ParamType>(iParamID, std::move(iTitle));
644  builder.template serializer<ParamSerializer>(std::forward<Args>(iSerializerArgs)...);
645  return builder;
646 }
647 
648 //------------------------------------------------------------------------
649 // Parameters::jmb
650 //------------------------------------------------------------------------
651 template<typename ParamSerializer>
653  VstString16 iTitle,
654  typename ParamSerializer::ConstructorType initValue) {
655  auto builder = jmbFromType<typename ParamSerializer::ParamType>(iParamID, std::move(iTitle));
656  builder.template serializer<ParamSerializer>(initValue);
657  return builder;
658 }
659 
660 //------------------------------------------------------------------------
661 // Parameters::buildParamIDs
662 //------------------------------------------------------------------------
663 template<typename... Args>
664 tresult Parameters::buildParamIDs(std::vector<ParamID> &iParamIDs, ParamID iParamID, Args&& ...args)
665 {
666  tresult res = kResultOk;
667 
668  if(fVstParams.find(iParamID) != fVstParams.cend() ||
669  fJmbParams.find(iParamID) != fJmbParams.cend())
670  {
671  iParamIDs.emplace_back(iParamID);
672  }
673  else
674  {
675  DLOG_F(ERROR, "No such parameter [%d]", iParamID);
676  res = kResultFalse;
677  }
678  res |= buildParamIDs(iParamIDs, std::forward<Args>(args)...);
679  return res;
680 }
681 
682 //------------------------------------------------------------------------
683 // Parameters::setRTSaveStateOrder
684 //------------------------------------------------------------------------
685 template<typename... Args>
686 tresult Parameters::setRTSaveStateOrder(int16 iVersion, Args&& ...args)
687 {
688  std::vector<ParamID> ids{};
689  buildParamIDs(ids, std::forward<Args>(args)...);
690  return setRTSaveStateOrder({iVersion, ids});
691 }
692 
693 //------------------------------------------------------------------------
694 // Parameters::setRTDeprecatedSaveStateOrder
695 //------------------------------------------------------------------------
696 template<typename... Args>
697 tresult Parameters::setRTDeprecatedSaveStateOrder(int16 iVersion, Args&& ...args)
698 {
699  std::vector<ParamID> ids{};
700  buildParamIDs(ids, std::forward<Args>(args)...);
701  return setRTDeprecatedSaveStateOrder({iVersion, ids});
702 }
703 
704 //------------------------------------------------------------------------
705 // Parameters::setRTSaveStateOrder
706 //------------------------------------------------------------------------
707 template<typename... Args>
708 tresult Parameters::setGUISaveStateOrder(int16 iVersion, Args&& ...args)
709 {
710  std::vector<ParamID> ids{};
711  buildParamIDs(ids, std::forward<Args>(args)...);
712  return setGUISaveStateOrder({iVersion, ids});
713 }
714 
715 //------------------------------------------------------------------------
716 // Parameters::setGUIDeprecatedSaveStateOrder
717 //------------------------------------------------------------------------
718 template<typename... Args>
719 tresult Parameters::setGUIDeprecatedSaveStateOrder(int16 iVersion, Args&& ...args)
720 {
721  std::vector<ParamID> ids{};
722  buildParamIDs(ids, std::forward<Args>(args)...);
723  return setGUIDeprecatedSaveStateOrder({iVersion, ids});
724 }
725 
726 }
VstParamDefBuilder & converter(std::shared_ptr< IParamConverter< T >> iConverter)
Definition: Parameters.h:131
std::shared_ptr< IParamConverter< T > > fConverter
Definition: Parameters.h:150
std::vector< ParamID > const & getAllRegistrationOrder() const
Definition: Parameters.h:377
std::shared_ptr< IParamSerializer< T > > fSerializer
Definition: Parameters.h:190
VstString16 fShortTitle
Definition: Parameters.h:145
VstString16 fShortTitle
Definition: Parameters.h:98
This is the class which maintains all the registered parameters.
Definition: Parameters.h:37
virtual ~Parameters()=default
VstString16 fUnits
Definition: Parameters.h:141
VstString16 fTitle
Definition: Parameters.h:140
int32 fFlags
Definition: Parameters.h:143
VstString16 fTitle
Definition: Parameters.h:92
NormalizedState::SaveOrder const & getRTSaveStateOrder() const
Definition: Parameters.h:336
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:708
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:185
Implements the builder pattern for ease of build.
Definition: Parameters.h:166
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:686
virtual tresult readDeprecatedRTState(uint16 iVersion, IBStreamer &iStreamer, NormalizedState *oNormalizedState) const
This method is called to read a deprecated (prior version) RTState from the stream.
Definition: Parameters.cpp:112
Maintains the order used to save/restore the RT and GUI state.
Definition: NormalizedState.h:43
std::map< int16, NormalizedState::SaveOrder > fRTDeprecatedSaveStateOrders
Definition: Parameters.h:464
std::shared_ptr< RawVstParamDef > RawVstParam
Definition: ParamDef.h:509
ParamID fParamID
Definition: Parameters.h:183
virtual ParamValue readNormalizedValue(ParamID iParamID, IBStreamer &iStreamer) const
Definition: Parameters.cpp:158
VstParamDefBuilder & converter(Args &&...iArgs)
Definition: Parameters.h:133
RawVstParamDefBuilder & shortTitle(VstString16 iShortTitle)
Definition: Parameters.h:80
bool fTransient
Definition: Parameters.h:148
VstParamDefBuilder & precision(int32 iPrecision)
Definition: Parameters.h:126
int32 fPrecision
Definition: Parameters.h:99
virtual tresult readRTState(IBStreamer &iStreamer, NormalizedState *oNormalizedState) const
This method is called to read the RTState from the stream.
Definition: Parameters.cpp:94
ParamValue fDefaultValue
Definition: Parameters.h:94
int32 fFlags
Definition: Parameters.h:96
VstParamDefBuilder & unitID(int32 iUnitID)
Definition: Parameters.h:124
VstParamDefBuilder & deprecatedSince(int16 iVersion)
Definition: Parameters.h:130
std::vector< ParamID > fVstRegistrationOrder
Definition: Parameters.h:454
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:460
RawVstParam add(RawVstParamDefBuilder const &iBuilder)
Definition: Parameters.cpp:593
Used to communicate the state between the UI and the RT and read/write to stream.
Definition: NormalizedState.h:37
NormalizedState::SaveOrder fGUISaveStateOrder
Definition: Parameters.h:461
Parameters * fParameters
Definition: Parameters.h:159
std::shared_ptr< RawVstParamDef > getRawVstParamDef(ParamID iParamID) const
Definition: Parameters.cpp:173
std::vector< ParamID > fAllRegistrationOrder
Definition: Parameters.h:457
UnitID fUnitID
Definition: Parameters.h:97
VstParamDefBuilder & flags(int32 iFlags)
Definition: Parameters.h:123
int32 fPrecision
Definition: Parameters.h:146
tresult buildParamIDs(std::vector< ParamID > &iParamIDs)
Definition: Parameters.h:469
RawVstParamDefBuilder & deprecatedSince(int16 iVersion)
Definition: Parameters.h:85
std::map< int16, NormalizedState::SaveOrder > fGUIDeprecatedSaveStateOrders
Definition: Parameters.h:465
Parameters * fParameters
Definition: Parameters.h:199
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:177
VstString16 fUnits
Definition: Parameters.h:93
tresult buildParamIDs(std::vector< ParamID > &iParamIDs, std::shared_ptr< RawVstParamDef > &iParamDef, Args &&...args)
Definition: Parameters.h:498
std::vector< ParamID > const & getVstRegistrationOrder() const
Definition: Parameters.h:374
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:639
RawVstParamDefBuilder & units(VstString16 iUnits)
Definition: Parameters.h:75
RawVstParamDefBuilder & rtOwned()
Definition: Parameters.h:82
int32 fStepCount
Definition: Parameters.h:95
NormalizedState::SaveOrder const * getGUIDeprecatedSaveStateOrder(int16 iVersion) const
Definition: Parameters.cpp:572
RawVstParamDefBuilder(Parameters *iParameters, ParamID iParamID, VstString16 iTitle)
Definition: Parameters.h:107
Parameters * fParameters
Definition: Parameters.h:111
UnitID fUnitID
Definition: Parameters.h:144
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:484
JmbParamDefBuilder & defaultValue(T const &iDefaultValue)
Definition: Parameters.h:169
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:630
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:127
VstString16 fTitle
Definition: Parameters.h:184
virtual void onParameterChange(ParamID iParamID)=0
NormalizedState::SaveOrder const & getGUISaveStateOrder() const
Definition: Parameters.h:292
bool fTransient
Definition: Parameters.h:101
JmbParamDefBuilder & rtOwned()
Definition: Parameters.h:172
RawVstParam add() const
Definition: Parameters.cpp:585
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:605
RawVstParamDefBuilder & defaultValue(ParamValue iDefaultValue)
Definition: Parameters.h:76
tresult setRTDeprecatedSaveStateOrder(int16 iVersion, Args &&...args)
This method should be called to save the order of a deprecated version so that it can be handled duri...
Definition: Parameters.h:697
VstParamDefBuilder< T > vstFromType(ParamID iParamID, VstString16 iTitle)
Used from derived classes to build a parameter backed by a VST parameter.
Definition: Parameters.h:596
JmbParamDefBuilder & deprecatedSince(int16 iVersion)
Definition: Parameters.h:171
VstParam< T > add() const
Definition: Parameters.h:525
tresult addVstParamDef(std::shared_ptr< RawVstParamDef > iParamDef)
Definition: Parameters.cpp:198
JmbParamDefBuilder & serializer(std::shared_ptr< IParamSerializer< T >> iSerializer)
Definition: Parameters.h:175
RawVstParamDefBuilder & stepCount(int32 iStepCount)
Definition: Parameters.h:77
int16 fDeprecatedSince
Definition: Parameters.h:102
JmbParamDefBuilder & shared(bool iShared=true)
Definition: Parameters.h:174
int16 fDeprecatedSince
Definition: Parameters.h:149
tresult buildParamIDs(std::vector< ParamID > &iParamIDs, std::shared_ptr< IJmbParamDef > &iParamDef, Args &&...args)
Definition: Parameters.h:477
VstParamDefBuilder & defaultValue(T const &iDefaultValue)
Definition: Parameters.h:122
T fDefaultValue
Definition: Parameters.h:185
ParamID fParamID
Definition: Parameters.h:91
RawVstParamDefBuilder raw(ParamID iParamID, VstString16 iTitle)
Used from derived classes to build a parameter backed by a raw VST parameter.
Definition: Parameters.cpp:617
JmbParamDefBuilder & guiOwned()
Definition: Parameters.h:173
virtual tresult handleRTStateUpgrade(NormalizedState const &iDeprecatedState, NormalizedState &oNewState) const
When Jamba detects that a previously saved RT state matches a deprecated version (as registered with ...
Definition: Parameters.h:416
virtual tresult writeRTState(NormalizedState const *iNormalizedState, IBStreamer &oStreamer) const
This method is called to write the NormalizedState to the stream.
Definition: Parameters.cpp:149
IParamDef::Owner fOwner
Definition: Parameters.h:186
JmbParam< T > add() const
Definition: Parameters.h:516
ParamID fParamID
Definition: Parameters.h:139
Definition: Clock.h:23
tresult setGUIDeprecatedSaveStateOrder(int16 iVersion, Args &&...args)
This method should be called to save the order of a deprecated version so that it can be handled duri...
Definition: Parameters.h:719
tresult buildParamIDs(std::vector< ParamID > &iParamIDs, std::shared_ptr< VstParamDef< ParamConverver >> &iParamDef, Args &&...args)
Definition: Parameters.h:491
RawVstParamDefBuilder & guiOwned()
Definition: Parameters.h:83
VstParamDefBuilder & units(VstString16 iUnits)
Definition: Parameters.h:121
IParamDef::Owner fOwner
Definition: Parameters.h:100
bool fTransient
Definition: Parameters.h:187
tresult addJmbParamDef(std::shared_ptr< IJmbParamDef > iParamDef)
Definition: Parameters.cpp:236
JmbParamDefBuilder(Parameters *iParameters, ParamID iParamID, VstString16 iTitle)
Definition: Parameters.h:195
VstParamDefBuilder(Parameters *iParameters, ParamID iParamID, VstString16 iTitle)
Definition: Parameters.h:155
VstParamDefBuilder & shortTitle(VstString16 iShortTitle)
Definition: Parameters.h:125
T fDefaultValue
Definition: Parameters.h:142
IParamDef::Owner fOwner
Definition: Parameters.h:147
Implements the builder pattern for ease of build.
Definition: Parameters.h:118
std::map< ParamID, std::shared_ptr< IJmbParamDef > > fJmbParams
Definition: Parameters.h:451
Interface to implement to receive parameter changes.
Definition: Parameters.h:43
bool fShared
Definition: Parameters.h:189
A vst parameter is represented by a ParamValue type which is a double in the range [0,...
Definition: ParamConverters.h:53
int16 fDeprecatedSince
Definition: Parameters.h:188
std::map< ParamID, std::shared_ptr< RawVstParamDef > > fVstParams
Definition: Parameters.h:448
VstParamDefBuilder & guiOwned()
Definition: Parameters.h:128