23 using namespace iplug;
25 IPlugAPIBase::IPlugAPIBase(Config c, EAPI plugAPI)
28 mUniqueID = c.uniqueID;
30 mVersion = c.vendorVersion;
31 mPluginName.Set(c.pluginName, MAX_PLUGIN_NAME_LEN);
32 mProductName.Set(c.productName, MAX_PLUGIN_NAME_LEN);
33 mMfrName.Set(c.mfrName, MAX_PLUGIN_NAME_LEN);
35 mHostResize = c.plugHostResize;
36 SetEditorSize(c.plugWidth, c.plugHeight);
37 SetSizeConstraints(c.plugMinWidth, c.plugMaxWidth, c.plugMinHeight, c.plugMaxHeight);
38 mStateChunks = c.plugDoesChunks;
40 mBundleID.Set(c.bundleID);
42 Trace(TRACELOC,
"%s:%s", c.pluginName, CurrentTime());
44 mParamDisplayStr.Set(
"", MAX_PARAM_DISPLAY_LEN);
47 IPlugAPIBase::~IPlugAPIBase()
61 for (
int i = 0; i < count; i++)
68 mTimer = std::unique_ptr<Timer>(Timer::Create(std::bind(&IPlugAPIBase::OnTimer,
this, std::placeholders::_1), IDLE_TIMER_RATE));
75 const double* data = (
const double*) pIncomingState + startPos;
79 for (
int i = 0; i < NParams(); i++)
81 float v = (float) GetParam(i)->Value();
82 float vi = (float) *(data++);
84 isEqual &= (std::fabs(v - vi) < 0.00001);
90 bool IPlugAPIBase::EditorResizeFromUI(
int viewWidth,
int viewHeight,
bool needsPlatformResize)
92 if (needsPlatformResize)
102 assert(mHost == kHostUninit);
105 mHostVersion = version;
109 Trace(TRACELOC,
"host_%sknown:%s:%s", (mHost == kHostUnknown ?
"un" :
""), host, vStr.Get());
117 Trace(TRACELOC,
"%d:%f", idx, normalizedValue);
118 GetParam(idx)->SetNormalized(normalizedValue);
120 OnParamChange(idx, kUI);
125 for (
int p = 0; p < NParams(); p++)
127 double normalizedValue = GetParam(p)->GetNormalized();
135 value = GetParam(paramIdx)->FromNormalized(value);
137 mParamChangeFromProcessor.Push(
ParamTuple { paramIdx, value } );
140 void IPlugAPIBase::OnTimer(
Timer& t)
145 #if defined VST3P_API || defined VST3_API 146 while (mMidiMsgsFromProcessor.ElementsAvailable())
149 mMidiMsgsFromProcessor.Pop(msg);
150 #ifdef VST3P_API // distributed 151 TransmitMidiMsgFromProcessor(msg);
153 SendMidiMsgFromDelegate(msg);
157 while (mSysExDataFromProcessor.ElementsAvailable())
160 mSysExDataFromProcessor.Pop(msg);
161 #ifdef VST3P_API // distributed 162 TransmitSysExDataFromProcessor(msg);
164 SendSysexMsgFromDelegate({msg.mOffset, msg.mData, msg.mSize});
169 while(mParamChangeFromProcessor.ElementsAvailable())
172 mParamChangeFromProcessor.Pop(p);
173 SendParameterValueFromDelegate(p.idx, p.value,
false);
176 while (mMidiMsgsFromProcessor.ElementsAvailable())
179 mMidiMsgsFromProcessor.Pop(msg);
180 SendMidiMsgFromDelegate(msg);
183 while (mSysExDataFromProcessor.ElementsAvailable())
186 mSysExDataFromProcessor.Pop(msg);
187 SendSysexMsgFromDelegate({msg.mOffset, msg.mData, msg.mSize});
195 void IPlugAPIBase::SendMidiMsgFromUI(
const IMidiMsg& msg)
198 EDITOR_DELEGATE_CLASS::SendMidiMsgFromUI(msg);
201 void IPlugAPIBase::SendSysexMsgFromUI(
const ISysEx& msg)
204 EDITOR_DELEGATE_CLASS::SendSysexMsgFromUI(msg);
207 void IPlugAPIBase::SendArbitraryMsgFromUI(
int msgTag,
int ctrlTag,
int dataSize,
const void* pData)
209 OnMessage(msgTag, ctrlTag, dataSize, pData);
211 EDITOR_DELEGATE_CLASS::SendArbitraryMsgFromUI(msgTag, ctrlTag, dataSize, pData);
virtual void OnHostRequestingImportantParameters(int count, WDL_TypedBuf< int > &results)
Called by AUv3 plug-ins to get the "overview parameters".
Encapsulates a MIDI message and provides helper functions.
virtual void SendParameterValueFromAPI(int paramIdx, double value, bool normalized)
This is called from the plug-in API class in order to update UI controls linked to plug-in parameters...
void InformHostOfParamChange(int idx, double normalizedValue) override
Implemented by the API class, called by the UI via SetParameterValue() with the value of a parameter ...
virtual void HostSpecificInit()
This method is implemented in some API classes, in order to do specific initialisation for particular...
bool EditorResize(int viewWidth, int viewHeight) override
Implementations call into the APIs resize hooks returns a bool to indicate whether the DAW or plugin ...
virtual bool CompareState(const uint8_t *pIncomingState, int startPos) const
Override this method to implement a custom comparison of incoming state data with your plug-ins state...
void CreateTimer()
Called by the API class to create the timer that pumps the parameter/message queues.
virtual void DirtyParametersFromUI() override
In a distributed VST3 or WAM plugin, if you modify the parameters on the UI side (e.g.
static void GetVersionStr(int versionInteger, WDL_String &str)
Helper function to get the semantic version number as a string from an integer.
In certain cases we need to queue parameter changes for transferral between threads.
virtual void OnIdle()
Override this method to get an "idle"" call on the main thread.
The base class of an IPlug plug-in, which interacts with the different plug-in APIs.
A struct for dealing with SysEx messages.
This structure is used when queueing Sysex messages.
static EHost LookUpHost(const char *inHost)
Gets the host ID from a human-readable name.
void SetParameterValue(int paramIdx, double normalizedValue)
SetParameterValue is called from the UI in the middle of a parameter change gesture (possibly via del...
Base class that contains plug-in info and state manipulation methods.
void SetHost(const char *host, int version)
Called to set the name of the current host, if known (calls on to HostSpecificInit() and OnHostIdenti...
virtual void OnHostIdentified()
Implement this to do something specific when IPlug becomes aware of the particular host that is hosti...