mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-09 23:34:20 +00:00
AudioProcessorParameter: Remove friendship with unrelated types
This commit is contained in:
parent
edd274f18e
commit
476f09f2c9
4 changed files with 43 additions and 35 deletions
|
|
@ -44,25 +44,25 @@ public:
|
|||
{
|
||||
processor = &audioProcessorToUse;
|
||||
|
||||
parameterIndex = audioParameterIndex;
|
||||
jassert (parameterIndex < processor->getNumParameters());
|
||||
setParameterIndex (audioParameterIndex);
|
||||
jassert (getParameterIndex() < processor->getNumParameters());
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
float getValue() const override { return processor->getParameter (parameterIndex); }
|
||||
void setValue (float newValue) override { processor->setParameter (parameterIndex, newValue); }
|
||||
float getDefaultValue() const override { return processor->getParameterDefaultValue (parameterIndex); }
|
||||
String getName (int maxLen) const override { return processor->getParameterName (parameterIndex, maxLen); }
|
||||
String getLabel() const override { return processor->getParameterLabel (parameterIndex); }
|
||||
int getNumSteps() const override { return processor->getParameterNumSteps (parameterIndex); }
|
||||
bool isDiscrete() const override { return processor->isParameterDiscrete (parameterIndex); }
|
||||
float getValue() const override { return processor->getParameter (getParameterIndex()); }
|
||||
void setValue (float newValue) override { processor->setParameter (getParameterIndex(), newValue); }
|
||||
float getDefaultValue() const override { return processor->getParameterDefaultValue (getParameterIndex()); }
|
||||
String getName (int maxLen) const override { return processor->getParameterName (getParameterIndex(), maxLen); }
|
||||
String getLabel() const override { return processor->getParameterLabel (getParameterIndex()); }
|
||||
int getNumSteps() const override { return processor->getParameterNumSteps (getParameterIndex()); }
|
||||
bool isDiscrete() const override { return processor->isParameterDiscrete (getParameterIndex()); }
|
||||
bool isBoolean() const override { return false; }
|
||||
bool isOrientationInverted() const override { return processor->isParameterOrientationInverted (parameterIndex); }
|
||||
bool isAutomatable() const override { return processor->isParameterAutomatable (parameterIndex); }
|
||||
bool isMetaParameter() const override { return processor->isMetaParameter (parameterIndex); }
|
||||
Category getCategory() const override { return processor->getParameterCategory (parameterIndex); }
|
||||
String getCurrentValueAsText() const override { return processor->getParameterText (parameterIndex); }
|
||||
String getParameterID() const override { return processor->getParameterID (parameterIndex); }
|
||||
bool isOrientationInverted() const override { return processor->isParameterOrientationInverted (getParameterIndex()); }
|
||||
bool isAutomatable() const override { return processor->isParameterAutomatable (getParameterIndex()); }
|
||||
bool isMetaParameter() const override { return processor->isMetaParameter (getParameterIndex()); }
|
||||
Category getCategory() const override { return processor->getParameterCategory (getParameterIndex()); }
|
||||
String getCurrentValueAsText() const override { return processor->getParameterText (getParameterIndex()); }
|
||||
String getParameterID() const override { return processor->getParameterID (getParameterIndex()); }
|
||||
|
||||
//==============================================================================
|
||||
float getValueForText (const String&) const override
|
||||
|
|
@ -85,22 +85,18 @@ public:
|
|||
return (dynamic_cast<LegacyAudioParameter*> (param) != nullptr);
|
||||
}
|
||||
|
||||
static int getParamIndex (AudioProcessor& processor, AudioProcessorParameter* param) noexcept
|
||||
static int getParamIndex (AudioProcessor& proc, AudioProcessorParameter* param) noexcept
|
||||
{
|
||||
if (auto* legacy = dynamic_cast<LegacyAudioParameter*> (param))
|
||||
{
|
||||
return legacy->parameterIndex;
|
||||
}
|
||||
else
|
||||
{
|
||||
auto n = processor.getNumParameters();
|
||||
jassert (n == processor.getParameters().size());
|
||||
return legacy->getParameterIndex();
|
||||
|
||||
for (int i = 0; i < n; ++i)
|
||||
{
|
||||
if (processor.getParameters()[i] == param)
|
||||
return i;
|
||||
}
|
||||
auto n = proc.getNumParameters();
|
||||
jassert (n == proc.getParameters().size());
|
||||
|
||||
for (int i = 0; i < n; ++i)
|
||||
{
|
||||
if (proc.getParameters()[i] == param)
|
||||
return i;
|
||||
}
|
||||
|
||||
return -1;
|
||||
|
|
@ -109,7 +105,7 @@ public:
|
|||
static String getParamID (const AudioProcessorParameter* param, bool forceLegacyParamIDs) noexcept
|
||||
{
|
||||
if (auto* legacy = dynamic_cast<const LegacyAudioParameter*> (param))
|
||||
return forceLegacyParamIDs ? String (legacy->parameterIndex) : legacy->getParameterID();
|
||||
return forceLegacyParamIDs ? String (legacy->getParameterIndex()) : legacy->getParameterID();
|
||||
|
||||
if (auto* paramWithID = dynamic_cast<const HostedAudioProcessorParameter*> (param))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -522,7 +522,7 @@ void AudioProcessor::addParameter (AudioProcessorParameter* param)
|
|||
parameterTree.addChild (std::unique_ptr<AudioProcessorParameter> (param));
|
||||
|
||||
param->processor = this;
|
||||
param->parameterIndex = flatParameterList.size();
|
||||
param->setParameterIndex (flatParameterList.size());
|
||||
flatParameterList.add (param);
|
||||
|
||||
validateParameter (param);
|
||||
|
|
@ -540,7 +540,7 @@ void AudioProcessor::addParameterGroup (std::unique_ptr<AudioProcessorParameterG
|
|||
{
|
||||
auto p = flatParameterList.getUnchecked (i);
|
||||
p->processor = this;
|
||||
p->parameterIndex = i;
|
||||
p->setParameterIndex (i);
|
||||
|
||||
validateParameter (p);
|
||||
}
|
||||
|
|
@ -567,7 +567,7 @@ void AudioProcessor::setParameterTree (AudioProcessorParameterGroup&& newTree)
|
|||
{
|
||||
auto p = flatParameterList.getUnchecked (i);
|
||||
p->processor = this;
|
||||
p->parameterIndex = i;
|
||||
p->setParameterIndex (i);
|
||||
|
||||
validateParameter (p);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,6 +44,12 @@ AudioProcessorParameter::~AudioProcessorParameter()
|
|||
#endif
|
||||
}
|
||||
|
||||
void AudioProcessorParameter::setParameterIndex (int index) noexcept
|
||||
{
|
||||
jassert (parameterIndex < 0 && 0 <= index);
|
||||
parameterIndex = index;
|
||||
}
|
||||
|
||||
void AudioProcessorParameter::setValueNotifyingHost (float newValue)
|
||||
{
|
||||
setValue (newValue);
|
||||
|
|
|
|||
|
|
@ -262,6 +262,12 @@ public:
|
|||
/** Returns the index of this parameter in its parent processor's parameter list. */
|
||||
int getParameterIndex() const noexcept { return parameterIndex; }
|
||||
|
||||
/** @internal
|
||||
This should only be called by the owner of the parameter after it has been added to
|
||||
a processor. Do not call this function; changing parameter indices *will* break things!
|
||||
*/
|
||||
void setParameterIndex (int index) noexcept;
|
||||
|
||||
//==============================================================================
|
||||
/** Returns the current value of the parameter as a String.
|
||||
|
||||
|
|
@ -349,11 +355,11 @@ public:
|
|||
/** @internal */
|
||||
void sendValueChangedMessageToListeners (float newValue);
|
||||
|
||||
/** @internal */
|
||||
AudioProcessor* processor = nullptr;
|
||||
|
||||
private:
|
||||
//==============================================================================
|
||||
friend class AudioProcessor;
|
||||
friend class LegacyAudioParameter;
|
||||
AudioProcessor* processor = nullptr;
|
||||
int parameterIndex = -1;
|
||||
int version = 0;
|
||||
CriticalSection listenerLock;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue