Jamba C++ API 7.5.0
Loading...
Searching...
No Matches
NormalizedState.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 or the MIT license,
5 * at your option. You may not use this file except in compliance with
6 * one of these licenses. You may obtain copies of the licenses at:
7 *
8 * https://www.apache.org/licenses/LICENSE-2.0
9 * https://opensource.org/licenses/MIT
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14 * License for the specific language governing permissions and limitations under
15 * the License.
16 *
17 * @author Yan Pujante
18 */
19#pragma once
20
21#include <pluginterfaces/vst/vsttypes.h>
22#include <base/source/fstreamer.h>
23#include <pongasoft/logging/logging.h>
24
25#include <string>
26#include <vector>
27
28namespace pongasoft::VST {
29
30using namespace Steinberg::Vst;
31using namespace Steinberg;
32
33class Parameters;
34
39{
40public:
44 struct SaveOrder
45 {
46 int16 fVersion{0};
47 std::vector<ParamID> fOrder{};
48 inline int getCount() const { return static_cast<int>(fOrder.size()); }
49 };
50
51 // Constructor
52 explicit NormalizedState(SaveOrder const *iSaveOrder);
53
54 // Destructor
56
57 // Copy constructor
58 NormalizedState(NormalizedState const &other);
59
60 // Copies the content of the array ONLY when same SaveOrder (which is the case internally)
62
69 int copyValuesTo(NormalizedState &oDestination) const;
70
77 inline int copyValuesFrom(NormalizedState const &iSource) { return iSource.copyValuesTo(*this); }
78
79 // getCount
80 inline int getCount() const { return fSaveOrder->getCount(); }
81
82 // getVersion
83 inline int16 getVersion() const { return fSaveOrder->fVersion; }
84
89 int findParamIndex(ParamID iParamID) const;
90
92 inline void set(int iIdx, ParamValue iParamValue)
93 {
94 DCHECK_F(iIdx >= 0 && iIdx < fSaveOrder->getCount());
95 fValues[iIdx] = iParamValue;
96 }
97
99 inline ParamValue get(int iIdx) const
100 {
101 DCHECK_F(iIdx >= 0 && iIdx < fSaveOrder->getCount());
102 return fValues[iIdx];
103 }
104
105 // readFromStream
106 virtual tresult readFromStream(Parameters const *iParameters, IBStreamer &iStreamer);
107
108 // writeToStream
109 virtual tresult writeToStream(Parameters const *iParameters, IBStreamer &oStreamer) const;
110
115 tresult getNormalizedValue(ParamID iParamID, ParamValue &oValue) const;
116
121 tresult setNormalizedValue(ParamID iParamID, ParamValue iValue);
122
123
124 // toString
125 std::string toString() const;
126
127public:
129 ParamValue *fValues{nullptr};
130};
131
132
133}
134
Used to communicate the state between the UI and the RT and read/write to stream.
Definition NormalizedState.h:39
std::string toString() const
Definition NormalizedState.cpp:172
int16 getVersion() const
Definition NormalizedState.h:83
int getCount() const
Definition NormalizedState.h:80
NormalizedState & operator=(NormalizedState const &other)
Definition NormalizedState.cpp:64
int copyValuesFrom(NormalizedState const &iSource)
Copy values from the source (iSource) state to this state.
Definition NormalizedState.h:77
tresult getNormalizedValue(ParamID iParamID, ParamValue &oValue) const
Returns the normalized value for the given param id if it exists.
Definition NormalizedState.cpp:132
NormalizedState(SaveOrder const *iSaveOrder)
Definition NormalizedState.cpp:29
void set(int iIdx, ParamValue iParamValue)
Sets the param value.
Definition NormalizedState.h:92
ParamValue * fValues
Definition NormalizedState.h:129
virtual tresult writeToStream(Parameters const *iParameters, IBStreamer &oStreamer) const
Definition NormalizedState.cpp:115
int copyValuesTo(NormalizedState &oDestination) const
Copy values from this to the destination (oDestination) state.
Definition NormalizedState.cpp:83
~NormalizedState()
Definition NormalizedState.cpp:56
int findParamIndex(ParamID iParamID) const
The index for the given param.
Definition NormalizedState.cpp:162
tresult setNormalizedValue(ParamID iParamID, ParamValue iValue)
Sets the normalized value for the given param id if it exists.
Definition NormalizedState.cpp:147
ParamValue get(int iIdx) const
Gets the param value.
Definition NormalizedState.h:99
SaveOrder const * fSaveOrder
Definition NormalizedState.h:128
virtual tresult readFromStream(Parameters const *iParameters, IBStreamer &iStreamer)
Definition NormalizedState.cpp:99
This is the class which maintains all the registered parameters.
Definition Parameters.h:39
Definition Clock.h:24
Maintains the order used to save/restore the RT and GUI state.
Definition NormalizedState.h:45
int getCount() const
Definition NormalizedState.h:48
std::vector< ParamID > fOrder
Definition NormalizedState.h:47
int16 fVersion
Definition NormalizedState.h:46