Permalink
Browse files

Allowed an AudioProcessorValueTreeState to manage RangedAudioParamete…

…r subclasses
  • Loading branch information...
reuk authored and tpoole committed Oct 12, 2018
1 parent 768139a commit 1f63493031e1e42d3986fba722d125466cb55fec
@@ -4,6 +4,39 @@ JUCE breaking changes
Develop
=======

Change
------
The AudioProcessorValueTreeState::createAndAddParameter function has been
deprecated.

Possible Issues
---------------
Deprecation warnings will be seen when compiling code which uses this function
and eventually builds will fail when it is later removed from the API.

Workaround
----------
Previous calls to

createAndAddParameter (paramID, paramName, ...);

can be directly replaced with

using Parameter = AudioProcessorValueTreeState::Parameter;
createAndAddParameter (std::make_unique<Parameter> (paramID, paramName, ...));

but an even better approach is to use the new AudioProcessorValueTreeState
constructor where you can pass both RangedAudioParameters and
AudioProcessorParameterGroups of RangedAudioParameters to the
AudioProcessorValueTreeState and initialise the ValueTree simultaneously.

Rationale
---------
The new createAndAddParameter method is much more flexible and enables any
parameter types derived from RangedAudioParameter to be managed by the
AudioProcessorValueTreeState.


Change
------
The Projucer's per-exporter Android SDK/NDK path options have been removed.
@@ -15,7 +48,7 @@ Projects that previously used these fields may no longer build.
Workaround
----------
Use the Projucer's global paths settings to point to these directories, either
by opening the "Projucer/File->Global Paths..." menu item or using the
by opening the "Projucer/File->Global Paths..." menu item or using the
"--set-global-search-path" command-line option.

Rationale
@@ -175,19 +175,14 @@ class JuceDemoPluginAudioProcessor : public AudioProcessor
//==============================================================================
JuceDemoPluginAudioProcessor()
: AudioProcessor (getBusesProperties()),
state (*this, nullptr)
state (*this, nullptr, "state",
{ std::make_unique<AudioParameterFloat> ("gain", "Gain", NormalisableRange<float> (0.0f, 1.0f), 0.9f),
std::make_unique<AudioParameterFloat> ("delay", "Delay Feedback", NormalisableRange<float> (0.0f, 1.0f), 0.5f) })
{
lastPosInfo.resetToDefault();

// This creates our parameters
state.createAndAddParameter ("gain", "Gain", {}, {}, 0.9f, {}, {});
state.createAndAddParameter ("delay", "Delay Feedback", {}, {}, 0.5f, {}, {});

state.state = ValueTree ("state", {},
{
// add a sub-tree to store the state of our UI
{"uiState", {{"width", 400}, {"height", 200}}, {}}
});
// Add a sub-tree to store the state of our UI
state.state.addChild ({ "uiState", { { "width", 400 }, { "height", 200 } }, {} }, -1, nullptr);

initialiseSynth();
}
@@ -152,17 +152,9 @@ class IAAEffectProcessor : public AudioProcessor
: AudioProcessor (BusesProperties()
.withInput ("Input", AudioChannelSet::stereo(), true)
.withOutput ("Output", AudioChannelSet::stereo(), true)),
parameters (*this, nullptr)
parameters (*this, nullptr, "InterAppAudioEffect",
{ std::make_unique<AudioParameterFloat> ("gain", "Gain", NormalisableRange<float> (0.0f, 1.0f), 1.0f / 3.14f) })
{
parameters.createAndAddParameter ("gain",
"Gain",
{},
NormalisableRange<float> (0.0f, 1.0f),
(float) (1.0 / 3.14),
nullptr,
nullptr);

parameters.state = ValueTree (Identifier ("InterAppAudioEffect"));
}

~IAAEffectProcessor() {}
@@ -39,6 +39,8 @@
#include "juce_audio_processors.h"
#include <juce_gui_extra/juce_gui_extra.h>

#include <numeric>

//==============================================================================
#if JUCE_MAC
#if JUCE_SUPPORT_CARBON \
@@ -127,6 +127,7 @@
#include "scanning/juce_PluginDirectoryScanner.h"
#include "scanning/juce_PluginListComponent.h"
#include "utilities/juce_AudioProcessorParameterWithID.h"
#include "utilities/juce_RangedAudioParameter.h"
#include "utilities/juce_AudioParameterFloat.h"
#include "utilities/juce_AudioParameterInt.h"
#include "utilities/juce_AudioParameterBool.h"
@@ -34,7 +34,7 @@ namespace juce
@tags{Audio}
*/
class JUCE_API AudioParameterBool : public AudioProcessorParameterWithID
class JUCE_API AudioParameterBool : public RangedAudioParameter
{
public:
/** Creates a AudioParameterBool with the specified parameters.
@@ -60,12 +60,16 @@ class JUCE_API AudioParameterBool : public AudioProcessorParameterWithID

/** Returns the parameter's current boolean value. */
bool get() const noexcept { return value >= 0.5f; }

/** Returns the parameter's current boolean value. */
operator bool() const noexcept { return get(); }

/** Changes the parameter's current value to a new boolean. */
AudioParameterBool& operator= (bool newValue);

/** Returns the range of values that the parameter can take. */
const NormalisableRange<float>& getNormalisableRange() const override { return range; }

protected:
/** Override this method if you are interested in receiving callbacks
when the parameter value changes.
@@ -83,6 +87,7 @@ class JUCE_API AudioParameterBool : public AudioProcessorParameterWithID
String getText (float, int) const override;
float getValueForText (const String&) const override;

const NormalisableRange<float> range { 0.0f, 1.0f, 1.0f };
float value;
const float defaultValue;
std::function<String (bool, int)> stringFromBoolFunction;
@@ -35,7 +35,7 @@ namespace juce
@tags{Audio}
*/
class JUCE_API AudioParameterChoice : public AudioProcessorParameterWithID
class JUCE_API AudioParameterChoice : public RangedAudioParameter
{
public:
/** Creates a AudioParameterChoice with the specified parameters.
@@ -64,17 +64,22 @@ class JUCE_API AudioParameterChoice : public AudioProcessorParameterWithID

/** Returns the current index of the selected item. */
int getIndex() const noexcept { return roundToInt (value); }

/** Returns the current index of the selected item. */
operator int() const noexcept { return getIndex(); }

/** Returns the name of the currently selected item. */
String getCurrentChoiceName() const noexcept { return choices[getIndex()]; }

/** Returns the name of the currently selected item. */
operator String() const noexcept { return getCurrentChoiceName(); }

/** Changes the selected item to a new index. */
AudioParameterChoice& operator= (int newValue);

/** Returns the range of values that the parameter can take. */
const NormalisableRange<float>& getNormalisableRange() const override { return range; }

/** Provides access to the list of choices that this parameter is working with. */
const StringArray choices;

@@ -94,12 +99,8 @@ class JUCE_API AudioParameterChoice : public AudioProcessorParameterWithID
String getText (float, int) const override;
float getValueForText (const String&) const override;

int limitRange (int) const noexcept;
float convertTo0to1 (int) const noexcept;
int convertFrom0to1 (float) const noexcept;

const NormalisableRange<float> range;
float value;
const int maxIndex;
const float defaultValue;
std::function<String (int, int)> stringFromIndexFunction;
std::function<int (const String&)> indexFromStringFunction;
@@ -35,7 +35,7 @@ namespace juce
@tags{Audio}
*/
class JUCE_API AudioParameterFloat : public AudioProcessorParameterWithID
class JUCE_API AudioParameterFloat : public RangedAudioParameter
{
public:
/** Creates a AudioParameterFloat with the specified parameters.
@@ -53,7 +53,8 @@ class JUCE_API AudioParameterFloat : public AudioProcessorParameterWithID
converts it into a non-normalised value. Some hosts use
this to allow users to type in parameter values.
*/
AudioParameterFloat (const String& parameterID, const String& name,
AudioParameterFloat (const String& parameterID,
const String& name,
NormalisableRange<float> normalisableRange,
float defaultValue,
const String& label = String(),
@@ -66,7 +67,8 @@ class JUCE_API AudioParameterFloat : public AudioProcessorParameterWithID
For control over skew factors, you can use the other
constructor and provide a NormalisableRange.
*/
AudioParameterFloat (String parameterID, String name,
AudioParameterFloat (String parameterID,
String name,
float minValue,
float maxValue,
float defaultValue);
@@ -76,12 +78,16 @@ class JUCE_API AudioParameterFloat : public AudioProcessorParameterWithID

/** Returns the parameter's current value. */
float get() const noexcept { return value; }

/** Returns the parameter's current value. */
operator float() const noexcept { return value; }

/** Changes the parameter's current value. */
AudioParameterFloat& operator= (float newValue);

/** Returns the range of values that the parameter can take. */
const NormalisableRange<float>& getNormalisableRange() const override { return range; }

/** Provides access to the parameter's range. */
NormalisableRange<float> range;

@@ -35,7 +35,7 @@ namespace juce
@tags{Audio}
*/
class JUCE_API AudioParameterInt : public AudioProcessorParameterWithID
class JUCE_API AudioParameterInt : public RangedAudioParameter
{
public:
/** Creates a AudioParameterInt with the specified parameters.
@@ -65,6 +65,7 @@ class JUCE_API AudioParameterInt : public AudioProcessorParameterWithID

/** Returns the parameter's current value as an integer. */
int get() const noexcept { return roundToInt (value); }

/** Returns the parameter's current value as an integer. */
operator int() const noexcept { return get(); }

@@ -74,7 +75,10 @@ class JUCE_API AudioParameterInt : public AudioProcessorParameterWithID
AudioParameterInt& operator= (int newValue);

/** Returns the parameter's range. */
Range<int> getRange() const noexcept { return Range<int> (minValue, maxValue); }
Range<int> getRange() const noexcept { return { (int) getNormalisableRange().start, (int) getNormalisableRange().end }; }

/** Returns the range of values that the parameter can take. */
const NormalisableRange<float>& getNormalisableRange() const override { return range; }

protected:
/** Override this method if you are interested in receiving callbacks
@@ -91,11 +95,7 @@ class JUCE_API AudioParameterInt : public AudioProcessorParameterWithID
String getText (float, int) const override;
float getValueForText (const String&) const override;

int limitRange (int) const noexcept;
float convertTo0to1 (int) const noexcept;
int convertFrom0to1 (float) const noexcept;

const int minValue, maxValue, rangeOfValues;
const NormalisableRange<float> range;
float value;
const float defaultValue;
std::function<String (int, int)> stringFromIntFunction;
@@ -37,7 +37,7 @@ namespace juce
class JUCE_API AudioProcessorParameterWithID : public AudioProcessorParameter
{
public:
/** Creation of this object requires providing a name and ID which will be
/** The creation of this object requires providing a name and ID which will be
constant for its lifetime.
*/
AudioProcessorParameterWithID (const String& parameterID,
Oops, something went wrong.

0 comments on commit 1f63493

Please sign in to comment.