commit 939c616d2efd4e4346298abad7b3d368d2a93009
parent 20fb8b32aed63a2e168be8ee6dc50ade5fcbaef5
Author: dsp56300 <dsp56300@users.noreply.github.com>
Date: Sat, 5 Mar 2022 20:34:46 +0100
prepare to have multiple juce parameters for one synth parameter
Diffstat:
4 files changed, 17 insertions(+), 33 deletions(-)
diff --git a/source/jucePlugin/VirusController.cpp b/source/jucePlugin/VirusController.cpp
@@ -55,9 +55,12 @@ namespace Virus
// 16 parts * 3 pages * 128 params
// TODO: not register internal/unused params?
auto globalParams = std::make_unique<juce::AudioProcessorParameterGroup>("global", "Global", "|");
- for (uint8_t pt = 0; pt < 16; pt++)
+
+ for (uint8_t part = 0; part < 16; part++)
{
- const auto partNumber = juce::String(pt + 1);
+ m_paramsByParamType[part].reserve(m_descriptions.getDescriptions().size());
+
+ const auto partNumber = juce::String(part + 1);
auto group =
std::make_unique<juce::AudioProcessorParameterGroup>("ch" + partNumber, "Ch " + partNumber, "|");
@@ -67,16 +70,16 @@ namespace Virus
const auto paramType = static_cast<ParameterType>(parameterDescIndex);
++parameterDescIndex;
- const ParamIndex idx = {static_cast<uint8_t>(desc.page), pt, desc.index};
+ const ParamIndex idx = {static_cast<uint8_t>(desc.page), part, desc.index};
- m_paramTypeToParamIndex.insert(std::make_pair(paramType, idx));
+ auto p = std::make_unique<Parameter>(*this, desc, part);
- auto p = std::make_unique<Parameter>(*this, desc, pt);
- const bool isNonPartExclusive = (desc.classFlags & Parameter::Class::GLOBAL) ||
- (desc.classFlags & Parameter::Class::NON_PART_SENSITIVE);
+ m_paramsByParamType[part].push_back(p.get());
+
+ const bool isNonPartExclusive = (desc.classFlags & Parameter::Class::GLOBAL) || (desc.classFlags & Parameter::Class::NON_PART_SENSITIVE);
if (isNonPartExclusive)
{
- if (pt != 0)
+ if (part != 0)
continue; // only register on first part!
}
if (p->getDescription().isPublic)
@@ -192,25 +195,18 @@ namespace Virus
Parameter* Controller::getParameter(const ParameterType _param)
{
- const auto it = m_paramTypeToParamIndex.find(_param);
- if (it == m_paramTypeToParamIndex.end())
- return nullptr;
-
- const auto& index = it->second;
-
- return findSynthParam(index);
+ return getParameter(_param, 0);
}
Parameter *Controller::getParameter(const ParameterType _param, const uint8_t _part)
{
- const auto it = m_paramTypeToParamIndex.find(_param);
- if (it == m_paramTypeToParamIndex.end())
+ if (_part >= m_paramsByParamType.size())
return nullptr;
- const auto &index = it->second;
+ if (_param >= m_paramsByParamType[_part].size())
+ return nullptr;
- const ParamIndex paramIndex{index.page, _part, index.paramNum};
- return findSynthParam(paramIndex);
+ return m_paramsByParamType[_part][_param];
}
void Controller::parseParamChange(const SysEx &msg)
diff --git a/source/jucePlugin/VirusController.h b/source/jucePlugin/VirusController.h
@@ -106,7 +106,7 @@ namespace Virus
std::map<ParamIndex, std::unique_ptr<Parameter>> m_synthInternalParams;
std::map<ParamIndex, Parameter *> m_synthParams; // exposed and managed by audio processor
- std::map<ParameterType, ParamIndex> m_paramTypeToParamIndex;
+ std::array<std::vector<Parameter*>, 16> m_paramsByParamType;
void registerParams();
// tries to find synth param in both internal and host.
diff --git a/source/jucePlugin/VirusParameterBinding.cpp b/source/jucePlugin/VirusParameterBinding.cpp
@@ -83,14 +83,3 @@ void VirusParameterBinding::bind(juce::DrawableButton &_btn, Virus::ParameterTyp
}
_btn.getToggleStateValue().referTo(v->getValueObject());
}
-
-void VirusParameterBinding::bind(juce::Component &_btn, Virus::ParameterType _param)
-{
- const auto v = m_processor.getController().getParameter(_param, m_processor.getController().getCurrentPart());
- if (!v)
- {
- assert(false && "Failed to find parameter");
- return;
- }
-
-}
diff --git a/source/jucePlugin/VirusParameterBinding.h b/source/jucePlugin/VirusParameterBinding.h
@@ -35,7 +35,6 @@ public:
void bind(juce::ComboBox &_control, Virus::ParameterType _param);
void bind(juce::ComboBox &_control, Virus::ParameterType _param, uint8_t _part);
void bind(juce::DrawableButton &_control, Virus::ParameterType _param);
- void bind(juce::Component &_control, Virus::ParameterType _param);
AudioPluginAudioProcessor& m_processor;
juce::Array<Virus::Parameter*> m_bindings;