Browse Source

AU Host: Ensure discrete parameters are scaled correctly

Previously, the AU hosting code always computed the number of steps in
the parameter range as though the minimum parameter value was 0.

Now, we take the parameter's reported minimum into account when
computing the number of steps. We also use the parameter's range, rather
than its step number, when normalising/denormalising the parameter
value.
tags/2021-05-28
reuk 4 years ago
parent
commit
daf8761727
2 changed files with 30 additions and 7 deletions
  1. +29
    -0
      BREAKING-CHANGES.txt
  2. +1
    -7
      modules/juce_audio_processors/format_types/juce_AudioUnitPluginFormat.mm

+ 29
- 0
BREAKING-CHANGES.txt View File

@@ -4,6 +4,35 @@ JUCE breaking changes
Develop
=======

Change
------
The implementations of `getValue` and `setValue` in `AUInstanceParameter` now
properly take the ranges of discrete parameters into account.

Possible Issues
---------------

This issue affects JUCE Audio Unit hosts. Automation data previously saved for
a discrete parameter with a non-zero minimum value may not set the parameter to
the same values as previous JUCE versions. Note that previously, `getValue` on
a hosted discrete parameter may have returned out-of-range values, and
`setValue` may have only mapped to a portion of the parameter range. As a
result, automation recorded for affected parameters was likely already behaving
unexpectedly.

Workaround
----------
There is no workaround.

Rationale
---------
The old behaviour was incorrect, and was causing issues in plugin validators
and other hosts. Hosts expect `getValue` to return a normalised parameter
value. If this function returns an out-of-range value (including Inf and NaN)
this is likely to break assumptions made by the host, leading to crashes,
corrupted project data, or other defects.


Change
------
AudioProcessorListener::audioProcessorChanged gained a new parameter describing


+ 1
- 7
modules/juce_audio_processors/format_types/juce_AudioUnitPluginFormat.mm View File

@@ -495,17 +495,11 @@ public:
float normaliseParamValue (float scaledValue) const noexcept
{
if (discrete)
return scaledValue / (getNumSteps() - 1);
return (scaledValue - minValue) / range;
}
float scaleParamValue (float normalisedValue) const noexcept
{
if (discrete)
return normalisedValue * (getNumSteps() - 1);
return minValue + (range * normalisedValue);
}
@@ -1467,7 +1461,7 @@ public:
info.defaultValue,
(info.flags & kAudioUnitParameterFlag_NonRealTime) == 0,
isDiscrete,
isDiscrete ? (int) (info.maxValue + 1.0f) : AudioProcessor::getDefaultNumParameterSteps(),
isDiscrete ? (int) (info.maxValue - info.minValue + 1.0f) : AudioProcessor::getDefaultNumParameterSteps(),
isBoolean,
label,
(info.flags & kAudioUnitParameterFlag_ValuesHaveStrings) != 0);


Loading…
Cancel
Save