17 #include "wdlendian.h" 18 #include "wdl_base64.h" 20 using namespace iplug;
22 IPluginBase::IPluginBase(
int nParams,
int nPresets)
23 : EDITOR_DELEGATE_CLASS(nParams)
25 for (
int i = 0; i < nPresets; ++i)
29 IPluginBase::~IPluginBase()
45 #if defined TRACER_BUILD 70 case kAPIVST2:
return "VST2";
71 case kAPIVST3:
return "VST3";
72 case kAPIAU:
return "AU";
73 case kAPIAUv3:
return "AUv3";
74 case kAPIAAX:
return "AAX";
75 case kAPIAPP:
return "APP";
76 case kAPIWAM:
return "WAM";
77 case kAPIWEB:
return "WEB";
86 #elif defined __aarch64__ 88 #elif defined ARCH_64BIT 98 GetPluginVersionStr(version);
99 str.SetFormatted(MAX_BUILD_INFO_STR_LEN,
"%s %s (%s), built on %s at %.5s ", version.Get(), GetAPIStr(), GetArchStr(), date, time);
108 int i, n = mParams.GetSize();
109 for (i = 0; i < n && savedOK; ++i)
111 IParam* pParam = mParams.Get(i);
112 Trace(TRACELOC,
"%d %s %f", i, pParam->
GetName(), pParam->
Value());
113 double v = pParam->
Value();
114 savedOK &= (chunk.
Put(&v) > 0);
122 int i, n = mParams.GetSize(), pos = startPos;
124 for (i = 0; i < n && pos >= 0; ++i)
126 IParam* pParam = mParams.Get(i);
128 pos = chunk.
Get(&v, pos);
130 Trace(TRACELOC,
"%d %s %f", i, pParam->
GetName(), pParam->
Value());
133 OnParamReset(kPresetRecall);
139 void IPluginBase::InitParamRange(
int startIdx,
int endIdx,
int countStart,
const char* nameFmtStr,
double defaultVal,
double minVal,
double maxVal,
double step,
const char *label,
int flags,
const char *group,
const IParam::Shape& shape,
IParam::EParamUnit unit,
IParam::DisplayFunc displayFunc)
142 for (
auto p = startIdx; p <= endIdx; p++)
144 nameStr.SetFormatted(MAX_PARAM_NAME_LEN, nameFmtStr, countStart + (p-startIdx));
145 GetParam(p)->InitDouble(nameStr.Get(), defaultVal, minVal, maxVal, step, label, flags, group, shape, unit, displayFunc);
149 void IPluginBase::CloneParamRange(
int cloneStartIdx,
int cloneEndIdx,
int startIdx,
const char* searchStr,
const char* replaceStr,
const char* newGroup)
151 for (
auto p = cloneStartIdx; p <= cloneEndIdx; p++)
153 IParam* pParam = GetParam(p);
154 int outIdx = startIdx + (p - cloneStartIdx);
155 GetParam(outIdx)->Init(*pParam, searchStr, replaceStr, newGroup);
156 GetParam(outIdx)->Set(pParam->
Value());
162 assert((startIdx + nParams) < NParams());
163 assert((destIdx + nParams) < NParams());
164 assert((startIdx + nParams) < destIdx);
166 for (
auto p = startIdx; p < startIdx + nParams; p++)
168 GetParam(destIdx++)->Set(GetParam(p)->
Value());
174 WDL_PtrList<IParam> inParams, outParams;
176 for (
auto p = 0; p < NParams(); p++)
178 IParam* pParam = GetParam(p);
179 if(strcmp(pParam->
GetGroup(), inGroup) == 0)
181 inParams.Add(pParam);
183 else if(strcmp(pParam->
GetGroup(), outGroup) == 0)
185 outParams.Add(pParam);
189 assert(inParams.GetSize() == outParams.GetSize());
191 for (
auto p = 0; p < inParams.GetSize(); p++)
193 outParams.Get(p)->Set(inParams.Get(p)->Value());
199 for (
auto p = startIdx; p <= endIdx; p++)
201 func(p, * GetParam(p));
207 for (
auto p = 0; p < NParams(); p++)
209 IParam* pParam = GetParam(p);
210 if(strcmp(pParam->
GetGroup(), paramGroup) == 0)
219 DefaultParamValues(0, NParams()-1);
224 ForParamInRange(startIdx, endIdx, [](
int paramIdx,
IParam& param) {
231 ForParamInGroup(paramGroup, [](
int paramIdx,
IParam& param) {
238 RandomiseParamValues(0, NParams()-1);
243 ForParamInRange(startIdx, endIdx, [&](
int paramIdx,
IParam& param) { param.
SetNormalized( static_cast<float>(std::rand()/(static_cast<float>(RAND_MAX)+1.f)) ); });
248 ForParamInGroup(paramGroup, [&](
int paramIdx,
IParam& param) { param.
SetNormalized( static_cast<float>(std::rand()/(static_cast<float>(RAND_MAX)+1.f)) ); });
253 ForParamInRange(0, NParams()-1, [](
int paramIdx,
IParam& param) {
259 static IPreset* GetNextUninitializedPreset(WDL_PtrList<IPreset>* pPresets)
261 int n = pPresets->GetSize();
262 for (
int i = 0; i < n; ++i)
264 IPreset* pPreset = pPresets->Get(i);
265 if (!(pPreset->mInitialized))
275 for (
int i = 0; i < nPresets; ++i)
277 IPreset* pPreset = GetNextUninitializedPreset(&mPresets);
280 pPreset->mInitialized =
true;
281 strcpy(pPreset->mName, (name ? name :
"Empty"));
282 SerializeState(pPreset->mChunk);
289 IPreset* pPreset = GetNextUninitializedPreset(&mPresets);
292 pPreset->mInitialized =
true;
293 strcpy(pPreset->mName, name);
295 int i, n = NParams();
300 for (i = 0; i < n; ++i)
302 GET_PARAM_FROM_VARARG(GetParam(i)->
Type(), vp, v);
303 pPreset->mChunk.
Put(&v);
311 IPreset* pPreset = GetNextUninitializedPreset(&mPresets);
314 pPreset->mInitialized =
true;
315 strcpy(pPreset->mName, name);
317 int i = 0, n = NParams();
319 WDL_TypedBuf<double> vals;
321 double* pV = vals.Get();
322 for (i = 0; i < n; ++i, ++pV)
328 va_start(vp, nParamsNamed);
329 for (
int i = 0; i < nParamsNamed; ++i)
331 int paramIdx = (int) va_arg(vp,
int);
334 assert(paramIdx > kNoParameter && paramIdx < n);
335 GET_PARAM_FROM_VARARG(GetParam(paramIdx)->
Type(), vp, *(vals.Get() + paramIdx));
340 for (
int i = 0; i < n; ++i, ++pV)
342 if (*pV == PARAM_UNINIT)
344 *pV = GetParam(i)->Value();
346 pPreset->mChunk.Put(pV);
353 IPreset* pPreset = GetNextUninitializedPreset(&mPresets);
356 pPreset->mInitialized =
true;
357 strcpy(pPreset->mName, name);
366 presetChunk.
Resize(sizeOfChunk);
367 wdl_base64decode(blob, presetChunk.
GetData(), sizeOfChunk);
369 MakePresetFromChunk(name, presetChunk);
372 static void MakeDefaultUserPresetName(WDL_PtrList<IPreset>* pPresets,
char* str)
374 int nDefaultNames = 0;
375 int n = pPresets->GetSize();
376 for (
int i = 0; i < n; ++i)
378 IPreset* pPreset = pPresets->Get(i);
379 if (strstr(pPreset->mName, DEFAULT_USER_PRESET_NAME))
384 sprintf(str,
"%s %d", DEFAULT_USER_PRESET_NAME, nDefaultNames + 1);
390 MakeDefaultPreset(
"Empty", mPresets.GetSize());
397 while (i < mPresets.GetSize())
399 IPreset* pPreset = mPresets.Get(i);
400 if (pPreset->mInitialized)
406 mPresets.Delete(i,
true);
414 bool restoredOK =
false;
415 if (idx >= 0 && idx < mPresets.GetSize())
417 IPreset* pPreset = mPresets.Get(idx);
419 if (!(pPreset->mInitialized))
421 pPreset->mInitialized =
true;
422 MakeDefaultUserPresetName(&mPresets, pPreset->mName);
423 restoredOK = SerializeState(pPreset->mChunk);
427 restoredOK = (UnserializeState(pPreset->mChunk, 0) > 0);
432 mCurrentPresetIdx = idx;
442 if (CStringHasContents(name))
444 int n = mPresets.GetSize();
445 for (
int i = 0; i < n; ++i)
447 IPreset* pPreset = mPresets.Get(i);
448 if (!strcmp(pPreset->mName, name))
450 return RestorePreset(i);
459 if (idx >= 0 && idx < mPresets.GetSize())
461 return mPresets.Get(idx)->mName;
468 if (mCurrentPresetIdx >= 0 && mCurrentPresetIdx < mPresets.GetSize())
470 IPreset* pPreset = mPresets.Get(mCurrentPresetIdx);
471 pPreset->mChunk.
Clear();
473 Trace(TRACELOC,
"%d %s", mCurrentPresetIdx, pPreset->mName);
475 SerializeState(pPreset->mChunk);
477 if (CStringHasContents(name))
479 strcpy(pPreset->mName, name);
488 int n = mPresets.GetSize();
489 for (
int i = 0; i < n && savedOK; ++i)
491 IPreset* pPreset = mPresets.Get(i);
492 chunk.
PutStr(pPreset->mName);
494 Trace(TRACELOC,
"%d %s", i, pPreset->mName);
496 chunk.
Put(&pPreset->mInitialized);
497 if (pPreset->mInitialized)
499 savedOK &= (chunk.
PutChunk(&(pPreset->mChunk)) > 0);
509 int n = mPresets.GetSize(), pos = startPos;
510 for (
int i = 0; i < n && pos >= 0; ++i)
512 IPreset* pPreset = mPresets.Get(i);
513 pos = chunk.
GetStr(name, pos);
514 strcpy(pPreset->mName, name.Get());
516 Trace(TRACELOC,
"%d %s", i, pPreset->mName);
518 pos = chunk.
Get<
bool>(&(pPreset->mInitialized), pos);
519 if (pPreset->mInitialized)
521 pos = UnserializeState(chunk, pos);
524 pPreset->mChunk.
Clear();
525 SerializeState(pPreset->mChunk);
529 RestorePreset(mCurrentPresetIdx);
535 bool sDumped =
false;
539 int i, n = NParams();
540 FILE* fp = fopen(filename,
"a");
545 int idx = GetCurrentPresetIdx();
546 fprintf(fp,
"MakePreset(\"%s\"", GetPresetName(idx));
547 for (i = 0; i < n; ++i)
549 const IParam* pParam = GetParam(i);
551 switch (pParam->
Type())
553 case IParam::kTypeBool:
554 sprintf(paramVal,
"%s", (pParam->
Bool() ?
"true" :
"false"));
556 case IParam::kTypeInt:
557 sprintf(paramVal,
"%d", pParam->
Int());
559 case IParam::kTypeEnum:
560 sprintf(paramVal,
"%d", pParam->
Int());
562 case IParam::kTypeDouble:
564 sprintf(paramVal,
"%.6f", pParam->
Value());
567 fprintf(fp,
", %s", paramVal);
576 bool sDumped =
false;
581 int i, n = NParams();
582 FILE* fp = fopen(filename,
"a");
587 int idx = GetCurrentPresetIdx();
588 fprintf(fp,
" MakePresetFromNamedParams(\"%s\", %d", GetPresetName(idx), n);
589 for (i = 0; i < n; ++i)
591 const IParam* pParam = GetParam(i);
593 switch (pParam->
Type())
595 case IParam::kTypeBool:
596 sprintf(paramVal,
"%s", (pParam->
Bool() ?
"true" :
"false"));
598 case IParam::kTypeInt:
599 sprintf(paramVal,
"%d", pParam->
Int());
601 case IParam::kTypeEnum:
602 sprintf(paramVal,
"%d", pParam->
Int());
604 case IParam::kTypeDouble:
606 sprintf(paramVal,
"%.6f", pParam->
Value());
609 fprintf(fp,
",\n %s, %s", paramEnumNames[i], paramVal);
618 FILE* fp = fopen(filename,
"a");
623 int idx = GetCurrentPresetIdx();
624 fprintf(fp,
"MakePresetFromBlob(\"%s\", \"", GetPresetName(idx));
626 char buf[MAX_BLOB_LENGTH];
628 IByteChunk* pPresetChunk = &mPresets.
Get(mCurrentPresetIdx)->mChunk;
629 uint8_t* byteStart = pPresetChunk->
GetData();
631 wdl_base64encode(byteStart, buf, pPresetChunk->
Size());
633 fprintf(fp,
"%s\", %i);\n", buf, pPresetChunk->
Size());
643 if (CStringHasContents(file))
645 FILE* fp = fopen(file,
"wb");
649 int32_t chunkMagic = WDL_bswap32(
'CcnK');
650 int32_t byteSize = 0;
652 int32_t fxpVersion = WDL_bswap32(kFXPVersionNum);
653 int32_t pluginID = WDL_bswap32(GetUniqueID());
654 int32_t pluginVersion = WDL_bswap32(GetPluginVersion(
true));
655 int32_t numParams = WDL_bswap32(NParams());
657 memset(prgName, 0, 28);
658 strcpy(prgName, GetPresetName(GetCurrentPresetIdx()));
660 pgm.
Put(&chunkMagic);
662 if (DoesStateChunks())
667 fxpMagic = WDL_bswap32(
'FPCh');
670 SerializeState(state);
672 chunkSize = WDL_bswap32(state.
Size());
673 byteSize = WDL_bswap32(state.
Size() + 60);
677 pgm.
Put(&fxpVersion);
679 pgm.
Put(&pluginVersion);
687 fxpMagic = WDL_bswap32(
'FxCk');
691 pgm.
Put(&fxpVersion);
693 pgm.
Put(&pluginVersion);
697 for (
int i = 0; i< NParams(); i++)
700 v32.f = (float) GetParam(i)->GetNormalized();
701 unsigned int swapped = WDL_bswap32(v32.int32);
716 if (CStringHasContents(file))
718 FILE* fp = fopen(file,
"wb");
722 int32_t chunkMagic = WDL_bswap32(
'CcnK');
723 int32_t byteSize = 0;
725 int32_t fxbVersion = WDL_bswap32(kFXBVersionNum);
726 int32_t pluginID = WDL_bswap32(GetUniqueID());
727 int32_t pluginVersion = WDL_bswap32(GetPluginVersion(
true));
728 int32_t numPgms = WDL_bswap32(NPresets());
729 int32_t currentPgm = WDL_bswap32(GetCurrentPresetIdx());
731 memset(future, 0, 124);
733 bnk.
Put(&chunkMagic);
735 if (DoesStateChunks())
740 fxbMagic = WDL_bswap32(
'FBCh');
743 SerializePresets(state);
745 chunkSize = WDL_bswap32(state.
Size());
746 byteSize = WDL_bswap32(160 + state.
Size() );
750 bnk.
Put(&fxbVersion);
752 bnk.
Put(&pluginVersion);
754 bnk.
Put(¤tPgm);
762 fxbMagic = WDL_bswap32(
'FxBk');
766 bnk.
Put(&fxbVersion);
768 bnk.
Put(&pluginVersion);
770 bnk.
Put(¤tPgm);
773 int32_t fxpMagic = WDL_bswap32(
'FxCk');
774 int32_t fxpVersion = WDL_bswap32(kFXPVersionNum);
775 int32_t numParams = WDL_bswap32(NParams());
777 for (
int p = 0; p < NPresets(); p++)
779 IPreset* pPreset = mPresets.Get(p);
782 memset(prgName, 0, 28);
783 strcpy(prgName, pPreset->mName);
785 bnk.
Put(&chunkMagic);
789 bnk.
Put(&fxpVersion);
791 bnk.
Put(&pluginVersion);
797 for (
int i = 0; i< NParams(); i++)
800 pos = pPreset->mChunk.
Get(&v, pos);
803 v32.f = (float) GetParam(i)->ToNormalized(v);
804 uint32_t swapped = WDL_bswap32(v32.int32);
821 if (CStringHasContents(file))
823 FILE* fp = fopen(file,
"rb");
830 fseek(fp , 0 , SEEK_END);
831 fileSize = ftell(fp);
834 pgm.
Resize((
int) fileSize);
835 fread(pgm.
GetData(), fileSize, 1, fp);
842 int32_t byteSize = 0;
846 int32_t pluginVersion;
850 pos = pgm.
Get(&chunkMagic, pos);
851 chunkMagic = WDL_bswap_if_le(chunkMagic);
852 pos = pgm.
Get(&byteSize, pos);
853 byteSize = WDL_bswap_if_le(byteSize);
854 pos = pgm.
Get(&fxpMagic, pos);
855 fxpMagic = WDL_bswap_if_le(fxpMagic);
856 pos = pgm.
Get(&fxpVersion, pos);
857 fxpVersion = WDL_bswap_if_le(fxpVersion);
858 pos = pgm.
Get(&pluginID, pos);
859 pluginID = WDL_bswap_if_le(pluginID);
860 pos = pgm.
Get(&pluginVersion, pos);
861 pluginVersion = WDL_bswap_if_le(pluginVersion);
862 pos = pgm.
Get(&numParams, pos);
863 numParams = WDL_bswap_if_le(numParams);
864 pos = pgm.
GetBytes(prgName, 28, pos);
866 if (chunkMagic !=
'CcnK')
return false;
867 if (fxpVersion != kFXPVersionNum)
return false;
868 if (pluginID != GetUniqueID())
return false;
872 if (DoesStateChunks() && fxpMagic ==
'FPCh')
875 pos = pgm.
Get(&chunkSize, pos);
876 chunkSize = WDL_bswap_if_le(chunkSize);
879 UnserializeState(pgm, pos);
880 ModifyCurrentPreset(prgName);
881 RestorePreset(GetCurrentPresetIdx());
882 InformHostOfPresetChange();
886 else if (fxpMagic ==
'FxCk')
889 for (
int i = 0; i< NParams(); i++)
892 pos = pgm.
Get(&v32.int32, pos);
893 v32.int32 = WDL_bswap_if_le(v32.int32);
894 GetParam(i)->SetNormalized((
double) v32.f);
898 ModifyCurrentPreset(prgName);
899 RestorePreset(GetCurrentPresetIdx());
900 InformHostOfPresetChange();
912 if (CStringHasContents(file))
914 FILE* fp = fopen(file,
"rb");
921 fseek(fp , 0 , SEEK_END);
922 fileSize = ftell(fp);
925 bnk.
Resize((
int) fileSize);
926 fread(bnk.
GetData(), fileSize, 1, fp);
933 int32_t byteSize = 0;
937 int32_t pluginVersion;
941 memset(future, 0, 124);
943 pos = bnk.
Get(&chunkMagic, pos);
944 chunkMagic = WDL_bswap_if_le(chunkMagic);
945 pos = bnk.
Get(&byteSize, pos);
946 byteSize = WDL_bswap_if_le(byteSize);
947 pos = bnk.
Get(&fxbMagic, pos);
948 fxbMagic = WDL_bswap_if_le(fxbMagic);
949 pos = bnk.
Get(&fxbVersion, pos);
950 fxbVersion = WDL_bswap_if_le(fxbVersion);
951 pos = bnk.
Get(&pluginID, pos);
952 pluginID = WDL_bswap_if_le(pluginID);
953 pos = bnk.
Get(&pluginVersion, pos);
954 pluginVersion = WDL_bswap_if_le(pluginVersion);
955 pos = bnk.
Get(&numPgms, pos);
956 numPgms = WDL_bswap_if_le(numPgms);
957 pos = bnk.
Get(¤tPgm, pos);
958 currentPgm = WDL_bswap_if_le(currentPgm);
959 pos = bnk.
GetBytes(future, 124, pos);
961 if (chunkMagic !=
'CcnK')
return false;
963 if (pluginID != GetUniqueID())
return false;
967 if (DoesStateChunks() && fxbMagic ==
'FBCh')
970 pos = bnk.
Get(&chunkSize, pos);
971 chunkSize = WDL_bswap_if_le(chunkSize);
974 UnserializePresets(bnk, pos);
976 InformHostOfPresetChange();
979 else if (fxbMagic ==
'FxBk')
986 int32_t pluginVersion;
990 for(
int i = 0; i<numPgms; i++)
992 pos = bnk.
Get(&chunkMagic, pos);
993 chunkMagic = WDL_bswap_if_le(chunkMagic);
995 pos = bnk.
Get(&byteSize, pos);
996 byteSize = WDL_bswap_if_le(byteSize);
998 pos = bnk.
Get(&fxpMagic, pos);
999 fxpMagic = WDL_bswap_if_le(fxpMagic);
1001 pos = bnk.
Get(&fxpVersion, pos);
1002 fxpVersion = WDL_bswap_if_le(fxpVersion);
1004 pos = bnk.
Get(&pluginID, pos);
1005 pluginID = WDL_bswap_if_le(pluginID);
1007 pos = bnk.
Get(&pluginVersion, pos);
1008 pluginVersion = WDL_bswap_if_le(pluginVersion);
1010 pos = bnk.
Get(&numParams, pos);
1011 numParams = WDL_bswap_if_le(numParams);
1013 if (chunkMagic !=
'CcnK')
return false;
1014 if (fxpMagic !=
'FxCk')
return false;
1015 if (fxpVersion != kFXPVersionNum)
return false;
1016 if (numParams != NParams())
return false;
1018 pos = bnk.
GetBytes(prgName, 28, pos);
1023 for (
int j = 0; j< NParams(); j++)
1025 WDL_EndianFloat v32;
1026 pos = bnk.
Get(&v32.int32, pos);
1027 v32.int32 = WDL_bswap_if_le(v32.int32);
1028 GetParam(j)->SetNormalized((
double) v32.f);
1032 ModifyCurrentPreset(prgName);
1035 RestorePreset(currentPgm);
1036 InformHostOfPresetChange();
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...
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.
const char * GetPresetName(int idx) const
Get the name a preset.
const char * GetName() const
Returns the parameter's name.
void MakePreset(const char *name,...)
Create a baked-in factory preset, specifiying parameter values sequentially usage: MakePreset(name...
void PrintParamValues()
Default parameter values for a parameter group.
const char * GetArchStr() 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...
const char * GetAPIStr() const
void Set(double value)
Sets the parameter value.
void Clear()
Clears the chunk (resizes to 0)
void DumpMakePresetSrc(const char *file) const
Writes a call to MakePreset() for the current preset to a new text file.
void ForParamInGroup(const char *paramGroup, std::function< void(int paramIdx, IParam ¶m)> func)
Modify a parameter group simulataneously.
void MakePresetFromNamedParams(const char *name, int nParamsNamed,...)
Create a baked-in factory preset, specifiying parameter values with a list of parameter index and val...
int PutStr(const char *str)
Put a string into the IByteChunk.
IPlug's parameter class.
void GetHostVersionStr(WDL_String &str) const
Get the host version number as a string.
int Get(T *pDst, int startPos) const
Get arbitary typed data from the IByteChunk.
void PruneUninitializedPresets()
[AUV2 only] Removes any presets that weren't initialized
void RandomiseParamValues()
Randomise all parameters.
void GetPluginVersionStr(WDL_String &str) const
Gets the plug-in version as a string.
bool Bool() const
Returns the parameter's value as a boolean.
static int GetIPlugVerFromChunk(const IByteChunk &chunk, int &position)
Helper method to retrieve the IPlug version number from the beginning of the byte chunk...
Base struct for parameter shaping.
void EnsureDefaultPreset()
[VST2 only] Called to fill uninitialzed presets
void DumpPresetBlob(const char *file) const
Writes a call to MakePresetFromBlob() for the current preset to a new text file.
int Put(const T *pVal)
Copies arbitary typed data into the IByteChunk.
double Value() const
Gets a readable value of the parameter.
Manages a block of memory, for plug-in settings store/recall.
void DefaultParamValues()
Set all parameters to their default values.
int UnserializePresets(const IByteChunk &chunk, int startPos)
[VST2 only] Called when the VST2 host calls effSetChunk for a bank *
void MakePresetFromBlob(const char *name, const char *blob, int sizeOfChunk)
Creates a preset from a base64 encoded CString.
int UnserializeParams(const IByteChunk &chunk, int startPos)
Unserializes double precision floating point, non-normalised values from a byte chunk into mParams...
Base class that contains plug-in info and state manipulation methods.
A struct used for specifying baked-in factory presets.
std::function< void(double, WDL_String &)> DisplayFunc
DisplayFunc allows custom parameter display functions, defined by a lambda matching this signature...
void SetNormalized(double normalizedValue)
Sets the parameter value from a normalized range (usually coming from the linked IControl) ...
int GetHostVersion(bool decimal) const
Get the host version number as an integer.
int Size() const
Returns the current size of the chunk.
const char * GetGroup() const
Returns the parameter's group.
int Resize(int newSize)
Resizes the chunk.
static void GetVersionStr(int versionInteger, WDL_String &str)
Helper function to get the semantic version number as a string from an integer.
bool LoadPresetFromFXP(const char *file)
Load VST2 format preset.
int Int() const
Returns the parameter's value as an integer.
void ModifyCurrentPreset(const char *name=0)
This method should update the current preset with current values NOTE: This is only relevant for VST2...
bool LoadBankFromFXB(const char *file)
Load VST2 format bank [VST2 only].
void PrintDetails() const
Helper to print the parameter details to debug console in debug builds.
static void InitChunkWithIPlugVer(IByteChunk &chunk)
This method is used in order to place the IPlug version number in the chunk when serialising data...
bool SerializeParams(IByteChunk &chunk) const
Serializes the current double precision floating point, non-normalised values (IParam::mValue) of all...
EParamUnit
Used by AudioUnit plugins to determine the appearance of parameters, based on the kind of data they r...
bool RestorePreset(int idx)
Restore a preset by index.
static int GetDecimalVersion(int versionInteger)
Helper function to get the version number as a decimal integer.
void ForParamInRange(int startIdx, int endIdx, std::function< void(int paramIdx, IParam ¶m)> func)
Modify a range of parameters with a lamda function.
void MakePresetFromChunk(const char *name, IByteChunk &chunk)
Creates a preset from an IByteChunk containging serialized data.
bool SavePresetAsFXP(const char *file) const
Save current state as a VST2 format preset.
EParamType Type() const
Get the parameter's type.
void DumpMakePresetFromNamedParamsSrc(const char *file, const char *paramEnumNames[]) const
Writes a call to MakePresetFromNamedParams() for the current preset to a new text file...
int GetStr(WDL_String &str, int startPos) const
Get a string from the IByteChunk.
uint8_t * GetData()
Gets a ptr to the chunk data.
int PutChunk(const IByteChunk *pRHS)
Put another IByteChunk into this one.
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.
int PutBytes(const void *pSrc, int nBytesToCopy)
Copies data into the chunk, placing it at the end, resizing if nessecary.
int GetPluginVersion(bool decimal) const
Get the plug-in version number.
void CopyParamValues(int startIdx, int destIdx, int nParams)
Copy a range of parameter values.
int GetBytes(void *pDst, int nBytesToCopy, int startPos) const
Copy raw bytes from the IByteChunk, returning the new position for subsequent calls.
bool SerializePresets(IByteChunk &chunk) const
[VST2 only] Called when the VST2 host calls effGetChunk for a bank *
bool SaveBankAsFXB(const char *file) const
Save current bank as a VST2 format bank [VST2 only].
void SetToDefault()
Replaces the parameter's current value with the default one.