25#if defined OS_WIN && !defined VST3C_API
26 HINSTANCE gHINSTANCE = 0;
27 #if defined(VST2_API) || defined(AAX_API) || defined(CLAP_API)
31 BOOL WINAPI DllMain(HINSTANCE hDllInst, DWORD fdwReason, LPVOID res)
33 gHINSTANCE = hDllInst;
38 UINT(WINAPI *__GetDpiForWindow)(HWND);
40 float GetScaleForHWND(HWND hWnd)
42 if (!__GetDpiForWindow)
44 HINSTANCE h = LoadLibraryW(L
"user32.dll");
45 if (h) *(
void **)&__GetDpiForWindow = GetProcAddress(h,
"GetDpiForWindow");
47 if (!__GetDpiForWindow)
51 int dpi = __GetDpiForWindow(hWnd);
53 if (dpi != USER_DEFAULT_SCREEN_DPI)
55#if defined IGRAPHICS_QUANTISE_SCREENSCALE
56 return std::round(
static_cast<float>(dpi) / USER_DEFAULT_SCREEN_DPI);
58 return static_cast<float>(dpi) / USER_DEFAULT_SCREEN_DPI;
67#pragma mark - ** Global Functions and Defines **
73 EXPORT
void* VSTPluginMain(audioMasterCallback hostCallback)
75 using namespace iplug;
77 IPlugVST2* pPlug = iplug::MakePlug(iplug::InstanceInfo{hostCallback});
81 AEffect& aEffect = pPlug->GetAEffect();
83 aEffect.numPrograms = std::max(aEffect.numPrograms, 1);
89 EXPORT
int main(
int hostCallback)
92 return (VstIntPtr) VSTPluginMain((audioMasterCallback)hostCallback);
94 return (
int) VSTPluginMain((audioMasterCallback)hostCallback);
98#pragma mark - VST3 (All)
99#elif defined VST3_API || VST3C_API || defined VST3P_API
100 #include "public.sdk/source/main/pluginfactory.h"
101 #include "pluginterfaces/vst/ivstcomponent.h"
102 #include "pluginterfaces/vst/ivsteditcontroller.h"
104#if !defined VST3_PROCESSOR_UID && !defined VST3_CONTROLLER_UID
105#define VST3_PROCESSOR_UID 0xF2AEE70D, 0x00DE4F4E, PLUG_MFR_ID, PLUG_UNIQUE_ID
106#define VST3_CONTROLLER_UID 0xF2AEE70E, 0x00DE4F4F, PLUG_MFR_ID, PLUG_UNIQUE_ID
109 #ifndef EFFECT_TYPE_VST3
111 #define EFFECT_TYPE_VST3 kInstrumentSynth
113 #define EFFECT_TYPE_VST3 kFx
117 #if defined VST3P_API || defined VST3_API
121 extern void* moduleHandle;
122 gHINSTANCE = (HINSTANCE) moduleHandle;
135 static Steinberg::FUnknown* createInstance(
void*)
137 return (Steinberg::Vst::IAudioProcessor*) iplug::MakePlug(iplug::InstanceInfo());
140 BEGIN_FACTORY_DEF(PLUG_MFR, PLUG_URL_STR, PLUG_EMAIL_STR)
142 DEF_CLASS2(INLINE_UID_FROM_FUID(FUID(VST3_PROCESSOR_UID)),
143 Steinberg::PClassInfo::kManyInstances,
144 kVstAudioEffectClass,
146 Steinberg::Vst::kSimpleModeSupported,
153 #pragma mark - VST3 Processor
154 #elif defined VST3P_API
155 static Steinberg::FUnknown* createProcessorInstance(
void*)
157 return MakeProcessor();
160 static Steinberg::FUnknown* createControllerInstance(
void*)
162 return MakeController();
165 BEGIN_FACTORY_DEF(PLUG_MFR, PLUG_URL_STR, PLUG_EMAIL_STR)
167 DEF_CLASS2 (INLINE_UID_FROM_FUID(FUID(VST3_PROCESSOR_UID)),
168 PClassInfo::kManyInstances,
169 kVstAudioEffectClass,
175 createProcessorInstance)
177 DEF_CLASS2(INLINE_UID_FROM_FUID(FUID(VST3_CONTROLLER_UID)),
178 PClassInfo::kManyInstances,
179 kVstComponentControllerClass,
180 PLUG_NAME
" Controller",
185 createControllerInstance)
193 #ifndef AU_NO_COMPONENT_ENTRY
195 EXPORT ComponentResult AUV2_ENTRY(ComponentParameters* pParams,
void* pPlug)
197 return iplug::IPlugAU::IPlugAUEntry(pParams, pPlug);
202 EXPORT
void* AUV2_FACTORY(
const AudioComponentDescription* pInDesc)
204 return iplug::IPlugAUFactory<PLUG_CLASS_NAME, PLUG_DOES_MIDI_IN>::Factory(pInDesc);
211 EMSCRIPTEN_KEEPALIVE
void* createModule()
213 Processor* pWAM =
dynamic_cast<Processor*
>(iplug::MakePlug(iplug::InstanceInfo()));
221 std::unique_ptr<iplug::IPlugWeb> gPlug;
222 extern void StartMainLoopTimer();
226 EMSCRIPTEN_KEEPALIVE
void iplug_syncfs()
229 if(Module.syncdone == 1) {
231 FS.syncfs(false, function (err) {
233 console.log(
"Synced to IDBFS...");
240 EMSCRIPTEN_KEEPALIVE
void iplug_fsready()
242 gPlug = std::unique_ptr<iplug::IPlugWeb>(iplug::MakePlug(iplug::InstanceInfo()));
243 gPlug->SetHost(
"www", 0);
244 gPlug->OpenWindow(
nullptr);
253 var name =
'/' + UTF8ToString($0) +
'_data';
255 FS.mount(IDBFS, {}, name);
258 FS.syncfs(
true, function (err) {
260 console.log(
"Synced from IDBFS...");
262 ccall(
'iplug_fsready',
'v');
266 StartMainLoopTimer();
275#elif defined CLAP_API
279#ifndef CLAP_MANUAL_URL
280#define CLAP_MANUAL_URL ""
282#ifndef CLAP_SUPPORT_URL
283#define CLAP_SUPPORT_URL ""
285#ifndef CLAP_DESCRIPTION
286#define CLAP_DESCRIPTION ""
290 #define CLAP_FEATURES CLAP_PLUGIN_FEATURE_AUDIO_EFFECT
292 #define CLAP_FEATURES CLAP_PLUGIN_FEATURE_INSTRUMENT
294 #define CLAP_FEATURES CLAP_PLUGIN_FEATURE_NOTE_EFFECT
298std::string gPluginPath;
299std::unique_ptr<clap_plugin_descriptor> gPluginDesc;
301static bool clap_init(
const char* pluginPath)
305 gPluginPath = pluginPath;
306 gPluginDesc = std::unique_ptr<clap_plugin_descriptor>(
new clap_plugin_descriptor());
310 gPluginDesc->clap_version = CLAP_VERSION;
312 gPluginDesc->id = BUNDLE_DOMAIN
"." BUNDLE_MFR
"." BUNDLE_NAME;
313 gPluginDesc->name = PLUG_NAME;
314 gPluginDesc->vendor = PLUG_MFR;
315 gPluginDesc->url = PLUG_URL_STR;
317 gPluginDesc->manual_url = CLAP_MANUAL_URL;
318 gPluginDesc->version = PLUG_VERSION_STR;
319 gPluginDesc->support_url = CLAP_SUPPORT_URL;
320 gPluginDesc->description = CLAP_DESCRIPTION;
322 static const char *clap_features[] = { CLAP_FEATURES, NULL };
323 gPluginDesc->features = clap_features;
328static void clap_deinit(
void)
331 gPluginDesc =
nullptr;
334static uint32_t clap_get_plugin_count(
const clap_plugin_factory_t *factory)
339static const clap_plugin_descriptor* clap_get_plugin_descriptor(
const clap_plugin_factory_t *factory, uint32_t index)
342 return gPluginDesc.get();
347static const clap_plugin* clap_create_plugin(
const clap_plugin_factory_t *factory,
const clap_host* host,
const char* plugin_id)
349 if (!strcmp(gPluginDesc->id, plugin_id))
351 IPlugCLAP* pPlug = MakePlug(InstanceInfo{gPluginDesc.get(), host});
352 return pPlug->clapPlugin();
358CLAP_EXPORT
const clap_plugin_factory_t clap_factory = {
359 clap_get_plugin_count,
360 clap_get_plugin_descriptor,
364const void *clap_get_factory(
const char *factory_id)
366 if (!::strcmp(factory_id, CLAP_PLUGIN_FACTORY_ID))
367 return &clap_factory;
372CLAP_EXPORT
const clap_plugin_entry_t clap_entry = {
379#elif defined AUv3_API || defined AAX_API || defined APP_API
382 #error "No API defined!"
385#pragma mark - ** Instantiation **
390#pragma mark VST2, VST3, AAX, AUv3, APP, WAM, WEB, CLAP
392#if defined VST2_API || defined VST3_API || defined AAX_API || defined AUv3_API || defined APP_API || defined WAM_API || defined WEB_API || defined CLAP_API
394Plugin* MakePlug(
const iplug::InstanceInfo& info)
397 static WDL_Mutex sMutex;
398 WDL_MutexLock lock(&sMutex);
400 return new PLUG_CLASS_NAME(info);
406Plugin* MakePlug(
void* pMemory)
408 iplug::InstanceInfo info;
409 info.mCocoaViewFactoryClassName.Set(AUV2_VIEW_CLASS_STR);
412 return new(pMemory) PLUG_CLASS_NAME(info);
414 return new PLUG_CLASS_NAME(info);
417#pragma mark - VST3 Controller
418#elif defined VST3C_API
420Steinberg::FUnknown* MakeController()
422 static WDL_Mutex sMutex;
423 WDL_MutexLock lock(&sMutex);
424 iplug::IPlugVST3Controller::InstanceInfo info;
425 info.mOtherGUID = Steinberg::FUID(VST3_PROCESSOR_UID);
429 return static_cast<Steinberg::Vst::IEditController*
>(
new PLUG_CLASS_NAME(info));
432#pragma mark - VST3 Processor
433#elif defined VST3P_API
435Steinberg::FUnknown* MakeProcessor()
437 static WDL_Mutex sMutex;
438 WDL_MutexLock lock(&sMutex);
439 iplug::IPlugVST3Processor::InstanceInfo info;
440 info.mOtherGUID = Steinberg::FUID(VST3_CONTROLLER_UID);
441 return static_cast<Steinberg::Vst::IAudioProcessor*
>(
new PLUG_CLASS_NAME(info));
444#error "No API defined!"
447#pragma mark - ** Config Utility **
449static Config MakeConfig(
int nParams,
int nPresets)
451 return Config(nParams, nPresets, PLUG_CHANNEL_IO, PLUG_NAME, PLUG_NAME, PLUG_MFR, PLUG_VERSION_HEX, PLUG_UNIQUE_ID, PLUG_MFR_ID, PLUG_LATENCY, PLUG_DOES_MIDI_IN, PLUG_DOES_MIDI_OUT, PLUG_DOES_MPE, PLUG_DOES_STATE_CHUNKS, PLUG_TYPE, PLUG_HAS_UI, PLUG_WIDTH, PLUG_HEIGHT, PLUG_HOST_RESIZE, PLUG_MIN_WIDTH, PLUG_MAX_WIDTH, PLUG_MIN_HEIGHT, PLUG_MAX_HEIGHT, BUNDLE_ID, APP_GROUP_ID);
469#if !defined NO_IGRAPHICS && !defined VST3P_API
470#include "IGraphics_include_in_plug_src.h"
CLAP API base class for an IPlug plug-in.
VST2.4 API base class for an IPlug plug-in.
void EnsureDefaultPreset()
[VST2 only] Called to fill uninitialzed presets