Hello,
I am trying to add the project version (as set in projucer) to the AudioProcessor parameters file.
I succeeded but encountered an old problem, my major/minor/revision version ints are being recorded as floats.
Here is my code that gets the version info and adds the parameters as AudioParameterInt
s:
AudioProcessorValueTreeState::ParameterLayout SmplcompAudioProcessor::createParameterLayout()
{
std::vector<std::unique_ptr<RangedAudioParameter>> params;
// other parameters added...
findVersionInfo();
params.push_back(std::make_unique<AudioParameterInt>("globeLoveVerMaj", "Globe Loveler Major Version",
1,
5,
globeLovelerVersion[0]));
params.push_back(std::make_unique<AudioParameterInt>("globeLoveVerMin", "Globe Loveler Minor Version",
1,
10,
globeLovelerVersion[1]));
params.push_back(std::make_unique<AudioParameterInt>("globeLoveVerRev", "Globe Loveler Revision",
1,
20,
globeLovelerVersion[2]));
}
void SmplcompAudioProcessor::findVersionInfo()
{
// Get program version -KGK
juce::String versionString = JUCEApplication::getInstance()->getApplicationVersion();
// * Split the version string into major, minor, and revision parts
juce::StringArray versionParts;
versionParts.addTokens(versionString, ".", "");
// * Ensure there are at least three parts (M, m, r)
while (versionParts.size() < 3)
versionParts.add("0");
// * Convert from str to int
for (int i = 0; i < versionParts.size(); ++i) {
int verN = versionParts[i].getIntValue();
globeLovelerVersion[i] = verN;
}
}
I haven’t modified the code to get/setStateInformation()
so it’s pretty boilerplate.
This is the output of the saved parameters file:
VC2!ĂĽ
<?xml version="1.0" encoding="UTF-8"?>
<PARAMETERS>
<PARAM id="attack" value="2.0"/> <!--Not normalized-->
<PARAM id="globeLoveVerMaj" value="1.0"/> <!--Not an int! :( -->
<PARAM id="globeLoveVerMin" value="2.0"/> <!--Not an int!-->
<PARAM id="globeLoveVerRev" value="2.0"/> <!--Not an int!-->
<PARAM id="inputgain" value="0.0"/>
<PARAM id="knee" value="6.0"/> <!--Not normalized-->
<PARAM id="makeup" value="19.60000228881836"/> <!--Not normalized-->
<PARAM id="mix" value="0.7440000176429749"/>
<PARAM id="power" value="1.0"/>
<PARAM id="ratio" value="2.0"/> <!--Not normalized-->
<PARAM id="release" value="140.0"/> <!--Not normalized-->
<PARAM id="threshold" value="-40.0"/> <!--Not normalized-->
</PARAMETERS>
My version parameters are the 2nd-4th recorded here. They are recorded as floats, furthermore, they are not normalized.
- It seems I’ll just have to work around them being saved as floats, is that correct?
- Why aren’t these parameters normalized? They are all given normalizable ranges when added to the parameter layout (
params
). - Side question, how does the order in which parameters are added to a parameterLayout matter?
Thank you
Some threads I read on this topic -
-
Probably the best outline of the situation and solutions:
Why are all audio parameters *float? -
Converting to text:
AudioProcessorValueTreeState::Parameter::getText() normalised or non-normalised argument? -
Exposes some good-to-know behavior but doesn’t explain much:
Proper usage of AudioParameterInt -
Discussion of the situation (hoping I don’t have to re-implement any built ins):
Expose AudioParameterInt/Float member functions