Closed wtholliday closed 3 years ago
Actually, never mind... It's easy enough to just instantiate a throw-away DSP object.
Yeah, the code that generates c++ is in our internal codebase. But actually, not a bad idea for us to mark it static, and even constexpr probably, as I think it's all just compile-time constants in there. I'll take a look when I get a second!
ah no - just had a look and noticed that actually it does some lambda capture in there, so can't be static, I'm afraid..
@julianstorer Yeah, I was suggesting moving the lambda capture to a separate struct. So you'd have something like:
struct ParameterProperties
{
const char* UID;
const char* name;
const char* unit;
float minValue, maxValue, step, initialValue;
bool isAutomatable, isBoolean, isHidden;
const char* group;
const char* textValues;
};
static std::vector<ParameterProperties> getParameterProperties() { ... }
struct Parameter
{
float minValue, maxValue;
float currentValue;
std::function<void(float)> applyValue;
void setValue (float f)
{
currentValue = snapToLegalValue (f);
applyValue (f);
}
float getValue() const
{
return currentValue;
}
private:
float snapToLegalValue (float v) const
{
if (step > 0)
v = minValue + step * std::floor ((v - minValue) / step + 0.5f);
return v < minValue ? minValue : (v > maxValue ? maxValue : v);
}
};
std::vector<Parameter> getParameters() { ... }
Could also put a ParameterProperties
in Parameter
if you want.
Yep, sensible request, I'll have a look when I get a moment!
I'm doing some initial integration of SOUL into AudioKit via
soul generate --cpp
PR here if curious: https://github.com/AudioKit/AudioKit/pull/2225
It would be helpful to be able to query as much information as possible without having to instantiate the DSP object. This would assist us in populating things on the Swift side.
To be specific, it seems
getParameterProperties
could be declaredstatic
except forapplyValue
. Suggest thatapplyValue
be moved to a separate array (perhaps returned bygetApplyValueFunctions
).I can't seem to find the code that generates
getParameterProperties
in this repo. Perhaps it's in the closed-source backend.Let me know if/how I can help 😀