25IPlugAPIBase::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);
41 mAppGroupID.Set(c.appGroupID);
43 Trace(TRACELOC,
"%s:%s", c.pluginName, CurrentTime());
45 mParamDisplayStr.Set(
"", MAX_PARAM_DISPLAY_LEN);
48IPlugAPIBase::~IPlugAPIBase()
62 for (
int i = 0; i < count; i++)
69 mTimer = std::unique_ptr<Timer>(
Timer::Create([
this](
Timer&) { OnTimer(); }, IDLE_TIMER_RATE));
76 const double* data = (
const double*) (pIncomingState + startPos);
80 for (
int i = 0; i < NParams(); i++)
82 float v = (float) GetParam(i)->Value();
83 float vi = (float) *(data++);
85 isEqual &= (std::fabs(v - vi) < 0.00001);
91bool IPlugAPIBase::EditorResizeFromUI(
int viewWidth,
int viewHeight,
bool needsPlatformResize)
93 if (needsPlatformResize)
94 return EditorResize(viewWidth, viewHeight);
99 SetEditorSize(viewWidth, viewHeight);
108 assert(mHost == kHostUninit);
110 mRawHostNameStr.Set(host);
112 mHostVersion = version;
116 Trace(TRACELOC,
"host_%sknown:%s:%s", (mHost == kHostUnknown ?
"un" :
""), host, vStr.Get());
124 Trace(TRACELOC,
"%d:%f", idx, normalizedValue);
125 GetParam(idx)->SetNormalized(normalizedValue);
126 InformHostOfParamChange(idx, normalizedValue);
127 OnParamChange(idx, kUI);
132 for (
int p = 0; p < NParams(); p++)
134 double normalizedValue = GetParam(p)->GetNormalized();
135 InformHostOfParamChange(p, normalizedValue);
142 value = GetParam(paramIdx)->FromNormalized(value);
144 mParamChangeFromProcessor.
PushFromArgs(paramIdx, value);
147void IPlugAPIBase::OnTimer()
150#if defined VST3P_API || defined VST3_API
154 mMidiMsgsFromProcessor.
Pop(msg);
156 TransmitMidiMsgFromProcessor(msg);
158 SendMidiMsgFromDelegate(msg);
165 mSysExDataFromProcessor.
Pop(msg);
167 TransmitSysExDataFromProcessor(msg);
169 SendSysexMsgFromDelegate({msg.mOffset, msg.mData, msg.mSize});
177 mParamChangeFromProcessor.
Pop(p);
178 SendParameterValueFromDelegate(p.idx, p.value,
false);
184 mMidiMsgsFromProcessor.
Pop(msg);
185 SendMidiMsgFromDelegate(msg);
191 mSysExDataFromProcessor.
Pop(msg);
192 SendSysexMsgFromDelegate({msg.mOffset, msg.mData, msg.mSize});
199void IPlugAPIBase::SendMidiMsgFromUI(
const IMidiMsg& msg)
202 EDITOR_DELEGATE_CLASS::SendMidiMsgFromUI(msg);
205void IPlugAPIBase::SendSysexMsgFromUI(
const ISysEx& msg)
208 EDITOR_DELEGATE_CLASS::SendSysexMsgFromUI(msg);
211void IPlugAPIBase::SendArbitraryMsgFromUI(
int msgTag,
int ctrlTag,
int dataSize,
const void* pData)
213 OnMessage(msgTag, ctrlTag, dataSize, pData);
215 EDITOR_DELEGATE_CLASS::SendArbitraryMsgFromUI(msgTag, ctrlTag, dataSize, pData);
void CreateTimer()
Called by the API class to create the timer that pumps the parameter/message queues.
virtual void OnIdle()
Override this method to get an "idle"" call on the main thread.
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 SetParameterValue(int paramIdx, double normalizedValue)
SetParameterValue is called from the UI in the middle of a parameter change gesture (possibly via del...
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 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 DirtyParametersFromUI() override
In a distributed VST3 or WAM plugin, if you modify the parameters on the UI side (e....
virtual void HostSpecificInit()
This method is implemented in some API classes, in order to do specific initialisation for particular...
virtual void OnHostIdentified()
Implement this to do something specific when IPlug becomes aware of the particular host that is hosti...
virtual void OnHostRequestingImportantParameters(int count, WDL_TypedBuf< int > &results)
Called by AUv3 plug-ins to get the "overview parameters".
bool Pop(T &item)
Removes and retrieves an item from the queue.
size_t ElementsAvailable() const
Returns the number of elements currently in the queue.
bool PushFromArgs(Args ...args)
Constructs and adds an item to the queue in-place from arguments.
Base class that contains plug-in info and state manipulation methods.
static void GetVersionStr(int versionInteger, WDL_String &str)
Helper function to get the semantic version number as a string from an integer.
static EHost LookUpHost(const char *inHost)
Gets the host ID from a human-readable name.
Encapsulates a MIDI message and provides helper functions.
A struct for dealing with SysEx messages.
In certain cases we need to queue parameter changes for transferral between threads.
This structure is used when queueing Sysex messages.
static Timer * Create(ITimerFunction func, uint32_t intervalMs)
On Linux, callbacks run on a worker; returns nullptr if that worker cannot be created.