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.

CarlaUtils2.cpp 5.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. /*
  2. * Carla Utility Tests
  3. * Copyright (C) 2013-2014 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. #ifdef NDEBUG
  18. # error Build this file with debug ON please
  19. #endif
  20. #define HAVE_JUCE
  21. #define VESTIGE_HEADER
  22. #include "CarlaUtils.hpp"
  23. #undef NULL
  24. #define NULL nullptr
  25. #include "CarlaLadspaUtils.hpp"
  26. #include "CarlaDssiUtils.hpp"
  27. #include "CarlaLv2Utils.hpp"
  28. #include "CarlaVstUtils.hpp"
  29. // used in dssi utils
  30. #include "juce_core.h"
  31. #include <QtCore/QDir>
  32. #include <QtCore/QFileInfo>
  33. #include <QtCore/QStringList>
  34. // -----------------------------------------------------------------------
  35. static void test_CarlaLadspaUtils()
  36. {
  37. LADSPA_Descriptor desc;
  38. carla_zeroStruct(desc);
  39. LADSPA_RDF_Descriptor rdfDesc;
  40. delete ladspa_rdf_dup(&rdfDesc);
  41. is_ladspa_port_good(0x0, 0x0);
  42. is_ladspa_rdf_descriptor_valid(&rdfDesc, &desc);
  43. get_default_ladspa_port_value(0x0, -1.0f, 1.0f);
  44. }
  45. // -----------------------------------------------------------------------
  46. namespace dssi_juce {
  47. const char* find_dssi_ui(const char* const filename, const char* const label) noexcept;
  48. #define HAVE_JUCE
  49. #include "CarlaDssiUtils.cpp"
  50. }
  51. namespace dssi_qt {
  52. const char* find_dssi_ui(const char* const filename, const char* const label) noexcept;
  53. #undef HAVE_JUCE
  54. #include "CarlaDssiUtils.cpp"
  55. }
  56. static void test_CarlaDssiUtils() noexcept
  57. {
  58. const char* const ui_juce = dssi_juce::find_dssi_ui("/usr/lib/dssi/trivial_sampler.so", "aa");
  59. const char* const ui_qt = dssi_qt::find_dssi_ui("/usr/lib/dssi/trivial_sampler.so", "aa");
  60. CARLA_SAFE_ASSERT(ui_juce != nullptr);
  61. CARLA_SAFE_ASSERT(ui_qt != nullptr);
  62. if (ui_juce != nullptr)
  63. {
  64. carla_stdout("%s", ui_juce);
  65. assert(std::strcmp(ui_juce, "/usr/lib/dssi/trivial_sampler/trivial_sampler_qt") == 0);
  66. delete[] ui_juce;
  67. }
  68. if (ui_qt != nullptr)
  69. {
  70. carla_stdout("%s", ui_qt);
  71. assert(std::strcmp(ui_qt, "/usr/lib/dssi/trivial_sampler/trivial_sampler_qt") == 0);
  72. delete[] ui_qt;
  73. }
  74. }
  75. // -----------------------------------------------------------------------
  76. static LV2_URID test_lv2_uridMap(LV2_URID_Map_Handle, const char*)
  77. {
  78. return 1;
  79. }
  80. static void test_CarlaLv2Utils()
  81. {
  82. Lv2WorldClass& lv2World(Lv2WorldClass::getInstance());
  83. lv2World.initIfNeeded();
  84. // getPlugin
  85. const LilvPlugin* const plugin(lv2World.getPlugin("urn:juced:DrumSynth"));
  86. CARLA_SAFE_ASSERT(plugin != nullptr);
  87. // getState
  88. LV2_URID_Map uridMap = { nullptr, test_lv2_uridMap };
  89. LilvState* const state(lv2World.getState("http://arcticanaudio.com/plugins/thefunction#preset001", &uridMap));
  90. CARLA_SAFE_ASSERT(state != nullptr);
  91. if (state != nullptr) lilv_state_free(state);
  92. // load a bunch of plugins to stress test lilv
  93. delete lv2_rdf_new("http://arcticanaudio.com/plugins/thefunction", true);
  94. delete lv2_rdf_new("http://kunz.corrupt.ch/products/tal-noisemaker", true);
  95. delete lv2_rdf_new("http://calf.sourceforge.net/plugins/Reverb", true);
  96. delete lv2_rdf_new("http://www.openavproductions.com/fabla", true);
  97. delete lv2_rdf_new("http://invadarecords.com/plugins/lv2/meter", true);
  98. delete lv2_rdf_new("http://gareus.org/oss/lv2/meters#spectr30stereo", true);
  99. delete lv2_rdf_new("http://plugin.org.uk/swh-plugins/revdelay", true);
  100. delete lv2_rdf_new("http://lv2plug.in/plugins/eg-scope#Stereo", true);
  101. delete lv2_rdf_new("http://kxstudio.sf.net/carla/plugins/carlarack", true);
  102. delete lv2_rdf_new("http://guitarix.sourceforge.net/plugins/gxautowah#autowah", true);
  103. delete lv2_rdf_new("http://github.com/blablack/ams-lv2/mixer_4ch", true);
  104. delete lv2_rdf_new("http://drumgizmo.org/lv2", true);
  105. delete lv2_rdf_new("http://synthv1.sourceforge.net/lv2", true);
  106. delete lv2_rdf_new("urn:juced:DrumSynth", true);
  107. // misc
  108. is_lv2_port_supported(0x0);
  109. is_lv2_feature_supported("test1");
  110. is_lv2_ui_feature_supported("test2");
  111. }
  112. // -----------------------------------------------------------------------
  113. static intptr_t test_vst_dispatcher(AEffect*, int, int, intptr_t, void*, float)
  114. {
  115. return 0;
  116. }
  117. static void test_CarlaVstUtils() noexcept
  118. {
  119. AEffect effect;
  120. carla_zeroStruct(effect);
  121. effect.dispatcher = test_vst_dispatcher;
  122. vstPluginCanDo(&effect, "test");
  123. carla_stdout(vstEffectOpcode2str(effOpen));
  124. carla_stdout(vstMasterOpcode2str(audioMasterAutomate));
  125. }
  126. // -----------------------------------------------------------------------
  127. // main
  128. int main()
  129. {
  130. test_CarlaLadspaUtils();
  131. test_CarlaDssiUtils();
  132. test_CarlaLv2Utils();
  133. test_CarlaVstUtils();
  134. return 0;
  135. }
  136. // -----------------------------------------------------------------------