mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-09 23:34:20 +00:00
AudioProcessorParameter: Move impl to dedicated file
This commit is contained in:
parent
90b948dffd
commit
1623b63889
25 changed files with 235 additions and 135 deletions
|
|
@ -184,6 +184,7 @@ private:
|
|||
#include "format/juce_AudioPluginFormat.cpp"
|
||||
#include "format/juce_AudioPluginFormatManager.cpp"
|
||||
#include "format_types/juce_LegacyAudioParameter.cpp"
|
||||
#include "processors/juce_AudioProcessorParameter.cpp"
|
||||
#include "processors/juce_AudioProcessor.cpp"
|
||||
#include "processors/juce_AudioPluginInstance.cpp"
|
||||
#include "processors/juce_AudioProcessorEditor.cpp"
|
||||
|
|
|
|||
|
|
@ -1429,139 +1429,4 @@ JUCE_END_IGNORE_DEPRECATION_WARNINGS
|
|||
void AudioProcessorListener::audioProcessorParameterChangeGestureBegin (AudioProcessor*, int) {}
|
||||
void AudioProcessorListener::audioProcessorParameterChangeGestureEnd (AudioProcessor*, int) {}
|
||||
|
||||
//==============================================================================
|
||||
AudioProcessorParameter::~AudioProcessorParameter()
|
||||
{
|
||||
#if JUCE_DEBUG && ! JUCE_DISABLE_AUDIOPROCESSOR_BEGIN_END_GESTURE_CHECKING
|
||||
// This will fail if you've called beginChangeGesture() without having made
|
||||
// a corresponding call to endChangeGesture...
|
||||
jassert (! isPerformingGesture);
|
||||
#endif
|
||||
}
|
||||
|
||||
void AudioProcessorParameter::setValueNotifyingHost (float newValue)
|
||||
{
|
||||
setValue (newValue);
|
||||
sendValueChangedMessageToListeners (newValue);
|
||||
}
|
||||
|
||||
void AudioProcessorParameter::beginChangeGesture()
|
||||
{
|
||||
// This method can't be used until the parameter has been attached to a processor!
|
||||
jassert (processor != nullptr && parameterIndex >= 0);
|
||||
|
||||
#if JUCE_DEBUG && ! JUCE_DISABLE_AUDIOPROCESSOR_BEGIN_END_GESTURE_CHECKING
|
||||
// This means you've called beginChangeGesture twice in succession without
|
||||
// a matching call to endChangeGesture. That might be fine in most hosts,
|
||||
// but it would be better to avoid doing it.
|
||||
jassert (! isPerformingGesture);
|
||||
isPerformingGesture = true;
|
||||
#endif
|
||||
|
||||
ScopedLock lock (listenerLock);
|
||||
|
||||
for (int i = listeners.size(); --i >= 0;)
|
||||
if (auto* l = listeners[i])
|
||||
l->parameterGestureChanged (getParameterIndex(), true);
|
||||
|
||||
if (processor != nullptr && parameterIndex >= 0)
|
||||
{
|
||||
// audioProcessorParameterChangeGestureBegin callbacks will shortly be deprecated and
|
||||
// this code will be removed.
|
||||
for (int i = processor->listeners.size(); --i >= 0;)
|
||||
if (auto* l = processor->listeners[i])
|
||||
l->audioProcessorParameterChangeGestureBegin (processor, getParameterIndex());
|
||||
}
|
||||
}
|
||||
|
||||
void AudioProcessorParameter::endChangeGesture()
|
||||
{
|
||||
// This method can't be used until the parameter has been attached to a processor!
|
||||
jassert (processor != nullptr && parameterIndex >= 0);
|
||||
|
||||
#if JUCE_DEBUG && ! JUCE_DISABLE_AUDIOPROCESSOR_BEGIN_END_GESTURE_CHECKING
|
||||
// This means you've called endChangeGesture without having previously
|
||||
// called beginChangeGesture. That might be fine in most hosts, but it
|
||||
// would be better to keep the calls matched correctly.
|
||||
jassert (isPerformingGesture);
|
||||
isPerformingGesture = false;
|
||||
#endif
|
||||
|
||||
ScopedLock lock (listenerLock);
|
||||
|
||||
for (int i = listeners.size(); --i >= 0;)
|
||||
if (auto* l = listeners[i])
|
||||
l->parameterGestureChanged (getParameterIndex(), false);
|
||||
|
||||
if (processor != nullptr && parameterIndex >= 0)
|
||||
{
|
||||
// audioProcessorParameterChangeGestureEnd callbacks will shortly be deprecated and
|
||||
// this code will be removed.
|
||||
for (int i = processor->listeners.size(); --i >= 0;)
|
||||
if (auto* l = processor->listeners[i])
|
||||
l->audioProcessorParameterChangeGestureEnd (processor, getParameterIndex());
|
||||
}
|
||||
}
|
||||
|
||||
void AudioProcessorParameter::sendValueChangedMessageToListeners (float newValue)
|
||||
{
|
||||
ScopedLock lock (listenerLock);
|
||||
|
||||
for (int i = listeners.size(); --i >= 0;)
|
||||
if (auto* l = listeners [i])
|
||||
l->parameterValueChanged (getParameterIndex(), newValue);
|
||||
|
||||
if (processor != nullptr && parameterIndex >= 0)
|
||||
{
|
||||
// audioProcessorParameterChanged callbacks will shortly be deprecated and
|
||||
// this code will be removed.
|
||||
for (int i = processor->listeners.size(); --i >= 0;)
|
||||
if (auto* l = processor->listeners[i])
|
||||
l->audioProcessorParameterChanged (processor, getParameterIndex(), newValue);
|
||||
}
|
||||
}
|
||||
|
||||
bool AudioProcessorParameter::isOrientationInverted() const { return false; }
|
||||
bool AudioProcessorParameter::isAutomatable() const { return true; }
|
||||
bool AudioProcessorParameter::isMetaParameter() const { return false; }
|
||||
AudioProcessorParameter::Category AudioProcessorParameter::getCategory() const { return genericParameter; }
|
||||
int AudioProcessorParameter::getNumSteps() const { return AudioProcessor::getDefaultNumParameterSteps(); }
|
||||
bool AudioProcessorParameter::isDiscrete() const { return false; }
|
||||
bool AudioProcessorParameter::isBoolean() const { return false; }
|
||||
|
||||
String AudioProcessorParameter::getText (float value, int /*maximumStringLength*/) const
|
||||
{
|
||||
return String (value, 2);
|
||||
}
|
||||
|
||||
String AudioProcessorParameter::getCurrentValueAsText() const
|
||||
{
|
||||
return getText (getValue(), 1024);
|
||||
}
|
||||
|
||||
StringArray AudioProcessorParameter::getAllValueStrings() const
|
||||
{
|
||||
if (isDiscrete() && valueStrings.isEmpty())
|
||||
{
|
||||
auto maxIndex = getNumSteps() - 1;
|
||||
|
||||
for (int i = 0; i < getNumSteps(); ++i)
|
||||
valueStrings.add (getText ((float) i / (float) maxIndex, 1024));
|
||||
}
|
||||
|
||||
return valueStrings;
|
||||
}
|
||||
|
||||
void AudioProcessorParameter::addListener (AudioProcessorParameter::Listener* newListener)
|
||||
{
|
||||
const ScopedLock sl (listenerLock);
|
||||
listeners.addIfNotAlreadyThere (newListener);
|
||||
}
|
||||
|
||||
void AudioProcessorParameter::removeListener (AudioProcessorParameter::Listener* listenerToRemove)
|
||||
{
|
||||
const ScopedLock sl (listenerLock);
|
||||
listeners.removeFirstMatchingValue (listenerToRemove);
|
||||
}
|
||||
|
||||
} // namespace juce
|
||||
|
|
|
|||
|
|
@ -0,0 +1,172 @@
|
|||
/*
|
||||
==============================================================================
|
||||
|
||||
This file is part of the JUCE framework.
|
||||
Copyright (c) Raw Material Software Limited
|
||||
|
||||
JUCE is an open source framework subject to commercial or open source
|
||||
licensing.
|
||||
|
||||
By downloading, installing, or using the JUCE framework, or combining the
|
||||
JUCE framework with any other source code, object code, content or any other
|
||||
copyrightable work, you agree to the terms of the JUCE End User Licence
|
||||
Agreement, and all incorporated terms including the JUCE Privacy Policy and
|
||||
the JUCE Website Terms of Service, as applicable, which will bind you. If you
|
||||
do not agree to the terms of these agreements, we will not license the JUCE
|
||||
framework to you, and you must discontinue the installation or download
|
||||
process and cease use of the JUCE framework.
|
||||
|
||||
JUCE End User Licence Agreement: https://juce.com/legal/juce-8-licence/
|
||||
JUCE Privacy Policy: https://juce.com/juce-privacy-policy
|
||||
JUCE Website Terms of Service: https://juce.com/juce-website-terms-of-service/
|
||||
|
||||
Or:
|
||||
|
||||
You may also use this code under the terms of the AGPLv3:
|
||||
https://www.gnu.org/licenses/agpl-3.0.en.html
|
||||
|
||||
THE JUCE FRAMEWORK IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL
|
||||
WARRANTIES, WHETHER EXPRESSED OR IMPLIED, INCLUDING WARRANTY OF
|
||||
MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ARE DISCLAIMED.
|
||||
|
||||
==============================================================================
|
||||
*/
|
||||
|
||||
namespace juce
|
||||
{
|
||||
|
||||
AudioProcessorParameter::~AudioProcessorParameter()
|
||||
{
|
||||
#if JUCE_DEBUG && ! JUCE_DISABLE_AUDIOPROCESSOR_BEGIN_END_GESTURE_CHECKING
|
||||
// This will fail if you've called beginChangeGesture() without having made
|
||||
// a corresponding call to endChangeGesture...
|
||||
jassert (! isPerformingGesture);
|
||||
#endif
|
||||
}
|
||||
|
||||
void AudioProcessorParameter::setValueNotifyingHost (float newValue)
|
||||
{
|
||||
setValue (newValue);
|
||||
sendValueChangedMessageToListeners (newValue);
|
||||
}
|
||||
|
||||
void AudioProcessorParameter::beginChangeGesture()
|
||||
{
|
||||
// This method can't be used until the parameter has been attached to a processor!
|
||||
jassert (processor != nullptr && parameterIndex >= 0);
|
||||
|
||||
#if JUCE_DEBUG && ! JUCE_DISABLE_AUDIOPROCESSOR_BEGIN_END_GESTURE_CHECKING
|
||||
// This means you've called beginChangeGesture twice in succession without
|
||||
// a matching call to endChangeGesture. That might be fine in most hosts,
|
||||
// but it would be better to avoid doing it.
|
||||
jassert (! isPerformingGesture);
|
||||
isPerformingGesture = true;
|
||||
#endif
|
||||
|
||||
ScopedLock lock (listenerLock);
|
||||
|
||||
for (int i = listeners.size(); --i >= 0;)
|
||||
if (auto* l = listeners[i])
|
||||
l->parameterGestureChanged (getParameterIndex(), true);
|
||||
|
||||
if (processor != nullptr && parameterIndex >= 0)
|
||||
{
|
||||
// audioProcessorParameterChangeGestureBegin callbacks will shortly be deprecated and
|
||||
// this code will be removed.
|
||||
for (int i = processor->listeners.size(); --i >= 0;)
|
||||
if (auto* l = processor->listeners[i])
|
||||
l->audioProcessorParameterChangeGestureBegin (processor, getParameterIndex());
|
||||
}
|
||||
}
|
||||
|
||||
void AudioProcessorParameter::endChangeGesture()
|
||||
{
|
||||
// This method can't be used until the parameter has been attached to a processor!
|
||||
jassert (processor != nullptr && parameterIndex >= 0);
|
||||
|
||||
#if JUCE_DEBUG && ! JUCE_DISABLE_AUDIOPROCESSOR_BEGIN_END_GESTURE_CHECKING
|
||||
// This means you've called endChangeGesture without having previously
|
||||
// called beginChangeGesture. That might be fine in most hosts, but it
|
||||
// would be better to keep the calls matched correctly.
|
||||
jassert (isPerformingGesture);
|
||||
isPerformingGesture = false;
|
||||
#endif
|
||||
|
||||
ScopedLock lock (listenerLock);
|
||||
|
||||
for (int i = listeners.size(); --i >= 0;)
|
||||
if (auto* l = listeners[i])
|
||||
l->parameterGestureChanged (getParameterIndex(), false);
|
||||
|
||||
if (processor != nullptr && parameterIndex >= 0)
|
||||
{
|
||||
// audioProcessorParameterChangeGestureEnd callbacks will shortly be deprecated and
|
||||
// this code will be removed.
|
||||
for (int i = processor->listeners.size(); --i >= 0;)
|
||||
if (auto* l = processor->listeners[i])
|
||||
l->audioProcessorParameterChangeGestureEnd (processor, getParameterIndex());
|
||||
}
|
||||
}
|
||||
|
||||
void AudioProcessorParameter::sendValueChangedMessageToListeners (float newValue)
|
||||
{
|
||||
ScopedLock lock (listenerLock);
|
||||
|
||||
for (int i = listeners.size(); --i >= 0;)
|
||||
if (auto* l = listeners [i])
|
||||
l->parameterValueChanged (getParameterIndex(), newValue);
|
||||
|
||||
if (processor != nullptr && parameterIndex >= 0)
|
||||
{
|
||||
// audioProcessorParameterChanged callbacks will shortly be deprecated and
|
||||
// this code will be removed.
|
||||
for (int i = processor->listeners.size(); --i >= 0;)
|
||||
if (auto* l = processor->listeners[i])
|
||||
l->audioProcessorParameterChanged (processor, getParameterIndex(), newValue);
|
||||
}
|
||||
}
|
||||
|
||||
bool AudioProcessorParameter::isOrientationInverted() const { return false; }
|
||||
bool AudioProcessorParameter::isAutomatable() const { return true; }
|
||||
bool AudioProcessorParameter::isMetaParameter() const { return false; }
|
||||
AudioProcessorParameter::Category AudioProcessorParameter::getCategory() const { return genericParameter; }
|
||||
int AudioProcessorParameter::getNumSteps() const { return AudioProcessor::getDefaultNumParameterSteps(); }
|
||||
bool AudioProcessorParameter::isDiscrete() const { return false; }
|
||||
bool AudioProcessorParameter::isBoolean() const { return false; }
|
||||
|
||||
String AudioProcessorParameter::getText (float value, int /*maximumStringLength*/) const
|
||||
{
|
||||
return String (value, 2);
|
||||
}
|
||||
|
||||
String AudioProcessorParameter::getCurrentValueAsText() const
|
||||
{
|
||||
return getText (getValue(), 1024);
|
||||
}
|
||||
|
||||
StringArray AudioProcessorParameter::getAllValueStrings() const
|
||||
{
|
||||
if (isDiscrete() && valueStrings.isEmpty())
|
||||
{
|
||||
auto maxIndex = getNumSteps() - 1;
|
||||
|
||||
for (int i = 0; i < getNumSteps(); ++i)
|
||||
valueStrings.add (getText ((float) i / (float) maxIndex, 1024));
|
||||
}
|
||||
|
||||
return valueStrings;
|
||||
}
|
||||
|
||||
void AudioProcessorParameter::addListener (AudioProcessorParameter::Listener* newListener)
|
||||
{
|
||||
const ScopedLock sl (listenerLock);
|
||||
listeners.addIfNotAlreadyThere (newListener);
|
||||
}
|
||||
|
||||
void AudioProcessorParameter::removeListener (AudioProcessorParameter::Listener* listenerToRemove)
|
||||
{
|
||||
const ScopedLock sl (listenerLock);
|
||||
listeners.removeFirstMatchingValue (listenerToRemove);
|
||||
}
|
||||
|
||||
} // namespace juce
|
||||
Loading…
Add table
Add a link
Reference in a new issue