I’m just revisiting the parameter range issue for plugins.
Previously, I’d patched the AU wrapper just to get real-world values displayed on the track automation in Logic (for example). But that wouldn’t have worked in VST (or RTAS).
I’ve now gone for something similar Sean’s approach with a subclass of Slider displaying the real value (and optionally a units suffix) in its text box. Overriding getValueFromText() and getTextFromValue(). Then I’ve added the following functions to my AudioProcessor subclass:
float getMappedParameter(int index);
void setMappedParameterNotifyingHost(int index, float newValue);
float getParameterMin(int index) const;
float getParameterMax(int index) const;
bool getParameterWarp(int index) const;
const String getParameterUnits(int index) const;
I’m storing all my paramater info in a nested namespace e.g.:
namespace Parameters
{
static const char UNUSED_NOWARN *Names[] = {
"Gain",
"Pan",
"Cut-off"
};
static const ParamRange Ranges[] = {
{0, 1, LINEAR, 0},
{-1, 1, LINEAR, 0},
{50, 18000, EXPONENTIAL, "Hz"}
};
enum {
Gain,
Pan,
Cutoff,
Count
};
}
With ParamRange just being a lightweight struct:
struct ParamRange
{
double minimum;
double maximum;
bool warp; // true for exponential, false for linear
char units[64]; // use 0 for no units, e.g., "Hz" for freqency
};
(If I was designing this again form scratch the parameter name would be in this struct too but I have users of my code and that change would break their code at the moment.)
Now I find that the String returned from AudioProcessor::getParameterText() is the value displayed in Cubase when doing automation. I don’t have an RTAS dev license, is that what RTAS does too? But of course Logic still displays 0-1 rather than the real range.
So there seems to be a general solution that would work:
[list]
[] AudioProcessor deals with real world parameters rather than 0-1 and has knowledge of the parameter range (and ideally a concept of linear/exponential mapping for things like frequencies and delay times or perhaps just using a similar idea to the Slider skew concept)[/]
[] The AU wrapper sets up the parameter ranges (and possibly the unit type?) as is possible in AU[/]
[] The VST and RTAS wrappers map down to 0-1 to communicate with the host[/][/list]
This should be possible without breaking exisiting code by keeping setParameter/getParameter (normalised versions) and adding ‘mapped’ versions of these functions.