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.

carla-vst-export.cpp 3.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /*
  2. * Carla Native Plugins
  3. * Copyright (C) 2013-2018 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 "CarlaDefines.h"
  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. #if defined(CARLA_OS_WIN) || defined(CARLA_OS_MAC)
  45. const AEffect* VSTPluginMain(audioMasterCallback audioMaster);
  46. #else
  47. const AEffect* VSTPluginMain(audioMasterCallback audioMaster) asm ("main");
  48. #endif
  49. CARLA_EXPORT __cdecl
  50. const AEffect* VSTPluginMain(audioMasterCallback audioMaster)
  51. {
  52. // old version
  53. if (audioMaster(nullptr, audioMasterVersion, 0, 0, nullptr, 0.0f) == 0)
  54. return nullptr;
  55. AEffect* const effect(new AEffect);
  56. std::memset(effect, 0, sizeof(AEffect));
  57. // vst fields
  58. effect->magic = kEffectMagic;
  59. effect->version = CARLA_VERSION_HEX;
  60. // pointers
  61. VstObject* const obj(new VstObject());
  62. obj->audioMaster = (void*)audioMaster;
  63. obj->plugin = nullptr;
  64. effect->object = obj;
  65. // static calls
  66. #ifdef __WINE__
  67. effect->dispatcher = cvst_dispatcherCallback;
  68. effect->getParameter = cvst_getParameterCallback;
  69. effect->setParameter = cvst_setParameterCallback;
  70. effect->process = cvst_processCallback;
  71. effect->processReplacing = cvst_processReplacingCallback;
  72. #else
  73. effect->dispatcher = vst_dispatcherCallback;
  74. effect->process = vst_processCallback;
  75. effect->getParameter = vst_getParameterCallback;
  76. effect->setParameter = vst_setParameterCallback;
  77. effect->processReplacing = vst_processReplacingCallback;
  78. #endif
  79. return VSTPluginMainInit(effect);
  80. }
  81. intptr_t VSTAudioMaster(AEffect* effect, int32_t opcode, int32_t index, intptr_t value, void* ptr, float opt)
  82. {
  83. const audioMasterCallback audioMaster = (audioMasterCallback)((VstObject*)effect->object)->audioMaster;
  84. return audioMaster(effect, opcode, index, value, ptr, opt);
  85. }