mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +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;
|
processor = &audioProcessorToUse;
|
||||||
|
|
||||||
parameterIndex = audioParameterIndex;
|
setParameterIndex (audioParameterIndex);
|
||||||
jassert (parameterIndex < processor->getNumParameters());
|
jassert (getParameterIndex() < processor->getNumParameters());
|
||||||
}
|
}
|
||||||
|
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
float getValue() const override { return processor->getParameter (parameterIndex); }
|
float getValue() const override { return processor->getParameter (getParameterIndex()); }
|
||||||
void setValue (float newValue) override { processor->setParameter (parameterIndex, newValue); }
|
void setValue (float newValue) override { processor->setParameter (getParameterIndex(), newValue); }
|
||||||
float getDefaultValue() const override { return processor->getParameterDefaultValue (parameterIndex); }
|
float getDefaultValue() const override { return processor->getParameterDefaultValue (getParameterIndex()); }
|
||||||
String getName (int maxLen) const override { return processor->getParameterName (parameterIndex, maxLen); }
|
String getName (int maxLen) const override { return processor->getParameterName (getParameterIndex(), maxLen); }
|
||||||
String getLabel() const override { return processor->getParameterLabel (parameterIndex); }
|
String getLabel() const override { return processor->getParameterLabel (getParameterIndex()); }
|
||||||
int getNumSteps() const override { return processor->getParameterNumSteps (parameterIndex); }
|
int getNumSteps() const override { return processor->getParameterNumSteps (getParameterIndex()); }
|
||||||
bool isDiscrete() const override { return processor->isParameterDiscrete (parameterIndex); }
|
bool isDiscrete() const override { return processor->isParameterDiscrete (getParameterIndex()); }
|
||||||
bool isBoolean() const override { return false; }
|
bool isBoolean() const override { return false; }
|
||||||
bool isOrientationInverted() const override { return processor->isParameterOrientationInverted (parameterIndex); }
|
bool isOrientationInverted() const override { return processor->isParameterOrientationInverted (getParameterIndex()); }
|
||||||
bool isAutomatable() const override { return processor->isParameterAutomatable (parameterIndex); }
|
bool isAutomatable() const override { return processor->isParameterAutomatable (getParameterIndex()); }
|
||||||
bool isMetaParameter() const override { return processor->isMetaParameter (parameterIndex); }
|
bool isMetaParameter() const override { return processor->isMetaParameter (getParameterIndex()); }
|
||||||
Category getCategory() const override { return processor->getParameterCategory (parameterIndex); }
|
Category getCategory() const override { return processor->getParameterCategory (getParameterIndex()); }
|
||||||
String getCurrentValueAsText() const override { return processor->getParameterText (parameterIndex); }
|
String getCurrentValueAsText() const override { return processor->getParameterText (getParameterIndex()); }
|
||||||
String getParameterID() const override { return processor->getParameterID (parameterIndex); }
|
String getParameterID() const override { return processor->getParameterID (getParameterIndex()); }
|
||||||
|
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
float getValueForText (const String&) const override
|
float getValueForText (const String&) const override
|
||||||
|
|
@ -85,22 +85,18 @@ public:
|
||||||
return (dynamic_cast<LegacyAudioParameter*> (param) != nullptr);
|
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))
|
if (auto* legacy = dynamic_cast<LegacyAudioParameter*> (param))
|
||||||
{
|
return legacy->getParameterIndex();
|
||||||
return legacy->parameterIndex;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
auto n = processor.getNumParameters();
|
|
||||||
jassert (n == processor.getParameters().size());
|
|
||||||
|
|
||||||
for (int i = 0; i < n; ++i)
|
auto n = proc.getNumParameters();
|
||||||
{
|
jassert (n == proc.getParameters().size());
|
||||||
if (processor.getParameters()[i] == param)
|
|
||||||
return i;
|
for (int i = 0; i < n; ++i)
|
||||||
}
|
{
|
||||||
|
if (proc.getParameters()[i] == param)
|
||||||
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
|
|
@ -109,7 +105,7 @@ public:
|
||||||
static String getParamID (const AudioProcessorParameter* param, bool forceLegacyParamIDs) noexcept
|
static String getParamID (const AudioProcessorParameter* param, bool forceLegacyParamIDs) noexcept
|
||||||
{
|
{
|
||||||
if (auto* legacy = dynamic_cast<const LegacyAudioParameter*> (param))
|
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))
|
if (auto* paramWithID = dynamic_cast<const HostedAudioProcessorParameter*> (param))
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -522,7 +522,7 @@ void AudioProcessor::addParameter (AudioProcessorParameter* param)
|
||||||
parameterTree.addChild (std::unique_ptr<AudioProcessorParameter> (param));
|
parameterTree.addChild (std::unique_ptr<AudioProcessorParameter> (param));
|
||||||
|
|
||||||
param->processor = this;
|
param->processor = this;
|
||||||
param->parameterIndex = flatParameterList.size();
|
param->setParameterIndex (flatParameterList.size());
|
||||||
flatParameterList.add (param);
|
flatParameterList.add (param);
|
||||||
|
|
||||||
validateParameter (param);
|
validateParameter (param);
|
||||||
|
|
@ -540,7 +540,7 @@ void AudioProcessor::addParameterGroup (std::unique_ptr<AudioProcessorParameterG
|
||||||
{
|
{
|
||||||
auto p = flatParameterList.getUnchecked (i);
|
auto p = flatParameterList.getUnchecked (i);
|
||||||
p->processor = this;
|
p->processor = this;
|
||||||
p->parameterIndex = i;
|
p->setParameterIndex (i);
|
||||||
|
|
||||||
validateParameter (p);
|
validateParameter (p);
|
||||||
}
|
}
|
||||||
|
|
@ -567,7 +567,7 @@ void AudioProcessor::setParameterTree (AudioProcessorParameterGroup&& newTree)
|
||||||
{
|
{
|
||||||
auto p = flatParameterList.getUnchecked (i);
|
auto p = flatParameterList.getUnchecked (i);
|
||||||
p->processor = this;
|
p->processor = this;
|
||||||
p->parameterIndex = i;
|
p->setParameterIndex (i);
|
||||||
|
|
||||||
validateParameter (p);
|
validateParameter (p);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,12 @@ AudioProcessorParameter::~AudioProcessorParameter()
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AudioProcessorParameter::setParameterIndex (int index) noexcept
|
||||||
|
{
|
||||||
|
jassert (parameterIndex < 0 && 0 <= index);
|
||||||
|
parameterIndex = index;
|
||||||
|
}
|
||||||
|
|
||||||
void AudioProcessorParameter::setValueNotifyingHost (float newValue)
|
void AudioProcessorParameter::setValueNotifyingHost (float newValue)
|
||||||
{
|
{
|
||||||
setValue (newValue);
|
setValue (newValue);
|
||||||
|
|
|
||||||
|
|
@ -262,6 +262,12 @@ public:
|
||||||
/** Returns the index of this parameter in its parent processor's parameter list. */
|
/** Returns the index of this parameter in its parent processor's parameter list. */
|
||||||
int getParameterIndex() const noexcept { return parameterIndex; }
|
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.
|
/** Returns the current value of the parameter as a String.
|
||||||
|
|
||||||
|
|
@ -349,11 +355,11 @@ public:
|
||||||
/** @internal */
|
/** @internal */
|
||||||
void sendValueChangedMessageToListeners (float newValue);
|
void sendValueChangedMessageToListeners (float newValue);
|
||||||
|
|
||||||
|
/** @internal */
|
||||||
|
AudioProcessor* processor = nullptr;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
friend class AudioProcessor;
|
|
||||||
friend class LegacyAudioParameter;
|
|
||||||
AudioProcessor* processor = nullptr;
|
|
||||||
int parameterIndex = -1;
|
int parameterIndex = -1;
|
||||||
int version = 0;
|
int version = 0;
|
||||||
CriticalSection listenerLock;
|
CriticalSection listenerLock;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue