iPlug2 - C++ Audio Plug-in Framework
Loading...
Searching...
No Matches
IPlugAPIBase.h
Go to the documentation of this file.
1/*
2 ==============================================================================
3
4 This file is part of the iPlug 2 library. Copyright (C) the iPlug 2 developers.
5
6 See LICENSE.txt for more info.
7
8 ==============================================================================
9*/
10
11#pragma once
12
13#include <cstring>
14#include <cstdint>
15#include <memory>
16
17#include "ptrlist.h"
18#include "mutex.h"
19
20#include "IPlugPlatform.h"
21#include "IPlugPluginBase.h"
22#include "IPlugConstants.h"
23#include "IPlugStructs.h"
24#include "IPlugUtilities.h"
25#include "IPlugParameter.h"
26#include "IPlugQueue.h"
27#include "IPlugTimer.h"
28
36BEGIN_IPLUG_NAMESPACE
37
38struct Config;
39
43{
44
45public:
46 IPlugAPIBase(Config config, EAPI plugAPI);
47 virtual ~IPlugAPIBase();
48
49 IPlugAPIBase(const IPlugAPIBase&) = delete;
50 IPlugAPIBase& operator=(const IPlugAPIBase&) = delete;
51
52#pragma mark - Methods you can implement/override in your plug-in class - you do not call these methods
53
59 virtual bool CompareState(const uint8_t* pIncomingState, int startPos) const;
60
61 /* Implement this and return true to trigger your custom about box, when someone clicks about in the menu of a standalone app or VST3 plugin */
62 virtual bool OnHostRequestingAboutBox() { return false; }
63
64 /* Implement this and return true to trigger your custom help info, when someone clicks help in the menu of a standalone app or VST3 plugin */
65 virtual bool OnHostRequestingProductHelp() { return false; }
66
69 virtual void OnHostIdentified() {}
70
74 virtual void OnHostRequestingImportantParameters(int count, WDL_TypedBuf<int>& results);
75
80 virtual bool OnHostRequestingSupportedViewConfiguration(int width, int height)
81 {
82 // Logic/GB offer one option with 0w, 0h, and if we allow that, our AUv3 has "our" size as its 100% setting
83 return ((width + height) == 0);
84 }
85
89 virtual void OnHostSelectedViewConfiguration(int width, int height) {}
90
96 virtual bool GetMidiNoteText(int noteNumber, char* str) const { *str = '\0'; return false; }
97
101 virtual void* GetAAXViewInterface()
102 {
103#ifndef NO_IGRAPHICS
104 return (void*) GetUI();
105#else
106 return nullptr;
107#endif
108 }
109
111 virtual void OnIdle() {}
112
113#pragma mark - Methods you can call - some of which have custom implementations in the API classes, some implemented in IPlugAPIBase.cpp
118 void SetParameterValue(int paramIdx, double normalizedValue);
119
121 virtual void GetTrackColor(int& r, int& g, int& b) { r = 0; g = 0; b = 0; }
122
124 virtual void GetTrackName(WDL_String& str) {}
125
127 virtual int GetTrackIndex() { return 0; }
128
130 virtual void GetTrackNamespace(WDL_String& str) {}
131
133 virtual int GetTrackNamespaceIndex() { return 0; }
134
137 virtual void DirtyParametersFromUI() override;
138
139#pragma mark - Methods called by the API class - you do not call these methods in your plug-in class
140
146 virtual void SendParameterValueFromAPI(int paramIdx, double value, bool normalized);
147
151 void SetHost(const char* host, int version);
152
155 virtual void HostSpecificInit() {}
156
157 //IEditorDelegate
158 void BeginInformHostOfParamChangeFromUI(int paramIdx) override { BeginInformHostOfParamChange(paramIdx); }
159
160 void EndInformHostOfParamChangeFromUI(int paramIdx) override { EndInformHostOfParamChange(paramIdx); }
161
162 bool EditorResizeFromUI(int viewWidth, int viewHeight, bool needsPlatformResize) override;
163
164 void SendParameterValueFromUI(int paramIdx, double normalisedValue) override
165 {
166 SetParameterValue(paramIdx, normalisedValue);
167 IPluginBase::SendParameterValueFromUI(paramIdx, normalisedValue);
168 }
169
170 //These are handled in IPlugAPIBase for non DISTRIBUTED APIs
171 void SendMidiMsgFromUI(const IMidiMsg& msg) override;
172
173 void SendSysexMsgFromUI(const ISysEx& msg) override;
174
175 void SendArbitraryMsgFromUI(int msgTag, int ctrlTag = kNoTag, int dataSize = 0, const void* pData = nullptr) override;
176
177 void DeferMidiMsg(const IMidiMsg& msg) override { mMidiMsgsFromEditor.Push(msg); }
178
179 void DeferSysexMsg(const ISysEx& msg) override
180 {
181 SysExData data(msg.mOffset, msg.mSize, msg.mData); // copies data
182 mSysExDataFromEditor.Push(data);
183 }
184
186 void CreateTimer();
187
188private:
191 virtual bool EditorResize(int width, int height) { return false; }
192
195 virtual void BeginInformHostOfParamChange(int paramIdx) {}
196
199 virtual void EndInformHostOfParamChange(int paramIdx) {}
200
204 virtual void InformHostOfParamChange(int paramIdx, double normalizedValue) {}
205
206 //DISTRIBUTED ONLY (Currently only VST3)
208 virtual void TransmitMidiMsgFromProcessor(const IMidiMsg& msg) {}
209
211 virtual void TransmitSysExDataFromProcessor(const SysExData& data) {}
212
213 void OnTimer(Timer& t);
214
215 friend class IPlugAPP;
216 friend class IPlugAAX;
217 friend class IPlugVST2;
218 friend class IPlugVST3;
219 friend class IPlugVST3Controller;
220 friend class IPlugVST3Processor;
221 friend class IPlugAU;
222 friend class IPlugAUv3;
223 friend class IPlugWEB;
224 friend class IPlugWAM;
225
226private:
227 WDL_String mParamDisplayStr;
228 std::unique_ptr<Timer> mTimer;
229
230 IPlugQueue<ParamTuple> mParamChangeFromProcessor {PARAM_TRANSFER_SIZE};
231 IPlugQueue<IMidiMsg> mMidiMsgsFromEditor {MIDI_TRANSFER_SIZE}; // a queue of midi messages generated in the editor by clicking keyboard UI etc
232 IPlugQueue<IMidiMsg> mMidiMsgsFromProcessor {MIDI_TRANSFER_SIZE}; // a queue of MIDI messages received (potentially on the high priority thread), by the processor to send to the editor
233 IPlugQueue<SysExData> mSysExDataFromEditor {SYSEX_TRANSFER_SIZE}; // a queue of SYSEX data to send to the processor
234 IPlugQueue<SysExData> mSysExDataFromProcessor {SYSEX_TRANSFER_SIZE}; // a queue of SYSEX data to send to the editor
235 SysExData mSysexBuf;
236};
237
238END_IPLUG_NAMESPACE
IPlug Constant definitions, Types, magic numbers.
Include to get consistently named preprocessor macros for different platforms and logging functionali...
This file includes classes for implementing timers - in order to get a regular callback on the main t...
Utility functions and macros.
AAX API base class for an IPlug plug-in.
Definition: IPlugAAX.h:80
The base class of an IPlug plug-in, which interacts with the different plug-in APIs.
Definition: IPlugAPIBase.h:43
virtual int GetTrackNamespaceIndex()
Get the namespace index of the track that the plug-in is inserted on.
Definition: IPlugAPIBase.h:133
void CreateTimer()
Called by the API class to create the timer that pumps the parameter/message queues.
virtual void OnHostSelectedViewConfiguration(int width, int height)
Called by some AUv3 plug-in hosts when a particular UI size is selected.
Definition: IPlugAPIBase.h:89
virtual int GetTrackIndex()
Get the index of the track that the plug-in is inserted on.
Definition: IPlugAPIBase.h:127
virtual bool GetMidiNoteText(int noteNumber, char *str) const
Override this method to provide custom text linked to MIDI note numbers in API classes that support t...
Definition: IPlugAPIBase.h:96
virtual void GetTrackNamespace(WDL_String &str)
Get the namespace of the track that the plug-in is inserted on.
Definition: IPlugAPIBase.h:130
virtual void * GetAAXViewInterface()
You need to implement this method if you are not using IGraphics and you want to support AAX's view i...
Definition: IPlugAPIBase.h:101
virtual void OnIdle()
Override this method to get an "idle"" call on the main thread.
Definition: IPlugAPIBase.h:111
virtual bool OnHostRequestingSupportedViewConfiguration(int width, int height)
Called by AUv3 plug-in hosts to query support for multiple UI sizes.
Definition: IPlugAPIBase.h:80
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...
Definition: IPlugAPIBase.h:155
virtual void OnHostIdentified()
Implement this to do something specific when IPlug becomes aware of the particular host that is hosti...
Definition: IPlugAPIBase.h:69
virtual void GetTrackName(WDL_String &str)
Get the name of the track that the plug-in is inserted on.
Definition: IPlugAPIBase.h:124
virtual void OnHostRequestingImportantParameters(int count, WDL_TypedBuf< int > &results)
Called by AUv3 plug-ins to get the "overview parameters".
virtual void GetTrackColor(int &r, int &g, int &b)
Get the color of the track that the plug-in is inserted on.
Definition: IPlugAPIBase.h:121
Standalone application base class for an IPlug plug-in.
Definition: IPlugAPP.h:37
AudioUnit v2 API base class for an IPlug plug-in.
Definition: IPlugAU.h:56
AudioUnit v3 API base class for an IPlug plug-in.
Definition: IPlugAUv3.h:45
A lock-free SPSC queue used to transfer data between threads based on MLQueue.h by Randy Jones based ...
Definition: IPlugQueue.h:32
bool Push(const T &item)
Definition: IPlugQueue.h:57
VST2.4 API base class for an IPlug plug-in.
Definition: IPlugVST2.h:36
VST3 Controller API-base class for a distributed IPlug VST3 plug-in.
VST3 base class for a non-distributed IPlug VST3 plug-in.
Definition: IPlugVST3.h:51
VST3 Processor API-base class for a distributed IPlug VST3 plug-in.
WebAudioModule (WAM) API base class.
Definition: IPlugWAM.h:31
Base class that contains plug-in info and state manipulation methods.
Encapsulates a MIDI message and provides helper functions.
Definition: IPlugMidi.h:31
A struct for dealing with SysEx messages.
Definition: IPlugMidi.h:539
This structure is used when queueing Sysex messages.
Definition: IPlugStructs.h:45
Base class for timer.
Definition: IPlugTimer.h:40