Hi !
In my void Processor::parameterChanged(const juce::String& parameterId, float newValue) callback I want to create a juce::Identifier to speed up the comparison to find the right parameter to update (if (id == “drive”) {})
I create the Identifier with juce::Identifier id(parameterId) but I get this compile error with MSVC 19.32 :
2>D:\Dev\AmpModeler\libs\juce\modules\juce_audio_processors\utilities/juce_AudioProcessorParameterWithID.h(51,9): error C2668: ‘juce::String::String’: ambiguous call to overloaded function
2>D:\Dev\AmpModeler\libs\juce\modules\juce_core\text/juce_String.h(148,5): message : could be ‘juce::String::String(juce::StringRef)’
2>D:\Dev\AmpModeler\libs\juce\modules\juce_core\text/juce_String.h(112,5): message : or ‘juce::String::String(juce::CharPointer_UTF8)’
2>D:\Dev\AmpModeler\libs\juce\modules\juce_audio_processors\utilities/juce_AudioProcessorParameterWithID.h(51,9): message : while trying to match the argument list ‘(const _Ty)’
I have tried to explicitly cast to different types and even to char* but I always get that same error even thought I do give a juce::String as argument. How can I make sure that the constructor will not try to implicitly cast to somethign I don’t want or is there a better way to check and update my parameters ?
Thanks in advance
You can’t compare a juce::Identifier
to char*
- see JUCE: Identifier Class Reference. You can only compare against another juce::Identifier
or a juce::StringRef
.
Easiest would be to replace
if (id == “drive”)
with
if (id == juce::Identifier{ "drive" })
Thanks for your reply.
Yes I want to compare to a juce::Identifier, all my parametes identifiers are stored in a std::vectorjuce::Identifier.
My problem is at the creation of the Identifier from the juce::String& parameterId at the beginning of the parameterChanged() function.
I will try what you proposed
I have just compiled the following code successfully on my macOS (Xcode 15.3, CMake).
void PluginProcessor::parameterChanged(const juce::String ¶meterID, float newValue) {
const auto id1 = juce::Identifier(parameterID);
const auto id_gain1 = juce::Identifier("gain1");
if (id1 == id_gain1) {
gain1.setGainDecibels(newValue); // a real-time safe gain dsp
}
}
However, I am not sure whether it will speed up the comparison.
Thanks ! I’ll try that.
The tutorial on the ValueTree says it is supposed to speed up as it is not a full string comparison. Identifier are stored in a way that, if you create a new one with an already existing ID, it will point to that already allocated memory. With that, the implementation of the comparison is just checking whether the two juce::Identifiers are pointing to the same adress.
It did the job, thanks a lot !