Hey, thanks for reply.
But I had already set range in createAndAddParameter, but it doesn’t work. I had something like that:
NormalisableRange<float> _A0_Range(-1.0f, 1.0f, 0.01f);
tree.createAndAddParameter(A0_ID, A0_NAME, A0_NAME, _A0_Range, 0.5f, nullptr, nullptr);
As I made my investigation I think my issue has something to do with those nullptr, nullptr
Actually I already solved the problem by modify code that sis described here: Getting Automation labeling/scaling to work with an AudioProcessorValueTreeState
and it works, but as I told, I modified that code so I am not sure if it’s proper way to do that. My solution looks like that:
` std::function<String (float)> valueToTextFunction = {};
if(!valueToTextFunction)
valueToTextFunction = [](float value){ return (String)value; };
NormalisableRange<float> _A0_Range(-1.0f, 1.0f, 0.01f);
tree.createAndAddParameter(A0_ID, A0_NAME, A0_NAME, _A0_Range, 0.5f, valueToTextFunction, nullptr);`
But as you can see I still have one nullptr
at the end. I am not sure if it’s OK?
For that second nullptr
I tried to do something like that:
std::function<float (String)> textToValueFunction = {};
if(!textToValueFunction)
textToValueFunction = [](String str)
{
float result;
std::stringstream convert(str);
if ( !(convert >> result) )
result = 0;
return result;
};
NormalisableRange<float> _A0_Range(-1.0f, 1.0f, 0.01f);
tree.createAndAddParameter(A0_ID, A0_NAME, A0_NAME, _A0_Range, 0.5f, valueToTextFunction, textToValueFunction);`
But it doesn’t work. I get some error with std::stringstream convert(str);
Error looks like that: Implicit instantiation of undefined template ‘std::__1::basic_stringstream<char, std::__1::char_traits, std::__1::allocator >’
As you probably can see I am not even sure how to use std::function, and how to convert String to float. I tried too find some tutorials to learn that, but no one helped me to understand. Maybe you have some good website where I can find some simply explanation for simply c++ guy like me ?