About setParameterNotifyingHost


#1

Hello

I’m doing what others have done before me, a class to allow easy conversion btw a “native value” (bool, int, int64, whatever) to/from the host float value.

My VSTi is a sample player which streams directly from the disk.
I’m a bit worried that there’s not enough resolution with floats to store an int64 which would be the start sample to play the audio file.
So, I thought, let’s store the “native value” in my class, and try to keep it as much as I can, and only convert it to/from float when the host calls setParameter or getParameter.

The problem I have is that when the UI wants to change the value of a parameter, it would call setNativeCurrentValue(xxx)
And setNativeCurrentValue would then store the native value, and calls the setParameterNotifyingHost function.
The problem is that setParameterNotifyingHost calls then setParameter, which converts from float to the native value, so all the benefit of storing the native value is lost.

So, there’s two solutions :

  • either I store the value as a float
  • or I ask Jules to add a notifyHostOfParameterChange(int n,float v) new function, that only tells the host that a value has changed.

What do you think ?

Here’s the .h of the class.

Thanks!

geoffroy

[code]
#ifndef GVSTPARAMETER_H
#define GVSTPARAMETER_H

#include “juce.h”
#include “juce_AudioFilterBase.h”

class GVSTParameter : public ChangeBroadcaster
{
public:
enum GVSTParameterType {boolParam,intParam,largeIntParam,floatParam,doubleParam,stringParam};

/** constructor
/
GVSTParameter(AudioFilterBase
filter, int parameterNumber, String parameterName, GVSTParameterType type);
GVSTParameter(AudioFilterBase* filter, int parameterNumber, String parameterName, bool initValue);
GVSTParameter(AudioFilterBase* filter, int parameterNumber, String parameterName, int minValue, int maxValue, int initValue);
GVSTParameter(AudioFilterBase* filter, int parameterNumber, String parameterName, float minValue, float maxValue, float initValue);
GVSTParameter(AudioFilterBase* filter, int parameterNumber, String parameterName, double minValue, double maxValue, double initValue);
GVSTParameter(AudioFilterBase* filter, int parameterNumber, String parameterName, int64 minValue, int64 maxValue, int64 initValue);
GVSTParameter(AudioFilterBase* filter, int parameterNumber, String parameterName, String value);

/** destructor
*/
~GVSTParameter();

/** gets the parameter name
*/
String getName();

/** when the host sets the value of the parameter. It will send a
* change message to all the listeners (typically the UI)
*/
void setHostValue(float v);
float getHostValue();

/**
* when the UI changes the value, it will send a message to the host
*/
void setNativeCurrentValue(bool v);
void setNativeCurrentValue(int v);
void setNativeCurrentValue(int64 v);
void setNativeCurrentValue(float v);
void setNativeCurrentValue(double v);

/**
* when the UI changes the min or max value of a parameter, it’s only
* to compute the host value, it doesn’t broadcast any message
*/
void setNativeMinValue(int v);
void setNativeMinValue(int64 v);
void setNativeMinValue(float v);
void setNativeMinValue(double v);

/**
* when the UI changes the min or max value of a parameter, it’s only
* to compute the host value, it doesn’t broadcast any message
*/
void setNativeMaxValue(int v);
void setNativeMaxValue(int64 v);
void setNativeMaxValue(float v);
void setNativeMaxValue(double v);

/**
* to set the value from a bank
* it will convert the string to the native type
* it will then tell the host and the UI to refresh
*/
void setCurrentNativeValueFromStringAndBroadcastToHostAndUI(String bankValue);

/**
* to get the native value in a String representation
*/
String getCurrentNativeValueInString();

private:
AudioFilterBase* filter;
String parameterName;
int parameterNumber;
GVSTParameterType type;
bool currentBoolValue;
int minIntValue, maxIntValue, currentIntValue;
float minFloatValue, maxFloatValue, currentFloatValue;
double minDoubleValue, maxDoubleValue, currentDoubleValue;
int64 minLargeIntValue, maxLargeIntValue, currentLargeIntValue;
String currentStringValue;
};

#endif
[/code][/code]


#2

Ta. I will add some kind of parameter improvements soon!


#3