Hello,
i would like to store a Color value in an AudioParameterInt.
The range of color is [0x80000000, 0x7FFFFFFF] = [ -2147483648 , 2147483647]
on 32 bits.
It fails to work. I guess the AudioParameterInt is coded on less than 32 bits. Is that right?
Thanks,
Frédéric.
bool validateIntRange(int minimum, int maximum)
{
if (minimum >= maximum)
return false;
juce::NormalisableRange<float> range { (float)minimum, (float)maximum, 1.0f, 1.0f };
for (auto i = minimum; i <= maximum; ++i)
{
auto value = static_cast<float>(i);
if (static_cast<int>(value) != i)
return false;
auto normalized = range.convertTo0to1(value);
auto value2 = range.convertFrom0to1(normalized);
if (value != value2)
return false;
}
return true;
}
void validateIntRanges()
{
auto minimum = 0;
auto maximum = 1;
while (maximum <= (1 << 30))
{
if (!validateIntRange(minimum, maximum))
{
DBG("Invalid int range: " << minimum << ".." << maximum);
return;
}
DBG("Valid int range: " << minimum << ".." << maximum);
maximum *= 2;
}
}
Valid int range: 0..1
Valid int range: 0..2
Valid int range: 0..4
Valid int range: 0..8
Valid int range: 0..16
Valid int range: 0..32
Valid int range: 0..64
Valid int range: 0..128
Valid int range: 0..256
Valid int range: 0..512
Valid int range: 0..1024
Valid int range: 0..2048
Valid int range: 0..4096
Valid int range: 0..8192
Valid int range: 0..16384
Valid int range: 0..32768
Valid int range: 0..65536
Valid int range: 0..131072
Valid int range: 0..262144
Valid int range: 0..524288
Valid int range: 0..1048576
Valid int range: 0..2097152
Valid int range: 0..4194304
Valid int range: 0..8388608
Valid int range: 0..16777216
Invalid int range: 0..33554432
No way? even using uint32 cast for example? I am not expert, but it sounds strange, because “32 bits is 32 bits” whatever the interpretation we may have of it (int or float) no?
An audio parameter is usually a parameter affecting the audio processing that the user can automate from the plugin host. I’m not sure if a int representation of an rgba value is really something that could be automated in a useful way, so maybe an audio parameter is simply not the best choice for that. What is your use case? Alternatively you could maybe think of adding four parameters to store the colour with individual r, g, b and a parameters in a 0-1 float range.
Using a parameter seems like overkill. We just have custom XML for our session data that we include the value tree XML in as just one of the nodes, not making it the entire thing. That lets us add other information we can parse out for purposes like this.
Yes, of course. It’s much better for me, thank you! I didn’t realize that, I’m a beginner with plugins and JUCE (which is great, thanks!) and I didn’t realize this now obvious solution.
So to be sure that i understand correctly now: is it correct that parameters are useful only for automation (with putting a Listener) and not for save/load operations of the plugin?