Jamba C++ API  5.1.1
VstParameters.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018 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 <pongasoft/logging/logging.h>
21 
22 #include <base/source/fstreamer.h>
23 #include <public.sdk/source/vst/vsteditcontroller.h>
24 #include <memory>
25 #include "GUIParamCx.h"
26 
27 namespace pongasoft {
28 namespace VST {
29 namespace GUI {
30 namespace Params {
31 
32 using namespace Steinberg;
33 using namespace Steinberg::Vst;
34 
39 {
40 public:
41  explicit VstParameters(EditController *const iParametersOwner) : fParametersOwner{iParametersOwner}
42  {
43  DCHECK_NOTNULL_F(iParametersOwner);
44  }
45 
46  // getParamNormalized
47  inline ParamValue getParamNormalized(ParamID iParamID) const { return fParametersOwner->getParamNormalized(iParamID); }
48  inline tresult setParamNormalized(ParamID iParamID, ParamValue iValue) const { return fParametersOwner->setParamNormalized(iParamID, iValue); }
49  inline tresult beginEdit(ParamID iParamID) const { return fParametersOwner->beginEdit(iParamID); }
50  inline tresult performEdit(ParamID iParamID, ParamValue iValue) const { return fParametersOwner->performEdit(iParamID, iValue); }
51  inline tresult endEdit(ParamID iParamID) const { return fParametersOwner->endEdit(iParamID); }
52  Vst::Parameter *getParameterObject(ParamID iParamID) const { return fParametersOwner->getParameterObject(iParamID); }
53 
57  Vst::ParameterInfo const *getParameterInfo(ParamID iParamID) const {
58  auto parameter = getParameterObject(iParamID);
59  return parameter ? &parameter->getInfo() : nullptr;
60  }
61 
62 
66  std::unique_ptr<FObjectCx> connect(ParamID iParamID, Parameters::IChangeListener *iChangeListener)
67  {
68  if(exists(iParamID))
69  return std::make_unique<GUIParamCx>(iParamID,
70  getParameterObject(iParamID),
71  iChangeListener);
72  else
73  return nullptr;
74  }
75 
79  std::unique_ptr<FObjectCx> connect(ParamID iParamID, Parameters::ChangeCallback iChangeCallback) const
80  {
81  if(exists(iParamID))
82  return std::make_unique<FObjectCxCallback>(getParameterObject(iParamID),
83  std::move(iChangeCallback));
84  else
85  return nullptr;
86  }
87 
88  // exists
89  inline bool exists(ParamID iParamID) const { return getParameterObject(iParamID) != nullptr; }
90 
91 private:
92  EditController *const fParametersOwner;
93 };
94 
95 using VstParametersSPtr = std::shared_ptr<VstParameters>;
96 
97 }
98 }
99 }
100 }
bool exists(ParamID iParamID) const
Definition: VstParameters.h:89
VstParameters(EditController *const iParametersOwner)
Definition: VstParameters.h:41
Vst::Parameter * getParameterObject(ParamID iParamID) const
Definition: VstParameters.h:52
std::function< void()> ChangeCallback
A callback that will be invoked for changes.
Definition: Parameters.h:55
tresult setParamNormalized(ParamID iParamID, ParamValue iValue) const
Definition: VstParameters.h:48
Definition: Clock.h:22
ParamValue getParamNormalized(ParamID iParamID) const
Definition: VstParameters.h:47
tresult beginEdit(ParamID iParamID) const
Definition: VstParameters.h:49
std::unique_ptr< FObjectCx > connect(ParamID iParamID, Parameters::IChangeListener *iChangeListener)
Definition: VstParameters.h:66
This class acts as a facade/proxy to the vst parameters managed by the host daw.
Definition: VstParameters.h:38
std::unique_ptr< FObjectCx > connect(ParamID iParamID, Parameters::ChangeCallback iChangeCallback) const
Definition: VstParameters.h:79
Vst::ParameterInfo const * getParameterInfo(ParamID iParamID) const
Definition: VstParameters.h:57
std::shared_ptr< VstParameters > VstParametersSPtr
Definition: VstParameters.h:95
tresult endEdit(ParamID iParamID) const
Definition: VstParameters.h:51
tresult performEdit(ParamID iParamID, ParamValue iValue) const
Definition: VstParameters.h:50
Interface to implement to receive parameter changes.
Definition: Parameters.h:43
EditController *const fParametersOwner
Definition: VstParameters.h:92