Jamba C++ API 8.0.0
Loading...
Searching...
No Matches
ParamDisplay.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2018 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
20#pragma once
21
25#include <string>
26
27namespace pongasoft::VST::Debug {
28
33{
34public:
54
55public:
56 using Value = std::string;
57 using ValueMap = std::map<Key, Value>;
58 using ParamMap = std::map<ParamID, ValueMap>;
59
60public:
61 explicit ParamDisplay(Parameters const &iParams) : fParameters{&iParams} {}
62 explicit ParamDisplay(RT::RTState const *iState) : fRTState{iState} {}
63 explicit ParamDisplay(GUI::GUIState const *iState) : fGUIState{iState} {}
64
65 // builder pattern to initialize the display
66 ParamDisplay &precision(int32 iPrecision) { fPrecision = iPrecision; return *this; }
67 ParamDisplay &keys(std::vector<Key> const &iKeys) { fKeys = iKeys; return *this; };
68 ParamDisplay &key(Key iKey) { fKeys.emplace_back(iKey); return *this; }
69 ParamDisplay &ids(std::vector<ParamID> const &iParamIDs) { fParamIDs = iParamIDs; return *this; };
70 ParamDisplay &id(ParamID iParamID) { fParamIDs.emplace_back(iParamID); return *this; };
71
72 Value getValue(Key iKey) const;
73 Value getValue(ParamID iParamID, Key iKey) const;
74 ValueMap getValues(ParamID iParamID, std::vector<Key> const &iKeys = {}) const;
75 ParamMap getParamMap(std::vector<ParamID> const &iParamIDs = {}) const;
76 ParamMap getParamMap(NormalizedState const &iNormalizedState) const;
77
78 std::vector<Key> const &keys() const { return fKeys; }
79 std::vector<ParamID> const &ids() const { return fParamIDs; }
80
81protected:
82 Value getValue(RawVstParamDef const *iParamDef, Key iKey) const;
83 Value getValue(IJmbParamDef const *iParamDef, Key iKey) const;
84 Value getValue(std::unique_ptr<RT::RTRawVstParameter> const &iParam, Key iKey) const;
85 Value getValue(std::unique_ptr<RT::IRTJmbInParameter> const &iParam, Key iKey) const;
86 Value getValue(std::unique_ptr<RT::IRTJmbOutParameter> const &iParam, Key iKey) const;
87 Value getValue(std::shared_ptr<GUI::GUIRawVstParameter> const &iParam, Key iKey, Parameters const *iParameters) const;
88 Value getValue(GUI::IGUIJmbParameter const &iParam, Key iKey) const;
89
90 Value getValue(Parameters const *iParams, ParamID iParamID, Key iKey) const;
91 Value getValue(RT::RTState const *iState, ParamID iParamID, Key iKey) const;
92 Value getValue(GUI::GUIState const *iState, ParamID iParamID, Key iKey) const;
93
94 // convenient call which uses the precision to render the raw value
95 Value getValue(ParamValue iValue) const;
96
97 // getRawVstParamDef (nullptr if not found)
98 std::shared_ptr<RawVstParamDef> getRawVstParamDef(ParamID iParamID) const;
99
100public:
105 static ParamDisplay from(Parameters const &iParams);
106
111 static ParamDisplay from(RT::RTState const *iState, bool iSaveStateOnly = false);
112
117 static ParamDisplay from(GUI::GUIState const *iState, bool iSaveStateOnly = false);
118
119private:
120 std::vector<Key> fKeys{};
121 std::vector<ParamID> fParamIDs{};
122 int32 fPrecision{3};
123
127};
128
129}
130
This helper class is used to display the parameters (vst/jmb) WARNING: this class is allocating memor...
Definition ParamDisplay.h:33
std::shared_ptr< RawVstParamDef > getRawVstParamDef(ParamID iParamID) const
Definition ParamDisplay.cpp:52
ParamDisplay(GUI::GUIState const *iState)
Definition ParamDisplay.h:63
std::vector< ParamID > fParamIDs
Definition ParamDisplay.h:121
static ParamDisplay from(Parameters const &iParams)
Shortcut to create a table for all registered parameter (definition not current value).
Definition ParamDisplay.cpp:443
Parameters const * fParameters
Definition ParamDisplay.h:124
std::vector< Key > fKeys
Definition ParamDisplay.h:120
ParamDisplay & id(ParamID iParamID)
Definition ParamDisplay.h:70
GUI::GUIState const * fGUIState
Definition ParamDisplay.h:126
ParamDisplay(RT::RTState const *iState)
Definition ParamDisplay.h:62
ParamDisplay & precision(int32 iPrecision)
Definition ParamDisplay.h:66
int32 fPrecision
Definition ParamDisplay.h:122
std::vector< Key > const & keys() const
Definition ParamDisplay.h:78
Value getValue(Key iKey) const
Definition ParamDisplay.cpp:385
ValueMap getValues(ParamID iParamID, std::vector< Key > const &iKeys={}) const
Definition ParamDisplay.cpp:69
std::vector< ParamID > const & ids() const
Definition ParamDisplay.h:79
ParamDisplay(Parameters const &iParams)
Definition ParamDisplay.h:61
std::map< ParamID, ValueMap > ParamMap
Definition ParamDisplay.h:58
Key
Definition ParamDisplay.h:36
@ kSteps
Definition ParamDisplay.h:46
@ kTransient
Definition ParamDisplay.h:41
@ kUnits
Definition ParamDisplay.h:51
@ kOwner
Definition ParamDisplay.h:40
@ kNormalizedDefault
Definition ParamDisplay.h:42
@ kPrecision
Definition ParamDisplay.h:49
@ kUnitID
Definition ParamDisplay.h:50
@ kDefault
Definition ParamDisplay.h:43
@ kTitle
Definition ParamDisplay.h:39
@ kShared
Definition ParamDisplay.h:52
@ kValue
Definition ParamDisplay.h:45
@ kNormalizedValue
Definition ParamDisplay.h:44
@ kShortTitle
Definition ParamDisplay.h:48
@ kType
Definition ParamDisplay.h:38
@ kFlags
Definition ParamDisplay.h:47
@ kID
Definition ParamDisplay.h:37
RT::RTState const * fRTState
Definition ParamDisplay.h:125
ParamMap getParamMap(std::vector< ParamID > const &iParamIDs={}) const
Definition ParamDisplay.cpp:86
ParamDisplay & key(Key iKey)
Definition ParamDisplay.h:68
std::map< Key, Value > ValueMap
Definition ParamDisplay.h:57
ParamDisplay & ids(std::vector< ParamID > const &iParamIDs)
Definition ParamDisplay.h:69
std::string Value
Definition ParamDisplay.h:56
ParamDisplay & keys(std::vector< Key > const &iKeys)
Definition ParamDisplay.h:67
Definition GUIState.h:45
Base class for a Jamba (Jmb) GUI parameter.
Definition GUIJmbParameter.h:42
Base class for jamba parameters (non templated).
Definition ParamDef.h:281
This is the class that maintains all the registered parameters.
Definition Parameters.h:41
Manages the state used by the processor: you add all the parameters that the state manages using the ...
Definition RTState.h:45
Base class for a raw vst parameter definition.
Definition ParamDef.h:92
Definition ParamDisplay.cpp:29
ParamDisplay::Key Key
Definition ParamLine.cpp:81
ParamDisplay::ValueMap ValueMap
Definition ParamTable.cpp:33