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.

118 lines
2.7KB

  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. effect = mainProc(HostCallback);
  61. if(NULL != effect)
  62. {
  63. effect->dispatcher(effect, effOpen, 0, 0, NULL, 0.0f);
  64. VstIntPtr ip = effect->dispatcher(effect, effEditOpen, 0, 0, NULL/*hWnd*/, 0.0f);
  65. (void)ip;
  66. printf("xxx call processreplacing\n");
  67. for(int i = 0; i < 1024; i++)
  68. {
  69. effect->processReplacing(effect, inputBuffers, outputBuffers, (VstInt32)64);
  70. }
  71. effect->dispatcher(effect, effEditClose, 0, 0, NULL, 0.0f);
  72. effect->dispatcher(effect, effClose, 0, 0, NULL, 0.0f);
  73. }
  74. }
  75. else
  76. {
  77. printf("[---] failed to find mainProc\n");
  78. }
  79. #ifdef YAC_WIN32
  80. ::FreeLibrary(dllHandle);
  81. #else
  82. ::dlclose(dllHandle);
  83. #endif
  84. }
  85. for(int i = 0; i < 48; i++)
  86. {
  87. delete [] inputBuffers[i];
  88. delete [] outputBuffers[i];
  89. }
  90. }
  91. int main() {
  92. for(;;)
  93. {
  94. open_and_close();
  95. }
  96. return 0;
  97. }