Jamba C++ API 7.5.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 {
28namespace VST {
29namespace Debug {
30
35{
36public:
56
57public:
58 using Value = std::string;
59 using ValueMap = std::map<Key, Value>;
60 using ParamMap = std::map<ParamID, ValueMap>;
61
62public:
63 explicit ParamDisplay(Parameters const &iParams) : fParameters{&iParams} {}
64 explicit ParamDisplay(RT::RTState const *iState) : fRTState{iState} {}
65 explicit ParamDisplay(GUI::GUIState const *iState) : fGUIState{iState} {}
66
67 // builder pattern to initialize the display
68 ParamDisplay &precision(int32 iPrecision) { fPrecision = iPrecision; return *this; }
69 ParamDisplay &keys(std::vector<Key> const &iKeys) { fKeys = iKeys; return *this; };
70 ParamDisplay &key(Key iKey) { fKeys.emplace_back(iKey); return *this; }
71 ParamDisplay &ids(std::vector<ParamID> const &iParamIDs) { fParamIDs = iParamIDs; return *this; };
72 ParamDisplay &id(ParamID iParamID) { fParamIDs.emplace_back(iParamID); return *this; };
73
74 Value getValue(Key iKey) const;
75 Value getValue(ParamID iParamID, Key iKey) const;
76 ValueMap getValues(ParamID iParamID, std::vector<Key> const &iKeys = {}) const;
77 ParamMap getParamMap(std::vector<ParamID> const &iParamIDs = {}) const;
78 ParamMap getParamMap(NormalizedState const &iNormalizedState) const;
79
80 std::vector<Key> const &keys() const { return fKeys; }
81 std::vector<ParamID> const &ids() const { return fParamIDs; }
82
83protected:
84 Value getValue(RawVstParamDef const *iParamDef, Key iKey) const;
85 Value getValue(IJmbParamDef const *iParamDef, Key iKey) const;
86 Value getValue(std::unique_ptr<RT::RTRawVstParameter> const &iParam, Key iKey) const;
87 Value getValue(std::unique_ptr<RT::IRTJmbInParameter> const &iParam, Key iKey) const;
88 Value getValue(std::unique_ptr<RT::IRTJmbOutParameter> const &iParam, Key iKey) const;
89 Value getValue(std::shared_ptr<GUI::GUIRawVstParameter> const &iParam, Key iKey, Parameters const *iParameters) const;
90 Value getValue(GUI::IGUIJmbParameter const &iParam, Key iKey) const;
91
92 Value getValue(Parameters const *iParams, ParamID iParamID, Key iKey) const;
93 Value getValue(RT::RTState const *iState, ParamID iParamID, Key iKey) const;
94 Value getValue(GUI::GUIState const *iState, ParamID iParamID, Key iKey) const;
95
96 // convenient call which uses the precision to render the raw value
97 Value getValue(ParamValue iValue) const;
98
99 // getRawVstParamDef (nullptr if not found)
100 std::shared_ptr<RawVstParamDef> getRawVstParamDef(ParamID iParamID) const;
101
102public:
107 static ParamDisplay from(Parameters const &iParams);
108
113 static ParamDisplay from(RT::RTState const *iState, bool iSaveStateOnly = false);
114
119 static ParamDisplay from(GUI::GUIState const *iState, bool iSaveStateOnly = false);
120
121private:
122 std::vector<Key> fKeys{};
123 std::vector<ParamID> fParamIDs{};
124 int32 fPrecision{3};
125
129};
130
131}
132}
133}
134
This helper class is used to display the parameters (vst/jmb) WARNING: this class is allocating memor...
Definition ParamDisplay.h:35
std::shared_ptr< RawVstParamDef > getRawVstParamDef(ParamID iParamID) const
Definition ParamDisplay.cpp:52
ParamDisplay(GUI::GUIState const *iState)
Definition ParamDisplay.h:65
std::vector< ParamID > fParamIDs
Definition ParamDisplay.h:123
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:126
std::vector< Key > fKeys
Definition ParamDisplay.h:122
ParamDisplay & id(ParamID iParamID)
Definition ParamDisplay.h:72
GUI::GUIState const * fGUIState
Definition ParamDisplay.h:128
ParamDisplay(RT::RTState const *iState)
Definition ParamDisplay.h:64
ParamDisplay & precision(int32 iPrecision)
Definition ParamDisplay.h:68
int32 fPrecision
Definition ParamDisplay.h:124
std::vector< Key > const & keys() const
Definition ParamDisplay.h:80
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:81
ParamDisplay(Parameters const &iParams)
Definition ParamDisplay.h:63
std::map< ParamID, ValueMap > ParamMap
Definition ParamDisplay.h:60
Key
Definition ParamDisplay.h:38
@ kSteps
Definition ParamDisplay.h:48
@ kTransient
Definition ParamDisplay.h:43
@ kUnits
Definition ParamDisplay.h:53
@ kOwner
Definition ParamDisplay.h:42
@ kNormalizedDefault
Definition ParamDisplay.h:44
@ kPrecision
Definition ParamDisplay.h:51
@ kUnitID
Definition ParamDisplay.h:52
@ kDefault
Definition ParamDisplay.h:45
@ kTitle
Definition ParamDisplay.h:41
@ kShared
Definition ParamDisplay.h:54
@ kValue
Definition ParamDisplay.h:47
@ kNormalizedValue
Definition ParamDisplay.h:46
@ kShortTitle
Definition ParamDisplay.h:50
@ kType
Definition ParamDisplay.h:40
@ kFlags
Definition ParamDisplay.h:49
@ kID
Definition ParamDisplay.h:39
RT::RTState const * fRTState
Definition ParamDisplay.h:127
ParamMap getParamMap(std::vector< ParamID > const &iParamIDs={}) const
Definition ParamDisplay.cpp:86
ParamDisplay & key(Key iKey)
Definition ParamDisplay.h:70
std::map< Key, Value > ValueMap
Definition ParamDisplay.h:59
ParamDisplay & ids(std::vector< ParamID > const &iParamIDs)
Definition ParamDisplay.h:71
std::string Value
Definition ParamDisplay.h:58
ParamDisplay & keys(std::vector< Key > const &iKeys)
Definition ParamDisplay.h:69
Definition GUIState.h:43
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 which maintains all the registered parameters.
Definition Parameters.h:39
Manages the state used by the processor: you add all the parameters that the state manages using the ...
Definition RTState.h:46
Base class for a raw vst parameter definition.
Definition ParamDef.h:92
Definition ParamDisplay.cpp:29
ParamDisplay::Key Key
Definition ParamLine.cpp:83
ParamDisplay::ValueMap ValueMap
Definition ParamTable.cpp:35
Definition Clock.h:24
Definition Clock.h:23