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.

104 lines
3.4KB

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