Audio plugin host https://kx.studio/carla
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.

173 lines
5.5KB

  1. /*
  2. * Carla Tests
  3. * Copyright (C) 2014 Filipe Coelho <falktx@falktx.com>
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU General Public License as
  7. * published by the Free Software Foundation; either version 2 of
  8. * the License, or any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * For a full copy of the GNU General Public License see the doc/GPL.txt file.
  16. */
  17. #include "CarlaLibUtils.hpp"
  18. // -----------------------------------------------------------------------
  19. typedef void (*Fn_RWDEFCloseDevice)();
  20. typedef void (*Fn_RWDEFDriveAudio)(void* ins, void* outs);
  21. typedef void (*Fn_RWDEFGetDeviceInfo)(void* info);
  22. typedef void (*Fn_RWDEFGetDeviceNameAndVersion)(long* version, char* name);
  23. typedef void (*Fn_RWDEFGetEventBusInfo)(ushort index, void* info);
  24. typedef void (*Fn_RWDEFGetEventChannelInfo)(void* v1, void* v2);
  25. typedef void (*Fn_RWDEFGetEventControllerInfo)(void* v1, ushort index, void* v2);
  26. typedef void (*Fn_RWDEFGetEventInfo)(void* info);
  27. typedef void (*Fn_RWDEFGetEventNoteInfo)(void* v1, ushort index, void* v2);
  28. typedef void (*Fn_RWDEFIdle)();
  29. typedef char (*Fn_RWDEFIsCloseOK)();
  30. typedef char (*Fn_RWDEFIsPanelAppLaunched)();
  31. typedef int (*Fn_RWDEFLaunchPanelApp)();
  32. typedef int (*Fn_RWDEFOpenDevice)(void* info);
  33. typedef int (*Fn_RWDEFQuitPanelApp)();
  34. typedef void (*Fn_RWDEFSetAudioInfo)(void* info);
  35. // -----------------------------------------------------------------------------
  36. struct RewireBridge {
  37. void* lib;
  38. Fn_RWDEFCloseDevice RWDEFCloseDevice;
  39. Fn_RWDEFDriveAudio RWDEFDriveAudio;
  40. Fn_RWDEFGetDeviceInfo RWDEFGetDeviceInfo;
  41. Fn_RWDEFGetDeviceNameAndVersion RWDEFGetDeviceNameAndVersion;
  42. Fn_RWDEFGetEventBusInfo RWDEFGetEventBusInfo;
  43. Fn_RWDEFGetEventChannelInfo RWDEFGetEventChannelInfo;
  44. Fn_RWDEFGetEventControllerInfo RWDEFGetEventControllerInfo;
  45. Fn_RWDEFGetEventInfo RWDEFGetEventInfo;
  46. Fn_RWDEFGetEventNoteInfo RWDEFGetEventNoteInfo;
  47. Fn_RWDEFIdle RWDEFIdle;
  48. Fn_RWDEFIsCloseOK RWDEFIsCloseOK;
  49. Fn_RWDEFIsPanelAppLaunched RWDEFIsPanelAppLaunched;
  50. Fn_RWDEFLaunchPanelApp RWDEFLaunchPanelApp;
  51. Fn_RWDEFOpenDevice RWDEFOpenDevice;
  52. Fn_RWDEFQuitPanelApp RWDEFQuitPanelApp;
  53. Fn_RWDEFSetAudioInfo RWDEFSetAudioInfo;
  54. RewireBridge(const char* const filename)
  55. : lib(nullptr),
  56. RWDEFCloseDevice(nullptr),
  57. RWDEFDriveAudio(nullptr),
  58. RWDEFGetDeviceInfo(nullptr),
  59. RWDEFGetDeviceNameAndVersion(nullptr),
  60. RWDEFGetEventBusInfo(nullptr),
  61. RWDEFGetEventChannelInfo(nullptr),
  62. RWDEFGetEventControllerInfo(nullptr),
  63. RWDEFGetEventInfo(nullptr),
  64. RWDEFGetEventNoteInfo(nullptr),
  65. RWDEFIdle(nullptr),
  66. RWDEFIsCloseOK(nullptr),
  67. RWDEFIsPanelAppLaunched(nullptr),
  68. RWDEFLaunchPanelApp(nullptr),
  69. RWDEFOpenDevice(nullptr),
  70. RWDEFQuitPanelApp(nullptr),
  71. RWDEFSetAudioInfo(nullptr)
  72. {
  73. lib = lib_open(filename);
  74. if (lib == nullptr)
  75. {
  76. fprintf(stderr, "Failed to load DLL, reason:\n%s\n", lib_error(filename));
  77. return;
  78. }
  79. else
  80. {
  81. fprintf(stdout, "loaded sucessfully!\n");
  82. }
  83. #define JOIN(a, b) a ## b
  84. #define LIB_SYMBOL(NAME) NAME = (Fn_##NAME)lib_symbol(lib, #NAME);
  85. LIB_SYMBOL(RWDEFCloseDevice)
  86. LIB_SYMBOL(RWDEFDriveAudio)
  87. LIB_SYMBOL(RWDEFGetDeviceInfo)
  88. LIB_SYMBOL(RWDEFGetDeviceNameAndVersion)
  89. LIB_SYMBOL(RWDEFGetEventBusInfo)
  90. LIB_SYMBOL(RWDEFGetEventChannelInfo)
  91. LIB_SYMBOL(RWDEFGetEventControllerInfo)
  92. LIB_SYMBOL(RWDEFGetEventInfo)
  93. LIB_SYMBOL(RWDEFGetEventNoteInfo)
  94. LIB_SYMBOL(RWDEFIdle)
  95. LIB_SYMBOL(RWDEFIsCloseOK)
  96. LIB_SYMBOL(RWDEFIsPanelAppLaunched)
  97. LIB_SYMBOL(RWDEFLaunchPanelApp)
  98. LIB_SYMBOL(RWDEFOpenDevice)
  99. LIB_SYMBOL(RWDEFQuitPanelApp)
  100. LIB_SYMBOL(RWDEFSetAudioInfo)
  101. #undef JOIN
  102. #undef LIB_SYMBOL
  103. }
  104. ~RewireBridge()
  105. {
  106. if (lib != nullptr)
  107. {
  108. lib_close(lib);
  109. lib = nullptr;
  110. }
  111. }
  112. };
  113. // -----------------------------------------------------------------------
  114. int main(/*int argc, char* argv[]*/)
  115. {
  116. //static const char* const filename = "C:\\Program Files\\Waves\\ReWire\\WavesReWireDevice.dll";
  117. static const char* const filename = "C:\\Program Files\\AudioGL\\AudioGL.dll";
  118. RewireBridge bridge(filename);
  119. struct OpenInfo {
  120. ulong size1; // ??
  121. ulong size2; // 12
  122. long sampleRate;
  123. long bufferSize;
  124. };
  125. OpenInfo info;
  126. info.size1 = sizeof(OpenInfo);
  127. info.size2 = 12;
  128. info.sampleRate = 44100;
  129. info.bufferSize = 512;
  130. (bridge.RWDEFOpenDevice)(&info);
  131. long version;
  132. char name[256];
  133. carla_zeroChar(name, 256);
  134. (bridge.RWDEFGetDeviceNameAndVersion)(&version, name);
  135. carla_stdout("Ok, this is the info:");
  136. carla_stdout("\tVersion: %i", version);
  137. carla_stdout("\tName: \"%s\"", name);
  138. carla_stdout("Starting panel...");
  139. (bridge.RWDEFLaunchPanelApp)();
  140. for (int i=0; i<500; ++i)
  141. //for (; (bridge.RWDEFIsPanelAppLaunched)() != 0;)
  142. {
  143. (bridge.RWDEFIdle)();
  144. carla_msleep(20);
  145. }
  146. (bridge.RWDEFQuitPanelApp)();
  147. (bridge.RWDEFCloseDevice)();
  148. return 0;
  149. }