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.

185 lines
5.5KB

  1. /*
  2. * ANSI pedantic test for the Carla Backend & Host API
  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 "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. # ifdef CARLA_PROPER_CPP11_SUPPORT
  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. const char* licenseText;
  54. const char* const* fileExtensions;
  55. uint l, count;
  56. licenseText = carla_get_complete_license_text();
  57. printf("LICENSE:\n%s\n", licenseText);
  58. fileExtensions = carla_get_supported_file_extensions();
  59. printf("FILE EXTENSIONS:\n ");
  60. for (l=0; fileExtensions[l] != NULL; ++l)
  61. printf(" %s", fileExtensions[l]);
  62. printf("\n");
  63. count = carla_get_engine_driver_count();
  64. printf("DRIVER COUNT: %i\n", count);
  65. for (l=0; l < count; ++l)
  66. {
  67. const char* driverName;
  68. const char* const* driverDeviceNames;
  69. const EngineDriverDeviceInfo* driverDeviceInfo;
  70. uint m, m2, count2;
  71. driverName = carla_get_engine_driver_name(l);
  72. driverDeviceNames = carla_get_engine_driver_device_names(l);
  73. printf("DRIVER %i/%i: \"%s\" : DEVICES:\n", l+1, count, driverName);
  74. count2 = 0;
  75. while (driverDeviceNames[count2] != NULL)
  76. ++count2;
  77. for (m = 0; m < count2; ++m)
  78. {
  79. driverDeviceInfo = carla_get_engine_driver_device_info(l, driverDeviceNames[m]);
  80. printf("DRIVER DEVICE %i/%i: \"%s\"\n", m+1, count2, driverDeviceNames[m]);
  81. printf(" Has control panel: %s\n", BOOLEAN_AS_STRING(driverDeviceInfo->hints & ENGINE_DRIVER_DEVICE_HAS_CONTROL_PANEL));
  82. printf(" Can triple buffer: %s\n", BOOLEAN_AS_STRING(driverDeviceInfo->hints & ENGINE_DRIVER_DEVICE_CAN_TRIPLE_BUFFER));
  83. printf(" Variable buffer size: %s\n", BOOLEAN_AS_STRING(driverDeviceInfo->hints & ENGINE_DRIVER_DEVICE_VARIABLE_BUFFER_SIZE));
  84. printf(" Variable sample rate: %s\n", BOOLEAN_AS_STRING(driverDeviceInfo->hints & ENGINE_DRIVER_DEVICE_VARIABLE_SAMPLE_RATE));
  85. if (driverDeviceInfo->bufferSizes != NULL && driverDeviceInfo->bufferSizes[0] != 0)
  86. {
  87. printf(" Buffer sizes:");
  88. m2 = 0;
  89. while (driverDeviceInfo->bufferSizes[m2] != 0)
  90. printf(" %i", driverDeviceInfo->bufferSizes[m2++]);
  91. printf("\n");
  92. }
  93. else
  94. {
  95. printf(" Buffer sizes: (null)\n");
  96. }
  97. if (driverDeviceInfo->sampleRates != NULL && driverDeviceInfo->sampleRates[0] > 0.1)
  98. {
  99. printf(" Sample rates:");
  100. m2 = 0;
  101. while (driverDeviceInfo->sampleRates[m2] > 0.1)
  102. printf(" %.1f", driverDeviceInfo->sampleRates[m2++]);
  103. printf("\n");
  104. }
  105. else
  106. {
  107. printf(" Sample rates: (null)\n");
  108. }
  109. }
  110. }
  111. carla_set_engine_option(ENGINE_OPTION_PROCESS_MODE, ENGINE_PROCESS_MODE_PATCHBAY, NULL);
  112. carla_set_engine_option(ENGINE_OPTION_TRANSPORT_MODE, ENGINE_TRANSPORT_MODE_INTERNAL, NULL);
  113. if (carla_engine_init("Dummy", "ansi-test"))
  114. {
  115. #ifdef __cplusplus
  116. CarlaEngine* const engine(carla_get_engine());
  117. assert(engine != nullptr);
  118. engine->getLastError();
  119. #endif
  120. if (carla_add_plugin(BINARY_NATIVE, PLUGIN_INTERNAL, NULL, NULL, "audiofile", 0, NULL, 0x0))
  121. {
  122. #ifdef __cplusplus
  123. CarlaPlugin* const plugin(engine->getPlugin(0));
  124. assert(plugin != nullptr);
  125. plugin->getId();
  126. #endif
  127. /* carla_set_custom_data(0, CUSTOM_DATA_TYPE_STRING, "file", "/home/falktx/Music/test.wav"); */
  128. carla_transport_play();
  129. }
  130. else
  131. {
  132. printf("%s\n", carla_get_last_error());
  133. }
  134. #ifdef __cplusplus
  135. engine->setAboutToClose();
  136. #endif
  137. carla_engine_close();
  138. }
  139. #ifdef __cplusplus
  140. EngineControlEvent e1;
  141. EngineMidiEvent e2;
  142. EngineEvent e3;
  143. e3.fillFromMidiData(0, nullptr, 0);
  144. EngineOptions e4;
  145. EngineTimeInfoBBT e5;
  146. EngineTimeInfo e6;
  147. #endif
  148. /* unused C */
  149. (void)argc;
  150. (void)argv;
  151. (void)a; (void)b; (void)c; (void)d; (void)e;
  152. (void)f; /*(void)g;*/ (void)h; (void)i; (void)j; (void)k;
  153. #ifdef __cplusplus
  154. (void)e1; (void)e2; (void)e4; (void)e5; (void)e6;
  155. #endif
  156. return 0;
  157. }