Vital
Loading...
Searching...
No Matches
synth_parameters.h
Go to the documentation of this file.
1/*
2Summary:
3The Parameters and ValueDetailsLookup classes centralize all parameter definitions for Vital. They define the behavior, ranges, and displayed names/units of every parameter (e.g., oscillators, filters, LFOs, envelopes). The code organizes parameters into groups (for envelopes, LFOs, oscillators, filters, and more) and ensures compatibility across versions. This system allows for easy retrieval of parameter metadata throughout the synthesizer’s code and UI layers.
4 */
5
6#pragma once
7
8#include "common.h"
9
10#include <map>
11#include <string>
12
13namespace vital {
14
52
64 public:
71
78 const bool isParameter(const std::string& name) const {
79 return details_lookup_.count(name);
80 }
81
88 const ValueDetails& getDetails(const std::string& name) const {
89 auto details = details_lookup_.find(name);
90 VITAL_ASSERT(details != details_lookup_.end());
91 return details->second;
92 }
93
100 const ValueDetails* getDetails(int index) const {
101 return details_list_[index];
102 }
103
110 std::string getDisplayName(const std::string& name) const {
111 return getDetails(name).display_name;
112 }
113
119 int getNumParameters() const {
120 return static_cast<int>(details_list_.size());
121 }
122
129 mono_float getParameterRange(const std::string& name) const {
130 auto details = details_lookup_.find(name);
131 VITAL_ASSERT(details != details_lookup_.end());
132 return details->second.max - details->second.min;
133 }
134
140 std::map<std::string, ValueDetails> getAllDetails() const {
141 return details_lookup_;
142 }
143
156 void addParameterGroup(const ValueDetails* list, int num_parameters, int index,
157 std::string id_prefix, std::string name_prefix, int version = -1);
158
169 void addParameterGroup(const ValueDetails* list, int num_parameters, std::string id,
170 std::string id_prefix, std::string name_prefix, int version = -1);
171
172 // Static arrays of parameter definitions for different categories.
180
181 private:
182 std::map<std::string, ValueDetails> details_lookup_;
183 std::vector<const ValueDetails*> details_list_;
184
185 JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(ValueDetailsLookup)
186 };
187
199 public:
200 static const ValueDetails& getDetails(const std::string& name) {
201 return lookup_.getDetails(name);
202 }
203
204 static int getNumParameters() {
205 return lookup_.getNumParameters();
206 }
207
208 static const ValueDetails* getDetails(int index) {
209 return lookup_.getDetails(index);
210 }
211
212 static std::string getDisplayName(const std::string& name) {
213 return lookup_.getDisplayName(name);
214 }
215
216 static const mono_float getParameterRange(const std::string& name) {
217 return lookup_.getParameterRange(name);
218 }
219
220 static const bool isParameter(const std::string& name) {
221 return lookup_.isParameter(name);
222 }
223
224 static std::map<std::string, ValueDetails> getAllDetails() {
225 return lookup_.getAllDetails();
226 }
227
229
230 private:
231 Parameters() { }
232 };
233
234} // namespace vital
A static utility class to access parameter details globally.
Definition synth_parameters.h:198
static const ValueDetails * getDetails(int index)
Definition synth_parameters.h:208
static ValueDetailsLookup lookup_
Definition synth_parameters.h:228
static int getNumParameters()
Definition synth_parameters.h:204
static const bool isParameter(const std::string &name)
Definition synth_parameters.h:220
static std::map< std::string, ValueDetails > getAllDetails()
Definition synth_parameters.h:224
static const ValueDetails & getDetails(const std::string &name)
Definition synth_parameters.h:200
static std::string getDisplayName(const std::string &name)
Definition synth_parameters.h:212
static const mono_float getParameterRange(const std::string &name)
Definition synth_parameters.h:216
Maintains a lookup table for all parameters defined in Vital.
Definition synth_parameters.h:63
int getNumParameters() const
Gets the number of parameters defined.
Definition synth_parameters.h:119
mono_float getParameterRange(const std::string &name) const
Gets the full parameter range (max - min).
Definition synth_parameters.h:129
static const ValueDetails parameter_list[]
Definition synth_parameters.h:173
const bool isParameter(const std::string &name) const
Checks if a given name corresponds to a known parameter.
Definition synth_parameters.h:78
static const ValueDetails osc_parameter_list[]
Definition synth_parameters.h:178
std::map< std::string, ValueDetails > getAllDetails() const
Returns a copy of all parameter details in a map.
Definition synth_parameters.h:140
static const ValueDetails random_lfo_parameter_list[]
Definition synth_parameters.h:176
const ValueDetails & getDetails(const std::string &name) const
Retrieves ValueDetails for a given parameter name.
Definition synth_parameters.h:88
static const ValueDetails env_parameter_list[]
Definition synth_parameters.h:174
static const ValueDetails filter_parameter_list[]
Definition synth_parameters.h:177
std::string getDisplayName(const std::string &name) const
Gets a human-readable display name for a parameter.
Definition synth_parameters.h:110
ValueDetailsLookup()
Constructs a ValueDetailsLookup and initializes its parameter tables.
Definition synth_parameters.cpp:537
static const ValueDetails mod_parameter_list[]
Definition synth_parameters.h:179
static const ValueDetails lfo_parameter_list[]
Definition synth_parameters.h:175
const ValueDetails * getDetails(int index) const
Retrieves ValueDetails by parameter index.
Definition synth_parameters.h:100
void addParameterGroup(const ValueDetails *list, int num_parameters, int index, std::string id_prefix, std::string name_prefix, int version=-1)
Adds a group of parameters, each with prefixed names and display names.
Definition synth_parameters.cpp:608
#define VITAL_ASSERT(x)
Definition common.h:11
Contains classes and functions used within the Vital synthesizer framework.
float mono_float
Definition common.h:33
Holds metadata about a single parameter (control) in the Vital synthesizer.
Definition synth_parameters.h:23
mono_float max
Maximum parameter value.
Definition synth_parameters.h:41
mono_float display_multiply
Multiplier for converting internal values to display units.
Definition synth_parameters.h:44
bool display_invert
If true, invert the displayed value range.
Definition synth_parameters.h:46
mono_float post_offset
Offset applied after scaling (for certain scale types).
Definition synth_parameters.h:43
ValueScale
Describes the scaling mode used to interpret and display parameter values.
Definition synth_parameters.h:28
@ kQuartic
Parameter value transformed by a quartic curve.
Definition synth_parameters.h:33
@ kSquareRoot
Parameter value transformed by a square root function.
Definition synth_parameters.h:34
@ kLinear
Parameter scales linearly between min and max.
Definition synth_parameters.h:30
@ kCubic
Parameter value transformed by a cubic curve.
Definition synth_parameters.h:32
@ kExponential
Parameter value transformed by an exponential function.
Definition synth_parameters.h:35
@ kIndexed
Parameter steps through discrete indexed values.
Definition synth_parameters.h:29
@ kQuadratic
Parameter value transformed by a quadratic curve.
Definition synth_parameters.h:31
mono_float min
Minimum parameter value.
Definition synth_parameters.h:40
std::string display_name
Human-readable name for display in UI.
Definition synth_parameters.h:48
std::string local_description
Local description or additional metadata.
Definition synth_parameters.h:50
int version_added
Version code when the parameter was introduced or changed.
Definition synth_parameters.h:39
const std::string * string_lookup
Optional lookup table for indexed parameter names.
Definition synth_parameters.h:49
mono_float default_value
Default value for the parameter.
Definition synth_parameters.h:42
std::string name
Unique parameter name/identifier.
Definition synth_parameters.h:38
ValueScale value_scale
The scaling mode of the parameter value.
Definition synth_parameters.h:45
std::string display_units
Units to display next to the parameter (e.g., "Hz", "dB").
Definition synth_parameters.h:47