Automation range other than slider


I just created Slider with range of:
Slider::setRange(-1.0f, 1.0f, 0.01f);
and make attachment to value tree state.
But in Logic Pro X, when I want to automate that slider I see the range from 0.0 to 1.0.
For example:
if I want to automate my slider to value -0.5, I need to set automation in Logic to 0.25. You know what I mean? It’s annoying.
Don’t you know how to make automation range corresponding to real values of slider?
Thanks for any help.



the Slider can use the range from the parameter, but not the other way round, since there might not be a slider, when the processor is already communicating with the host.
Use the range in createAndAddParameter, if you use the AudioProcessorValueTreeState. The SliderAttachment will then propagate the range to the slider, when you attach one.

Note also, that it would be a bad idea to change the range of a parameter, since it would screw up all automations stored in the host (since the plugin has no notion of time and what value a parameter has at a certain point in time, it is purely remote controlled by the host).



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 = {};

    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 = {};

    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 ? :slight_smile:


IIRC the nullptr just uses the default methods to convert a float to text and vice versa, I think it drops characters after the number.
I.e. text.getFloatValue() and String (value)

This is an example I am using, evolved from other suggestions here on the forum:

state.createAndAddParameter ("freq", "frequency", "Frequency",
                             NormalisableRange<float> (20.0, 20000.0, 1.0),
                             [](float value) { return (value < 1000) ?
                                 String (value, 0) + " Hz" :
                                 String (value / 1000.0, 2) + " kHz"; },
                             [](String text) { return text.endsWith(" kHz") ?
                                 text.dropLastCharacters (4).getFloatValue() * 1000.0 :
                                 text.dropLastCharacters (3).getFloatValue(); },
                             false, true, false);