27 template <
typename Self, u
int32_t NOutputs>
32 std::optional<float>
getParameter(std::string_view
id)
const override final;
33 bool setParameter(std::string_view
id,
float value)
override final;
43 static std::vector<float> defaultParameterValues();
44 static constexpr std::optional<size_t> findParameterIndex(std::string_view
id);
45 static constexpr std::optional<size_t> findProgramIndex(std::string_view name);
47 std::vector<float> parameterValues_{defaultParameterValues()};
48 size_t programIndex_{0};
53 template <
typename Self, u
int32_t NOutputs>
55 if (
const auto index = findParameterIndex(
id)) {
56 return parameterValues_[index.value()];
61 template <
typename Self, u
int32_t NOutputs>
63 if (
const auto index = findParameterIndex(
id)) {
64 const auto& descriptor = Self::parameters[index.value()];
66 if (descriptor.quantizeStep) {
67 const auto quantizeStep = descriptor.quantizeStep.value();
68 value = std::round(value / quantizeStep) * quantizeStep;
70 value = std::clamp(value, descriptor.minValue, descriptor.maxValue);
72 parameterValues_[index.value()] = value;
73 onParameterChange(
id, value);
79 template <
typename Self, u
int32_t NOutputs>
81 assert(programIndex_ < Self::programs.size());
82 return Self::programs[programIndex_];
85 template <
typename Self, u
int32_t NOutputs>
87 if (
const auto index = findProgramIndex(name)) {
88 programIndex_ = index.value();
89 onProgramChange(name);
95 template <
typename Self, u
int32_t NOutputs>
97 std::vector<float> values(Self::parameters.size());
98 for (
size_t i = 0; i < Self::parameters.size(); ++i) {
99 values[i] = Self::parameters[i].defaultValue;
104 template <
typename Self, u
int32_t NOutputs>
105 constexpr std::optional<size_t> PluginExt<Self, NOutputs>::findParameterIndex(std::string_view
id) {
106 for (
size_t i = 0; i < Self::parameters.size(); ++i) {
107 if (Self::parameters[i].identifier ==
id)
return i;
112 template <
typename Self, u
int32_t NOutputs>
113 constexpr std::optional<size_t> PluginExt<Self, NOutputs>::findProgramIndex(std::string_view name) {
114 for (
size_t i = 0; i < Self::programs.size(); ++i) {
115 if (Self::programs[i] == name)
return i;