Request: remove unnecessary workload in JuceAU::addParameter


#1

Please apply this patch, it checks just if the parameter is a non-legacy parameter, and than uses the modern getText() approach to retrieve the text for a step value, instead of setting the parameter for every step.
I have a plugin with thousand of parameters, and a lot of different steps, this old approach is very inefficient, because it causes a complicated coefficient calculation for every setValue(), in my case.

The comment in the source-code mentions that it can be replaced with getText() sometime in the future, but this approach works also with LegacyParameter.

        for (auto* param : juceParameters.params)
        {
            OwnedArray<const __CFString>* stringValues = nullptr;

            auto initialValue = param->getValue();

            bool isLegacy=dynamic_cast<LegacyAudioParameter*>(param) != nullptr;
            
            if (param->isDiscrete() && (! forceUseLegacyParamIDs))
            {
                const auto numSteps = param->getNumSteps();
                stringValues = new OwnedArray<const __CFString>();
                stringValues->ensureStorageAllocated (numSteps);

                const auto maxValue = getMaximumParameterValue (param);

                for (int i = 0; i < numSteps; ++i)
                {
                    auto value = (float) i / maxValue;
                    String text;
                    if (!isLegacy)
                    {
                       text=param->getText(value,100);
                    } else
                    {
                       param->setValue (value);
                       text=param->getCurrentValueAsText();
                    }
                    stringValues->add (CFStringCreateCopy (nullptr, (text.toCFString())));
                }
            }

            if (isLegacy)
            {
                param->setValue (initialValue);
            }

            parameterValueStringArrays.add (stringValues);
        }

#2

Yep, that’s a reasonable request. I’ll push something shortly.


#3

#4

Great! Thank you very much!