Jamba  3.0.2
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 
54 
58  std::unique_ptr<FObjectCx> connect(ParamID iParamID, Parameters::IChangeListener *iChangeListener)
59  {
60  if(exists(iParamID))
61  return std::make_unique<GUIParamCx>(iParamID,
62  getParameterObject(iParamID),
63  iChangeListener);
64  else
65  return nullptr;
66  }
67 
71  std::unique_ptr<FObjectCx> connect(ParamID iParamID, Parameters::ChangeCallback iChangeCallback) const
72  {
73  if(exists(iParamID))
74  return std::make_unique<FObjectCxCallback>(getParameterObject(iParamID),
75  std::move(iChangeCallback));
76  else
77  return nullptr;
78  }
79 
80  // exists
81  inline bool exists(ParamID iParamID) const { return getParameterObject(iParamID) != nullptr; }
82 
83 private:
84  EditController *const fParametersOwner;
85 };
86 
87 using VstParametersSPtr = std::shared_ptr<VstParameters>;
88 
89 }
90 }
91 }
92 }
EditController *const fParametersOwner
Definition: VstParameters.h:84
Definition: Clock.h:22
VstParameters(EditController *const iParametersOwner)
Definition: VstParameters.h:41
ParamValue getParamNormalized(ParamID iParamID) const
Definition: VstParameters.h:47
Vst::Parameter * getParameterObject(ParamID iParamID) const
Definition: VstParameters.h:52
tresult setParamNormalized(ParamID iParamID, ParamValue iValue) const
Definition: VstParameters.h:48
tresult endEdit(ParamID iParamID) const
Definition: VstParameters.h:51
tresult beginEdit(ParamID iParamID) const
Definition: VstParameters.h:49
std::function< void()> ChangeCallback
Definition: Parameters.h:57
Definition: VstParameters.h:38
tresult performEdit(ParamID iParamID, ParamValue iValue) const
Definition: VstParameters.h:50
std::unique_ptr< FObjectCx > connect(ParamID iParamID, Parameters::ChangeCallback iChangeCallback) const
Definition: VstParameters.h:71
std::unique_ptr< FObjectCx > connect(ParamID iParamID, Parameters::IChangeListener *iChangeListener)
Definition: VstParameters.h:58
bool exists(ParamID iParamID) const
Definition: VstParameters.h:81
std::shared_ptr< VstParameters > VstParametersSPtr
Definition: VstParameters.h:87