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.

188 lines
5.7KB

  1. /*
  2. * ANSI pedantic test for the Carla Backend & Host API
  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 "CarlaBackend.h"
  18. #include "CarlaHost.h"
  19. #include "CarlaUtils.h"
  20. #include "CarlaMIDI.h"
  21. #include "CarlaNative.h"
  22. #include "CarlaNativePlugin.h"
  23. #ifdef __cplusplus
  24. # include "CarlaEngine.hpp"
  25. # include "CarlaPlugin.hpp"
  26. # include <cassert>
  27. # include <cstdio>
  28. # ifndef nullptr
  29. # undef NULL
  30. # define NULL nullptr
  31. # endif
  32. #else
  33. # include <assert.h>
  34. # include <stdio.h>
  35. #endif
  36. #define BOOLEAN_AS_STRING(cond) ((cond) ? "true" : "false")
  37. int main(int argc, char* argv[])
  38. {
  39. #ifdef __cplusplus
  40. CARLA_BACKEND_USE_NAMESPACE
  41. #endif
  42. ParameterData a;
  43. ParameterRanges b;
  44. MidiProgramData c;
  45. CustomData d;
  46. EngineDriverDeviceInfo e;
  47. CarlaPluginInfo f;
  48. /*CarlaCachedPluginInfo g;*/
  49. CarlaPortCountInfo h;
  50. CarlaParameterInfo i;
  51. CarlaScalePointInfo j;
  52. CarlaTransportInfo k;
  53. CarlaHostHandle handle;
  54. const char* licenseText;
  55. const char* const* fileExtensions;
  56. uint l, count;
  57. licenseText = carla_get_complete_license_text();
  58. printf("LICENSE:\n%s\n", licenseText);
  59. fileExtensions = carla_get_supported_file_extensions();
  60. printf("FILE EXTENSIONS:\n ");
  61. for (l=0; fileExtensions[l] != NULL; ++l)
  62. printf(" %s", fileExtensions[l]);
  63. printf("\n");
  64. count = carla_get_engine_driver_count();
  65. printf("DRIVER COUNT: %i\n", count);
  66. for (l=0; l < count; ++l)
  67. {
  68. const char* driverName;
  69. const char* const* driverDeviceNames;
  70. const EngineDriverDeviceInfo* driverDeviceInfo;
  71. uint m, m2, count2;
  72. driverName = carla_get_engine_driver_name(l);
  73. driverDeviceNames = carla_get_engine_driver_device_names(l);
  74. printf("DRIVER %i/%i: \"%s\" : DEVICES:\n", l+1, count, driverName);
  75. count2 = 0;
  76. while (driverDeviceNames[count2] != NULL)
  77. ++count2;
  78. for (m = 0; m < count2; ++m)
  79. {
  80. driverDeviceInfo = carla_get_engine_driver_device_info(l, driverDeviceNames[m]);
  81. printf("DRIVER DEVICE %i/%i: \"%s\"\n", m+1, count2, driverDeviceNames[m]);
  82. printf(" Has control panel: %s\n", BOOLEAN_AS_STRING(driverDeviceInfo->hints & ENGINE_DRIVER_DEVICE_HAS_CONTROL_PANEL));
  83. printf(" Can triple buffer: %s\n", BOOLEAN_AS_STRING(driverDeviceInfo->hints & ENGINE_DRIVER_DEVICE_CAN_TRIPLE_BUFFER));
  84. printf(" Variable buffer size: %s\n", BOOLEAN_AS_STRING(driverDeviceInfo->hints & ENGINE_DRIVER_DEVICE_VARIABLE_BUFFER_SIZE));
  85. printf(" Variable sample rate: %s\n", BOOLEAN_AS_STRING(driverDeviceInfo->hints & ENGINE_DRIVER_DEVICE_VARIABLE_SAMPLE_RATE));
  86. if (driverDeviceInfo->bufferSizes != NULL && driverDeviceInfo->bufferSizes[0] != 0)
  87. {
  88. printf(" Buffer sizes:");
  89. m2 = 0;
  90. while (driverDeviceInfo->bufferSizes[m2] != 0)
  91. printf(" %i", driverDeviceInfo->bufferSizes[m2++]);
  92. printf("\n");
  93. }
  94. else
  95. {
  96. printf(" Buffer sizes: (null)\n");
  97. }
  98. if (driverDeviceInfo->sampleRates != NULL && driverDeviceInfo->sampleRates[0] > 0.1)
  99. {
  100. printf(" Sample rates:");
  101. m2 = 0;
  102. while (driverDeviceInfo->sampleRates[m2] > 0.1)
  103. printf(" %.1f", driverDeviceInfo->sampleRates[m2++]);
  104. printf("\n");
  105. }
  106. else
  107. {
  108. printf(" Sample rates: (null)\n");
  109. }
  110. }
  111. }
  112. handle = carla_standalone_host_init();
  113. carla_set_engine_option(handle, ENGINE_OPTION_PROCESS_MODE, ENGINE_PROCESS_MODE_PATCHBAY, NULL);
  114. carla_set_engine_option(handle, ENGINE_OPTION_TRANSPORT_MODE, ENGINE_TRANSPORT_MODE_INTERNAL, NULL);
  115. if (carla_engine_init(handle, "Dummy", "ansi-test"))
  116. {
  117. #ifdef __cplusplus
  118. CarlaEngine* const engine(carla_get_engine_from_handle(handle));
  119. assert(engine != nullptr);
  120. engine->getLastError();
  121. #endif
  122. if (carla_add_plugin(handle, BINARY_NATIVE, PLUGIN_INTERNAL, NULL, NULL, "audiofile", 0, NULL, 0x0))
  123. {
  124. #ifdef __cplusplus
  125. const std::shared_ptr<CarlaPlugin> plugin(engine->getPlugin(0));
  126. assert(plugin.get() != nullptr);
  127. plugin->getId();
  128. #endif
  129. /* carla_set_custom_data(0, CUSTOM_DATA_TYPE_STRING, "file", "/home/falktx/Music/test.wav"); */
  130. carla_transport_play(handle);
  131. }
  132. else
  133. {
  134. printf("%s\n", carla_get_last_error(handle));
  135. }
  136. #ifdef __cplusplus
  137. engine->setAboutToClose();
  138. #endif
  139. carla_engine_close(handle);
  140. }
  141. #ifdef __cplusplus
  142. EngineControlEvent e1;
  143. EngineMidiEvent e2;
  144. EngineEvent e3;
  145. e3.fillFromMidiData(0, nullptr, 0);
  146. EngineOptions e4;
  147. EngineTimeInfoBBT e5;
  148. EngineTimeInfo e6;
  149. #endif
  150. /* unused C */
  151. (void)argc;
  152. (void)argv;
  153. (void)a; (void)b; (void)c; (void)d; (void)e;
  154. (void)f; /*(void)g;*/ (void)h; (void)i; (void)j; (void)k;
  155. #ifdef __cplusplus
  156. (void)e1; (void)e2; (void)e4; (void)e5; (void)e6;
  157. #endif
  158. return 0;
  159. }