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.

118 lines
3.6KB

  1. /*
  2. * Carla Native Plugins
  3. * Copyright (C) 2013-2020 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 "carla-vst.hpp"
  18. #include "ui_launcher.cpp"
  19. #include "ui_launcher_res.cpp"
  20. #include <cstring>
  21. #ifdef __WINE__
  22. __cdecl static intptr_t cvst_dispatcherCallback(AEffect* effect, int32_t opcode, int32_t index, intptr_t value, void* ptr, float opt)
  23. {
  24. return vst_dispatcherCallback(effect, opcode, index, value, ptr, opt);
  25. }
  26. __cdecl static float cvst_getParameterCallback(AEffect* effect, int32_t index)
  27. {
  28. return vst_getParameterCallback(effect, index);
  29. }
  30. __cdecl static void cvst_setParameterCallback(AEffect* effect, int32_t index, float value)
  31. {
  32. return vst_setParameterCallback(effect, index, value);
  33. }
  34. __cdecl static void cvst_processCallback(AEffect* effect, float** inputs, float** outputs, int32_t sampleFrames)
  35. {
  36. return vst_processCallback(effect, inputs, outputs, sampleFrames);
  37. }
  38. __cdecl static void cvst_processReplacingCallback(AEffect* effect, float** inputs, float** outputs, int32_t sampleFrames)
  39. {
  40. return vst_processReplacingCallback(effect, inputs, outputs, sampleFrames);
  41. }
  42. #endif
  43. CARLA_EXPORT __cdecl
  44. const AEffect* VSTPluginMain(audioMasterCallback audioMaster);
  45. CARLA_EXPORT __cdecl
  46. const AEffect* VSTPluginMain(audioMasterCallback audioMaster)
  47. {
  48. // old version
  49. if (audioMaster(nullptr, audioMasterVersion, 0, 0, nullptr, 0.0f) == 0)
  50. return nullptr;
  51. AEffect* const effect(new AEffect);
  52. std::memset(effect, 0, sizeof(AEffect));
  53. // vst fields
  54. effect->magic = kEffectMagic;
  55. effect->version = CARLA_VERSION_HEX;
  56. // pointers
  57. VstObject* const obj(new VstObject());
  58. obj->audioMaster = (void*)audioMaster;
  59. obj->plugin = nullptr;
  60. effect->object = obj;
  61. // static calls
  62. #ifdef __WINE__
  63. effect->dispatcher = cvst_dispatcherCallback;
  64. effect->getParameter = cvst_getParameterCallback;
  65. effect->setParameter = cvst_setParameterCallback;
  66. effect->process = cvst_processCallback;
  67. effect->processReplacing = cvst_processReplacingCallback;
  68. #else
  69. effect->dispatcher = vst_dispatcherCallback;
  70. effect->process = vst_processCallback;
  71. effect->getParameter = vst_getParameterCallback;
  72. effect->setParameter = vst_setParameterCallback;
  73. effect->processReplacing = vst_processReplacingCallback;
  74. #endif
  75. return VSTPluginMainInit(effect);
  76. }
  77. #if ! (defined(CARLA_OS_MAC) || defined(CARLA_OS_WIN))
  78. CARLA_EXPORT __cdecl
  79. const AEffect* VSTPluginMain_asm(audioMasterCallback audioMaster) asm ("main");
  80. CARLA_EXPORT __cdecl
  81. const AEffect* VSTPluginMain_asm(audioMasterCallback audioMaster)
  82. {
  83. return VSTPluginMain(audioMaster);
  84. }
  85. #endif
  86. intptr_t VSTAudioMaster(AEffect* effect, int32_t opcode, int32_t index, intptr_t value, void* ptr, float opt)
  87. {
  88. const audioMasterCallback audioMaster = (audioMasterCallback)((VstObject*)effect->object)->audioMaster;
  89. return audioMaster(effect, opcode, index, value, ptr, opt);
  90. }
  91. bool isUsingUILauncher()
  92. {
  93. #ifdef CARLA_OS_LINUX
  94. return false;
  95. #else
  96. return true;
  97. #endif
  98. }