Jamba C++ API  6.2.0
Parameters.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018-2023 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  // add id to the param (checking that the parameter actually exists)
469  tresult addParamID(std::vector<ParamID> &oParamIDs, ParamID iParamID);
470 
471  // leaf of templated calls to build a list of ParamIDs from ParamID or ParamDefs
472  tresult buildParamIDs(std::vector<ParamID> &iParamIDs) { return kResultOk; }
473 
474  // case when ParamID
475  template<typename... Args>
476  tresult buildParamIDs(std::vector<ParamID> &iParamIDs, ParamID id, Args&& ...args);
477 
478  // case when IJmbParamDef
479  template<typename... Args>
480  tresult buildParamIDs(std::vector<ParamID> &iParamIDs, std::shared_ptr<IJmbParamDef> &iParamDef, Args&& ...args)
481  {
482  return buildParamIDs(iParamIDs, iParamDef->fParamID, std::forward<Args>(args)...);
483  }
484 
485  // case when IJmbParamDef
486  template<typename T, typename... Args>
487  tresult buildParamIDs(std::vector<ParamID> &iParamIDs, std::shared_ptr<JmbParamDef<T>> &iParamDef, Args&& ...args)
488  {
489  return buildParamIDs(iParamIDs, iParamDef->fParamID, std::forward<Args>(args)...);
490  }
491 
492  // case when VstParamDef
493  template<typename ParamConverter, typename... Args>
494  tresult buildParamIDs(std::vector<ParamID> &iParamIDs, std::shared_ptr<VstParamDef<ParamConverter>> &iParamDef, Args&& ...args)
495  {
496  return buildParamIDs(iParamIDs, iParamDef->fParamID, std::forward<Args>(args)...);
497  }
498 
499  // case when array of VstParamDef
500  template<typename ParamConverter, size_t N, typename... Args>
501  tresult buildParamIDs(std::vector<ParamID> &iParamIDs, std::array<std::shared_ptr<VstParamDef<ParamConverter>>, N> &iParamDefs, Args&& ...args);
502 
503  // case when RawVstParamDef
504  template<typename... Args>
505  tresult buildParamIDs(std::vector<ParamID> &iParamIDs, std::shared_ptr<RawVstParamDef> &iParamDef, Args&& ...args)
506  {
507  return buildParamIDs(iParamIDs, iParamDef->fParamID, std::forward<Args>(args)...);
508  }
509 
513 
517 };
518 
519 //------------------------------------------------------------------------
520 // Parameters::JmbParamDefBuilder::add
521 //------------------------------------------------------------------------
522 template<typename T>
524 {
525  return fParameters->add(*this);
526 }
527 
528 //------------------------------------------------------------------------
529 // Parameters::VstParamDefBuilder::add
530 //------------------------------------------------------------------------
531 template<typename T>
533 {
534  return fParameters->add(*this);
535 }
536 
537 //------------------------------------------------------------------------
538 // Parameters::add (called by the builder)
539 //------------------------------------------------------------------------
540 template<typename T>
541 VstParam<T> Parameters::add(VstParamDefBuilder<T> const &iBuilder)
542 {
543  auto param = std::make_shared<VstParamDef<T>>(iBuilder.fParamID,
544  iBuilder.fTitle,
545  iBuilder.fUnits,
546  iBuilder.fDefaultValue,
547  iBuilder.fFlags,
548  iBuilder.fUnitID,
549  iBuilder.fShortTitle,
550  iBuilder.fPrecision,
551  iBuilder.fOwner,
552  iBuilder.fTransient,
553  iBuilder.fDeprecatedSince,
554  iBuilder.fConverter);
555 
556  if(!iBuilder.fTransient && !iBuilder.fConverter)
557  {
558  DLOG_F(WARNING, "No converter defined for non transient parameter [%d]", iBuilder.fParamID);
559  }
560 
561  if(addVstParamDef(param) == kResultOk)
562  return param;
563  else
564  return nullptr;
565 }
566 
567 //------------------------------------------------------------------------
568 // Parameters::add (called by the builder)
569 //------------------------------------------------------------------------
570 template<typename T>
572 {
573  auto param = std::make_shared<JmbParamDef<T>>(iBuilder.fParamID,
574  iBuilder.fTitle,
575  iBuilder.fOwner,
576  iBuilder.fTransient,
577  iBuilder.fDeprecatedSince,
578  iBuilder.fShared,
579  iBuilder.fDefaultValue,
580  iBuilder.fSerializer);
581 
582  if(!iBuilder.fTransient && !iBuilder.fSerializer)
583  {
584  DLOG_F(WARNING, "No serializer defined for parameter [%d] (won't be able to be saved)", iBuilder.fParamID);
585  }
586 
587  if(iBuilder.fShared && !iBuilder.fSerializer)
588  {
589  DLOG_F(WARNING, "No serializer defined for parameter [%d] (won't be able to be shared with peer)", iBuilder.fParamID);
590  }
591 
592  if(addJmbParamDef(param) == kResultOk)
593  return param;
594  else
595  return nullptr;
596 }
597 
598 
599 //------------------------------------------------------------------------
600 // Parameters::vstFromType
601 //------------------------------------------------------------------------
602 template<typename T>
604 {
605  return Parameters::VstParamDefBuilder<T>(this, iParamID, std::move(iTitle));
606 }
607 
608 //------------------------------------------------------------------------
609 // Parameters::vst
610 //------------------------------------------------------------------------
611 template<typename ParamConverter, typename... Args>
613  VstString16 iTitle,
614  Args&& ...iConverterArgs)
615 {
616  auto builder = vstFromType<typename ParamConverter::ParamType>(iParamID, std::move(iTitle));
617  builder.template converter<ParamConverter>(std::forward<Args>(iConverterArgs)...);
618  return builder;
619 }
620 
621 //------------------------------------------------------------------------
622 // Parameters::vst
623 //------------------------------------------------------------------------
624 template<typename ParamConverter>
626  VstString16 iTitle,
627  typename ParamConverter::ConstructorType initValue) {
628  auto builder = vstFromType<typename ParamConverter::ParamType>(iParamID, std::move(iTitle));
629  builder.template converter<ParamConverter>(initValue);
630  return builder;
631 }
632 
633 //------------------------------------------------------------------------
634 // Parameters::jmbFromType
635 //------------------------------------------------------------------------
636 template<typename T>
638 {
639  return Parameters::JmbParamDefBuilder<T>(this, iParamID, std::move(iTitle));
640 }
641 
642 //------------------------------------------------------------------------
643 // Parameters::jmb
644 //------------------------------------------------------------------------
645 template<typename ParamSerializer, typename... Args>
647  VstString16 iTitle,
648  Args&& ...iSerializerArgs)
649 {
650  auto builder = jmbFromType<typename ParamSerializer::ParamType>(iParamID, std::move(iTitle));
651  builder.template serializer<ParamSerializer>(std::forward<Args>(iSerializerArgs)...);
652  return builder;
653 }
654 
655 //------------------------------------------------------------------------
656 // Parameters::jmb
657 //------------------------------------------------------------------------
658 template<typename ParamSerializer>
660  VstString16 iTitle,
661  typename ParamSerializer::ConstructorType initValue) {
662  auto builder = jmbFromType<typename ParamSerializer::ParamType>(iParamID, std::move(iTitle));
663  builder.template serializer<ParamSerializer>(initValue);
664  return builder;
665 }
666 
667 //------------------------------------------------------------------------
668 // Parameters::buildParamIDs
669 //------------------------------------------------------------------------
670 template<typename... Args>
671 tresult Parameters::buildParamIDs(std::vector<ParamID> &iParamIDs, ParamID iParamID, Args&& ...args)
672 {
673  tresult res = addParamID(iParamIDs, iParamID);
674  res |= buildParamIDs(iParamIDs, std::forward<Args>(args)...);
675  return res;
676 }
677 
678 //------------------------------------------------------------------------
679 // Parameters::buildParamIDs
680 //------------------------------------------------------------------------
681 template<typename ParamConverter, size_t N, typename... Args>
682 tresult Parameters::buildParamIDs(std::vector<ParamID> &iParamIDs, std::array<std::shared_ptr<VstParamDef<ParamConverter>>, N> &iParamDefs, Args&& ...args)
683 {
684  tresult res = kResultOk;
685  for(auto &def: iParamDefs)
686  res |= addParamID(iParamIDs, def->fParamID);
687  res |= buildParamIDs(iParamIDs, std::forward<Args>(args)...);
688  return res;
689 }
690 
691 //------------------------------------------------------------------------
692 // Parameters::setRTSaveStateOrder
693 //------------------------------------------------------------------------
694 template<typename... Args>
695 tresult Parameters::setRTSaveStateOrder(int16 iVersion, Args&& ...args)
696 {
697  std::vector<ParamID> ids{};
698  buildParamIDs(ids, std::forward<Args>(args)...);
699  return setRTSaveStateOrder({iVersion, ids});
700 }
701 
702 //------------------------------------------------------------------------
703 // Parameters::setRTDeprecatedSaveStateOrder
704 //------------------------------------------------------------------------
705 template<typename... Args>
706 tresult Parameters::setRTDeprecatedSaveStateOrder(int16 iVersion, Args&& ...args)
707 {
708  std::vector<ParamID> ids{};
709  buildParamIDs(ids, std::forward<Args>(args)...);
710  return setRTDeprecatedSaveStateOrder({iVersion, ids});
711 }
712 
713 //------------------------------------------------------------------------
714 // Parameters::setRTSaveStateOrder
715 //------------------------------------------------------------------------
716 template<typename... Args>
717 tresult Parameters::setGUISaveStateOrder(int16 iVersion, Args&& ...args)
718 {
719  std::vector<ParamID> ids{};
720  buildParamIDs(ids, std::forward<Args>(args)...);
721  return setGUISaveStateOrder({iVersion, ids});
722 }
723 
724 //------------------------------------------------------------------------
725 // Parameters::setGUIDeprecatedSaveStateOrder
726 //------------------------------------------------------------------------
727 template<typename... Args>
728 tresult Parameters::setGUIDeprecatedSaveStateOrder(int16 iVersion, Args&& ...args)
729 {
730  std::vector<ParamID> ids{};
731  buildParamIDs(ids, std::forward<Args>(args)...);
732  return setGUIDeprecatedSaveStateOrder({iVersion, ids});
733 }
734 
735 }
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:717
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
tresult buildParamIDs(std::vector< ParamID > &iParamIDs, std::shared_ptr< VstParamDef< ParamConverter >> &iParamDef, Args &&...args)
Definition: Parameters.h:494
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:695
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:472
RawVstParamDefBuilder & deprecatedSince(int16 iVersion)
Definition: Parameters.h:85
std::map< int16, NormalizedState::SaveOrder > fGUIDeprecatedSaveStateOrders
Definition: Parameters.h:465
tresult addParamID(std::vector< ParamID > &oParamIDs, ParamID iParamID)
Definition: Parameters.cpp:625
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:505
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:646
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:487
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:107
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:637
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:612
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:706
VstParamDefBuilder< T > vstFromType(ParamID iParamID, VstString16 iTitle)
Used from derived classes to build a parameter backed by a VST parameter.
Definition: Parameters.h:603
JmbParamDefBuilder & deprecatedSince(int16 iVersion)
Definition: Parameters.h:171
VstParam< T > add() const
Definition: Parameters.h:532
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:480
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:523
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:728
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