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.

81 lines
2.6KB

  1. #include "CarlaHost.h"
  2. #include <dlfcn.h>
  3. #include <signal.h>
  4. #include <stdbool.h>
  5. #include <stdio.h>
  6. #include <unistd.h>
  7. // --------------------------------------------------------------------------------------------------------
  8. static volatile bool term = false;
  9. static void signalHandler(int sig)
  10. {
  11. switch (sig)
  12. {
  13. case SIGINT:
  14. case SIGTERM:
  15. term = true;
  16. break;
  17. }
  18. }
  19. // --------------------------------------------------------------------------------------------------------
  20. typedef bool (*carla_engine_init_func)(const char* driverName, const char* clientName);
  21. typedef void (*carla_engine_idle_func)(void);
  22. typedef bool (*carla_is_engine_running_func)(void);
  23. typedef bool (*carla_engine_close_func)(void);
  24. typedef bool (*carla_add_plugin_func)(BinaryType btype, PluginType ptype,
  25. const char* filename, const char* name, const char* label, int64_t uniqueId,
  26. const void* extraPtr, uint options);
  27. typedef const char* (*carla_get_last_error_func)(void);
  28. int main(void)
  29. {
  30. void* lib = dlopen("/home/falktx/FOSS/GIT-mine/falkTX/Carla/bin/libcarla_standalone2.so", RTLD_NOW|RTLD_GLOBAL);
  31. if (!lib)
  32. {
  33. printf("Failed to load carla lib\n");
  34. return 1;
  35. }
  36. const carla_engine_init_func carla_engine_init = dlsym(lib, "carla_engine_init");
  37. const carla_engine_idle_func carla_engine_idle = dlsym(lib, "carla_engine_idle");
  38. const carla_is_engine_running_func carla_is_engine_running = dlsym(lib, "carla_is_engine_running");
  39. const carla_engine_close_func carla_engine_close = dlsym(lib, "carla_engine_close");
  40. const carla_add_plugin_func carla_add_plugin = dlsym(lib, "carla_add_plugin");
  41. const carla_get_last_error_func carla_get_last_error = dlsym(lib, "carla_get_last_error");
  42. if (! carla_engine_init("JACK", "Carla-uhe-test"))
  43. {
  44. printf("Engine failed to initialize, possible reasons:\n%s\n", carla_get_last_error());
  45. return 1;
  46. }
  47. if (! carla_add_plugin(BINARY_NATIVE, PLUGIN_VST2, "/home/falktx/.vst/u-he/ACE.64.so", "", "", 0, NULL, 0))
  48. {
  49. printf("Failed to load plugin, possible reasons:\n%s\n", carla_get_last_error());
  50. carla_engine_close();
  51. return 1;
  52. }
  53. signal(SIGINT, signalHandler);
  54. signal(SIGTERM, signalHandler);
  55. while (carla_is_engine_running() && ! term)
  56. {
  57. carla_engine_idle();
  58. sleep(1);
  59. }
  60. carla_engine_close();
  61. return 0;
  62. }
  63. // --------------------------------------------------------------------------------------------------------