iPlug2 - C++ Audio Plug-in Framework
Loading...
Searching...
No Matches
IPlugPluginBase.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
19#include "IPlugParameter.h"
20#include "IPlugStructs.h"
21#include "IPlugLogger.h"
22
23BEGIN_IPLUG_NAMESPACE
24
26class IPluginBase : public EDITOR_DELEGATE_CLASS
27{
28public:
29 IPluginBase(int nParams, int nPresets);
30 virtual ~IPluginBase();
31
32 IPluginBase(const IPluginBase&) = delete;
33 IPluginBase& operator=(const IPluginBase&) = delete;
34
35#pragma mark - Plug-in properties
37 const char* GetPluginName() const { return mPluginName.Get(); }
38
42 int GetPluginVersion(bool decimal) const;
43
49 void GetPluginVersionStr(WDL_String& str) const;
50
52 const char* GetMfrName() const { return mMfrName.Get(); }
53
55 const char* GetProductName() const { return mProductName.Get(); }
56
58 int GetUniqueID() const { return mUniqueID; }
59
61 int GetMfrID() const { return mMfrID; }
62
64 EHost GetHost() const { return mHost; }
65
68 void GetHostStr(WDL_String& str) const { GetHostNameStr(GetHost(), str); }
69
73 int GetHostVersion(bool decimal) const;
74
77 void GetHostVersionStr(WDL_String& str) const;
78
80 EAPI GetAPI() const { return mAPI; }
81
83 const char* GetAPIStr() const;
84
86 const char* GetArchStr() const;
87
92 void GetBuildInfoStr(WDL_String& str, const char* date, const char* time) const;
93
95 bool HasUI() const { return mHasUI; }
96
98 bool GetHostResizeEnabled() const { return mHostResize; }
99
100 /*** @return a CString with the bundle identifier (macOS/IOS only) */
101 const char* GetBundleID() const { return mBundleID.Get(); }
102
103 /*** @return a CString with the app group identifier (macOS/IOS only) */
104 const char* GetAppGroupID() const { return mAppGroupID.Get(); }
105
106#pragma mark - Parameters
107
109 int NParamGroups() const { return mParamGroups.GetSize(); }
110
114 int AddParamGroup(const char* name) { mParamGroups.Add(name); return NParamGroups(); }
115
119 const char* GetParamGroupName(int idx) const { return mParamGroups.Get(idx); }
120
123
124#pragma mark - State Serialization
126 bool DoesStateChunks() const { return mStateChunks; }
127
131 bool SerializeParams(IByteChunk& chunk) const;
132
137 int UnserializeParams(const IByteChunk& chunk, int startPos);
138
142 virtual bool SerializeState(IByteChunk& chunk) const { TRACE return SerializeParams(chunk); }
143
149 virtual int UnserializeState(const IByteChunk& chunk, int startPos) { TRACE return UnserializeParams(chunk, startPos); }
150
154 virtual bool SerializeVST3CtrlrState(IByteChunk& chunk) const { return true; }
155
159 virtual int UnserializeVST3CtrlrState(const IByteChunk& chunk, int startPos) { return startPos; }
160
163 int GetCurrentPresetIdx() const { return mCurrentPresetIdx; }
164
167 void SetCurrentPresetIdx(int idx) { assert(idx > -1 && idx < NPresets()); mCurrentPresetIdx = idx; }
168
170 virtual void InformHostOfPresetChange() {};
171
172#pragma mark - Preset Manipulation
173
176 IPreset* GetPreset(int idx) { return mPresets.Get(idx); }
177
181 void ModifyCurrentPreset(const char* name = 0);
182
185 int NPresets() const { return mPresets.GetSize(); }
186
190 bool RestorePreset(int idx);
191
195 bool RestorePreset(const char* name);
196
200 const char* GetPresetName(int idx) const;
201
205 void CopyPreset(IPreset* pSrc, int destIdx, bool copyname = false)
206 {
207 IPreset* pDst = mPresets.Get(destIdx);
208
209 pDst->mChunk.Clear();
210 pDst->mChunk.PutChunk(&pSrc->mChunk);
211 pDst->mInitialized = true;
212 strncpy(pDst->mName, pSrc->mName, MAX_PRESET_NAME_LEN - 1);
213 }
214
221 void MakeDefaultPreset(const char* name = 0, int nPresets = 1);
222
228 void MakePreset(const char* name, ...);
229
237 void MakePresetFromNamedParams(const char* name, int nParamsNamed, ...);
238
242 void MakePresetFromChunk(const char* name, IByteChunk& chunk);
243
250 void MakePresetFromBlob(const char* name, const char* blob, int sizeOfChunk);
251
254
256 virtual void OnPresetsModified() {}
257
259 void EnsureDefaultPreset();
260
264 bool SerializePresets(IByteChunk& chunk) const;
265
270 int UnserializePresets(const IByteChunk& chunk, int startPos);
271
274 void DumpMakePresetSrc(const char* file) const;
275
279 void DumpMakePresetFromNamedParamsSrc(const char* file, const char* paramEnumNames[]) const;
280
283 void DumpPresetBlob(const char* file) const;
284
288 bool SavePresetAsFXP(const char* file) const;
289
293 bool SaveBankAsFXB(const char* file) const;
294
298 bool LoadPresetFromFXP(const char* file);
299
303 bool LoadBankFromFXB(const char* file);
304
305
306#pragma mark - Parameter manipulation
307
323 void InitParamRange(int startIdx, int endIdx, int countStart, const char* nameFmtStr, double defaultVal, double minVal, double maxVal, double step, const char* label = "", int flags = 0, const char* group = "", const IParam::Shape& shape = IParam::ShapeLinear(), IParam::EParamUnit unit = IParam::kUnitCustom, IParam::DisplayFunc displayFunc = nullptr);
324
332 void CloneParamRange(int cloneStartIdx, int cloneEndIdx, int startIdx, const char* searchStr = "", const char* replaceStr = "", const char* newGroup = "");
333
338 void ForParamInRange(int startIdx, int endIdx, std::function<void(int paramIdx, IParam& param)> func);
339
343 void ForParamInGroup(const char* paramGroup, std::function<void(int paramIdx, IParam& param)> func);
344
349 void CopyParamValues(int startIdx, int destIdx, int nParams);
350
354 void CopyParamValues(const char* inGroup, const char* outGroup);
355
358
362 void RandomiseParamValues(int startIdx, int endIdx);
363
366 void RandomiseParamValues(const char* paramGroup);
367
369 void DefaultParamValues();
370
374 void DefaultParamValues(int startIdx, int endIdx);
375
378 void DefaultParamValues(const char* paramGroup);
379
381 void PrintParamValues();
382
383 friend class IPlugAPP;
384 friend class IPlugAAX;
385 friend class IPlugVST2;
386 friend class IPlugVST3;
387 friend class IPlugVST3Controller;
388 friend class IPlugVST3Processor;
389 friend class IPlugAU;
390 friend class IPlugAUv3;
391 friend class IPlugWEB;
392 friend class IPlugWAM;
393 friend class IPlugAPIBase;
394
395private:
396 int mCurrentPresetIdx = 0;
398 bool mStateChunks = false;
400 WDL_String mPluginName;
402 WDL_String mProductName;
404 WDL_String mMfrName;
405 /* Plug-in unique four char ID as an int */
406 int mUniqueID;
407 /* Manufacturer unique four char ID as an int */
408 int mMfrID;
410 int mVersion;
412 int mHostVersion = 0;
414 EHost mHost = kHostUninit;
416 EAPI mAPI;
418 WDL_String mBundleID;
420 WDL_String mAppGroupID;
422 bool mHasUI = false;
424 bool mHostResize = false;
426 WDL_PtrList<const char> mParamGroups;
428 WDL_PtrList<IPreset> mPresets;
429
430#ifdef PARAMS_MUTEX
431 friend class IPlugVST3ProcessorBase;
432protected:
434 WDL_Mutex mParams_mutex;
435#endif
436};
437
438END_IPLUG_NAMESPACE
Used for choosing an editor delegate.
IPlug logging a.k.a tracing functionality.
Manages a block of memory, for plug-in settings store/recall.
Definition: IPlugStructs.h:112
void Clear()
Clears the chunk (resizes to 0)
Definition: IPlugStructs.h:214
int PutChunk(const IByteChunk *pRHS)
Put another IByteChunk into this one.
Definition: IPlugStructs.h:208
IPlug's parameter class.
std::function< void(double, WDL_String &)> DisplayFunc
DisplayFunc allows custom parameter display functions, defined by a lambda matching this signature.
EParamUnit
Used by AudioUnit plugins to determine the appearance of parameters, based on the kind of data they r...
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
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
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
Shared VST3 processor code.
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.
void ForParamInRange(int startIdx, int endIdx, std::function< void(int paramIdx, IParam &param)> func)
Modify a range of parameters with a lamda function.
void InitParamRange(int startIdx, int endIdx, int countStart, const char *nameFmtStr, double defaultVal, double minVal, double maxVal, double step, const char *label="", int flags=0, const char *group="", const IParam::Shape &shape=IParam::ShapeLinear(), IParam::EParamUnit unit=IParam::kUnitCustom, IParam::DisplayFunc displayFunc=nullptr)
Initialise a range of parameters simultaneously.
virtual int UnserializeState(const IByteChunk &chunk, int startPos)
Override this method to unserialize custom state data, if your plugin does state chunks.
IPreset * GetPreset(int idx)
Get a ptr to a factory preset @ param idx The index number of the preset you are referring to.
void DefaultParamValues()
Set all parameters to their default values.
const char * GetPluginName() const
int GetMfrID() const
void DumpMakePresetFromNamedParamsSrc(const char *file, const char *paramEnumNames[]) const
Writes a call to MakePresetFromNamedParams() for the current preset to a new text file.
bool SerializeParams(IByteChunk &chunk) const
Serializes the current double precision floating point, non-normalised values (IParam::mValue) of all...
void GetHostStr(WDL_String &str) const
Get the host name as a CString.
int GetPluginVersion(bool decimal) const
Get the plug-in version number.
const char * GetArchStr() const
bool HasUI() const
void RandomiseParamValues()
Randomise all parameters.
void MakePresetFromBlob(const char *name, const char *blob, int sizeOfChunk)
Creates a preset from a base64 encoded CString.
int GetUniqueID() const
int UnserializePresets(const IByteChunk &chunk, int startPos)
[VST2 only] Called when the VST2 host calls effSetChunk for a bank *
bool LoadPresetFromFXP(const char *file)
Load VST2 format preset.
virtual void InformHostOfParameterDetailsChange()
Implemented by the API class, call this if you update parameter labels and hopefully the host should ...
virtual bool SerializeState(IByteChunk &chunk) const
Override this method to serialize custom state data, if your plugin does state chunks.
int AddParamGroup(const char *name)
Called to add a parameter group name, when a unique group name is discovered.
bool DoesStateChunks() const
void ModifyCurrentPreset(const char *name=0)
This method should update the current preset with current values NOTE: This is only relevant for VST2...
int GetCurrentPresetIdx() const
Get the index of the current, active preset.
int UnserializeParams(const IByteChunk &chunk, int startPos)
Unserializes double precision floating point, non-normalised values from a byte chunk into mParams.
void EnsureDefaultPreset()
[VST2 only] Called to fill uninitialzed presets
int GetHostVersion(bool decimal) const
Get the host version number as an integer.
void CopyParamValues(int startIdx, int destIdx, int nParams)
Copy a range of parameter values.
virtual void InformHostOfPresetChange()
Implemented by the API class, called by the UI (etc) when the plug-in initiates a program/preset chan...
void GetPluginVersionStr(WDL_String &str) const
Gets the plug-in version as a string.
void MakePresetFromNamedParams(const char *name, int nParamsNamed,...)
Create a baked-in factory preset, specifiying parameter values with a list of parameter index and val...
const char * GetMfrName() const
Get the manufacturer name as a CString.
void DumpPresetBlob(const char *file) const
Writes a call to MakePresetFromBlob() for the current preset to a new text file.
bool RestorePreset(int idx)
Restore a preset by index.
const char * GetParamGroupName(int idx) const
Get the parameter group name as a particular index.
void SetCurrentPresetIdx(int idx)
Set the index of the current, active preset.
void GetBuildInfoStr(WDL_String &str, const char *date, const char *time) const
Get the build date of the plug-in and architecture/api details in one string.
void GetHostVersionStr(WDL_String &str) const
Get the host version number as a string.
void MakeDefaultPreset(const char *name=0, int nPresets=1)
This method can be used to initialize baked-in factory presets with the default parameter values.
const char * GetAPIStr() const
virtual bool SerializeVST3CtrlrState(IByteChunk &chunk) const
VST3 ONLY! - THIS IS ONLY INCLUDED FOR COMPATIBILITY - NOONE ELSE SHOULD NEED IT!
bool SerializePresets(IByteChunk &chunk) const
[VST2 only] Called when the VST2 host calls effGetChunk for a bank *
void ForParamInGroup(const char *paramGroup, std::function< void(int paramIdx, IParam &param)> func)
Modify a parameter group simulataneously.
void CopyPreset(IPreset *pSrc, int destIdx, bool copyname=false)
Copy source preset to preset at index.
const char * GetPresetName(int idx) const
Get the name a preset.
bool LoadBankFromFXB(const char *file)
Load VST2 format bank [VST2 only].
bool GetHostResizeEnabled() const
void CloneParamRange(int cloneStartIdx, int cloneEndIdx, int startIdx, const char *searchStr="", const char *replaceStr="", const char *newGroup="")
Clone a range of parameters, optionally doing a string substitution on the parameter name.
virtual int UnserializeVST3CtrlrState(const IByteChunk &chunk, int startPos)
VST3 ONLY! - THIS IS ONLY INCLUDED FOR COMPATIBILITY - NOONE ELSE SHOULD NEED IT!
void DumpMakePresetSrc(const char *file) const
Writes a call to MakePreset() for the current preset to a new text file.
bool SavePresetAsFXP(const char *file) const
Save current state as a VST2 format preset.
EHost GetHost() const
void PruneUninitializedPresets()
[AUV2 only] Removes any presets that weren't initialized
EAPI GetAPI() const
void PrintParamValues()
Default parameter values for a parameter group
virtual void OnPresetsModified()
[VST2 only] Called when the preset name is changed by the host
void MakePresetFromChunk(const char *name, IByteChunk &chunk)
Creates a preset from an IByteChunk containging serialized data.
int NPresets() const
Gets the number of factory presets.
bool SaveBankAsFXB(const char *file) const
Save current bank as a VST2 format bank [VST2 only].
int NParamGroups() const
const char * GetProductName() const
Get the product name as a CString.
void MakePreset(const char *name,...)
Create a baked-in factory preset, specifiying parameter values sequentially usage: MakePreset(name,...
EHost
Host identifier.
static void GetHostNameStr(EHost host, WDL_String &str)
Gets a human-readable name from host identifier.
Base struct for parameter shaping.
Linear parameter shaping.
A struct used for specifying baked-in factory presets.
Definition: IPlugStructs.h:602