You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

122 lines
2.9KB

  1. // vst_eureka_standalone_test.cpp : Defines the entry point for the console application.
  2. //
  3. #define DLL_PATH "../../vst2_bin/veeseevstrack_effect.dll"
  4. #define SO_PATH "../../vst2_bin/veeseevstrack_effect.so"
  5. #include <yac.h>
  6. #ifdef YAC_WIN32
  7. #include "stdafx.h"
  8. #include <windows.h>
  9. #else
  10. #include <dlfcn.h>
  11. #endif
  12. #include <aeffect.h>
  13. #include <aeffectx.h>
  14. typedef AEffect* (*PluginEntryProc) (audioMasterCallback audioMaster);
  15. static VstIntPtr VSTCALLBACK HostCallback(AEffect* effect, VstInt32 opcode, VstInt32 index, VstIntPtr value, void* ptr, float opt) {
  16. static VstInt32 lastOpcode = -1;
  17. static VstIntPtr lastTimeMask = ~0;
  18. VstIntPtr result = 0;
  19. lastOpcode = opcode;
  20. (void)lastOpcode;
  21. (void)lastTimeMask;
  22. return result;
  23. }
  24. float *inputBuffers[48];
  25. float *outputBuffers[48];
  26. void open_and_close(void) {
  27. #ifdef YAC_WIN32
  28. HINSTANCE dllHandle = ::LoadLibraryA(DLL_PATH);
  29. #else
  30. void *dllHandle = ::dlopen(SO_PATH, RTLD_NOW);
  31. if(NULL == dllHandle)
  32. {
  33. printf("Failed to load library %s: %s", SO_PATH, dlerror());
  34. return;
  35. }
  36. #endif
  37. for(int i = 0; i < 48; i++)
  38. {
  39. inputBuffers[i] = new float[4096];
  40. outputBuffers[i] = new float[4096];
  41. }
  42. if(NULL != dllHandle)
  43. {
  44. #ifdef YAC_WIN32
  45. PluginEntryProc mainProc = (PluginEntryProc) ::GetProcAddress((HMODULE)dllHandle, "VSTPluginMain");
  46. if(NULL == mainProc)
  47. {
  48. mainProc = (PluginEntryProc) ::GetProcAddress((HMODULE)dllHandle, "main");
  49. }
  50. #else
  51. PluginEntryProc mainProc = (PluginEntryProc) ::dlsym(dllHandle, "VSTPluginMain");
  52. if(NULL == mainProc)
  53. {
  54. mainProc = (PluginEntryProc) ::dlsym(dllHandle, "main");
  55. }
  56. #endif
  57. if(NULL != mainProc)
  58. {
  59. AEffect *effect;
  60. printf("xxx calling mainProc\n");
  61. effect = mainProc(HostCallback);
  62. printf("xxx mainProc returned effect=%p\n", effect);
  63. if(NULL != effect)
  64. {
  65. printf("xxx calling effect->dispatcher<effOpen>\n");
  66. effect->dispatcher(effect, effOpen, 0, 0, NULL, 0.0f);
  67. printf("xxx effect->dispatcher<effOpen> returned\n");
  68. VstIntPtr ip = effect->dispatcher(effect, effEditOpen, 0, 0, NULL/*hWnd*/, 0.0f);
  69. (void)ip;
  70. printf("xxx call processreplacing\n");
  71. for(int i = 0; i < 1024; i++)
  72. {
  73. effect->processReplacing(effect, inputBuffers, outputBuffers, (VstInt32)64);
  74. }
  75. effect->dispatcher(effect, effEditClose, 0, 0, NULL, 0.0f);
  76. effect->dispatcher(effect, effClose, 0, 0, NULL, 0.0f);
  77. }
  78. }
  79. else
  80. {
  81. printf("[---] failed to find mainProc\n");
  82. }
  83. #ifdef YAC_WIN32
  84. ::FreeLibrary(dllHandle);
  85. #else
  86. ::dlclose(dllHandle);
  87. #endif
  88. }
  89. for(int i = 0; i < 48; i++)
  90. {
  91. delete [] inputBuffers[i];
  92. delete [] outputBuffers[i];
  93. }
  94. }
  95. int main() {
  96. for(;;)
  97. {
  98. open_and_close();
  99. }
  100. return 0;
  101. }