diff --git a/other/vst2_debug_host/makefile.linux b/other/vst2_debug_host/makefile.linux new file mode 100644 index 00000000..b1d0be67 --- /dev/null +++ b/other/vst2_debug_host/makefile.linux @@ -0,0 +1,14 @@ + +include ../../dep/yac/install_linux.mk + +.cpp.o: + $(CPP) $(CPPFLAGS) $(OPTFLAGS_PLUGIN) -I"$(VSVR_BASE_DIR)/dep/yac/" -I"$(VST2_SDK_DIR)" -c "$<" -o"$@" + +.PHONY: bin +bin: vst2_debug_host.o + $(CPP) -o vst2_debug_host vst2_debug_host.o -ldl + +.PHONY: clean +clean: + rm -f vst2_debug_host vst2_debug_host.o + diff --git a/other/vst2_debug_host/vst2_debug_host b/other/vst2_debug_host/vst2_debug_host new file mode 100644 index 00000000..2e39ae53 Binary files /dev/null and b/other/vst2_debug_host/vst2_debug_host differ diff --git a/other/vst2_debug_host/vst2_debug_host.cpp b/other/vst2_debug_host/vst2_debug_host.cpp new file mode 100644 index 00000000..84cfcb36 --- /dev/null +++ b/other/vst2_debug_host/vst2_debug_host.cpp @@ -0,0 +1,117 @@ +// vst_eureka_standalone_test.cpp : Defines the entry point for the console application. +// + +#define DLL_PATH "../../vst2_bin/veeseevstrack_effect.dll" +#define SO_PATH "../../vst2_bin/veeseevstrack_effect.so" + + +#include + +#ifdef YAC_WIN32 +#include "stdafx.h" +#include +#else +#include +#endif + +#include +#include + +typedef AEffect* (*PluginEntryProc) (audioMasterCallback audioMaster); + + +static VstIntPtr VSTCALLBACK HostCallback(AEffect* effect, VstInt32 opcode, VstInt32 index, VstIntPtr value, void* ptr, float opt) { + static VstInt32 lastOpcode = -1; + static VstIntPtr lastTimeMask = ~0; + VstIntPtr result = 0; + + lastOpcode = opcode; + + (void)lastOpcode; + (void)lastTimeMask; + + return result; +} + +float *inputBuffers[48]; +float *outputBuffers[48]; + +void open_and_close(void) { +#ifdef YAC_WIN32 + HINSTANCE dllHandle = ::LoadLibraryA(DLL_PATH); +#else + void *dllHandle = ::dlopen(SO_PATH, RTLD_NOW); + if(NULL == dllHandle) + { + printf("Failed to load library %s: %s", SO_PATH, dlerror()); + return; + } +#endif + + for(int i = 0; i < 48; i++) + { + inputBuffers[i] = new float[4096]; + outputBuffers[i] = new float[4096]; + } + + if(NULL != dllHandle) + { +#ifdef YAC_WIN32 + PluginEntryProc mainProc = (PluginEntryProc) ::GetProcAddress((HMODULE)dllHandle, "VSTPluginMain"); + if(NULL == mainProc) + { + mainProc = (PluginEntryProc) ::GetProcAddress((HMODULE)dllHandle, "main"); + } +#else + PluginEntryProc mainProc = (PluginEntryProc) ::dlsym(dllHandle, "VSTPluginMain"); + if(NULL == mainProc) + { + mainProc = (PluginEntryProc) ::dlsym(dllHandle, "main"); + } +#endif + + if(NULL != mainProc) + { + AEffect *effect; + effect = mainProc(HostCallback); + + if(NULL != effect) + { + effect->dispatcher(effect, effOpen, 0, 0, NULL, 0.0f); + VstIntPtr ip = effect->dispatcher(effect, effEditOpen, 0, 0, NULL/*hWnd*/, 0.0f); + (void)ip; + printf("xxx call processreplacing\n"); + for(int i = 0; i < 1024; i++) + { + effect->processReplacing(effect, inputBuffers, outputBuffers, (VstInt32)64); + } + effect->dispatcher(effect, effEditClose, 0, 0, NULL, 0.0f); + effect->dispatcher(effect, effClose, 0, 0, NULL, 0.0f); + } + } + else + { + printf("[---] failed to find mainProc\n"); + } + +#ifdef YAC_WIN32 + ::FreeLibrary(dllHandle); +#else + ::dlclose(dllHandle); +#endif + } + + for(int i = 0; i < 48; i++) + { + delete [] inputBuffers[i]; + delete [] outputBuffers[i]; + } +} + + int main() { + for(;;) + { + open_and_close(); + } + return 0; +}