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.

187 lines
4.2KB

  1. /*
  2. * Carla Juce Engine
  3. * Copyright (C) 2013 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 GPL.txt file
  16. */
  17. #ifndef USE_JUCE
  18. # error This file should not be compiled if Juce is disabled
  19. #endif
  20. #include "CarlaEngineInternal.hpp"
  21. #include "CarlaBackendUtils.hpp"
  22. #include "CarlaMIDI.h"
  23. #include "RtList.hpp"
  24. #include "juce_audio_basics.h"
  25. CARLA_BACKEND_START_NAMESPACE
  26. #if 0
  27. } // Fix editor indentation
  28. #endif
  29. // -------------------------------------------------------------------------------------------------------------------
  30. // Juce Engine
  31. static const char** gRetNames = nullptr;
  32. class CarlaEngineJuce : public CarlaEngine/*,
  33. public juce::AudioIODeviceCallback*/
  34. {
  35. public:
  36. CarlaEngineJuce()
  37. : CarlaEngine()
  38. {
  39. carla_debug("CarlaEngineJuce::CarlaEngineJuce()");
  40. }
  41. ~CarlaEngineJuce() override
  42. {
  43. if (gRetNames != nullptr)
  44. {
  45. delete[] gRetNames;
  46. gRetNames = nullptr;
  47. }
  48. }
  49. // -------------------------------------
  50. bool init(const char* const clientName) override
  51. {
  52. carla_debug("CarlaEngineJuce::init(\"%s\")", clientName);
  53. CarlaEngine::init(clientName);
  54. return true;
  55. }
  56. bool close() override
  57. {
  58. carla_debug("CarlaEngineJuce::close()");
  59. return CarlaEngine::close();
  60. }
  61. bool isRunning() const noexcept override
  62. {
  63. return false;
  64. }
  65. bool isOffline() const noexcept override
  66. {
  67. return false;
  68. }
  69. EngineType getType() const noexcept override
  70. {
  71. return kEngineTypeJuce;
  72. }
  73. const char* getCurrentDriverName() const noexcept override
  74. {
  75. return nullptr;
  76. }
  77. // -------------------------------------------------------------------
  78. protected:
  79. // void audioDeviceIOCallback (const float** inputChannelData,
  80. // int numInputChannels,
  81. // float** outputChannelData,
  82. // int numOutputChannels,
  83. // int numSamples)
  84. // {
  85. // }
  86. //
  87. // void audioDeviceAboutToStart (juce::AudioIODevice* device)
  88. // {
  89. // }
  90. //
  91. // void audioDeviceStopped()
  92. // {
  93. // }
  94. //
  95. // void audioDeviceError (const juce::String& errorMessage)
  96. // {
  97. // }
  98. // -------------------------------------
  99. private:
  100. //juce::AudioIODeviceType* fDeviceType;
  101. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(CarlaEngineJuce)
  102. };
  103. // -----------------------------------------
  104. CarlaEngine* CarlaEngine::newJuce(const AudioApi /*api*/)
  105. {
  106. return new CarlaEngineJuce();
  107. }
  108. size_t CarlaEngine::getJuceApiCount()
  109. {
  110. return 0;
  111. }
  112. const char* CarlaEngine::getJuceApiName(const unsigned int /*index*/)
  113. {
  114. return nullptr;
  115. }
  116. const char* const* CarlaEngine::getJuceApiDeviceNames(const unsigned int /*index*/)
  117. {
  118. #if 0
  119. juce::ScopedPointer<juce::AudioIODeviceType> deviceType;
  120. switch(index)
  121. {
  122. case 0:
  123. deviceType = juce::AudioIODeviceType::createAudioIODeviceType_JACK();
  124. break;
  125. default:
  126. //setLastError("");
  127. return nullptr;
  128. }
  129. if (deviceType == nullptr)
  130. {
  131. //setLastError("");
  132. return nullptr;
  133. }
  134. deviceType->scanForDevices();
  135. const juce::StringArray devNames(deviceType->getDeviceNames());
  136. const int devNameCount(devNames.size());
  137. if (devNameCount <= 0)
  138. return nullptr;
  139. gRetNames = new const char*[devNameCount+1];
  140. for (unsigned int i=0; i < devNameCount; ++i)
  141. gRetNames[i] = carla_strdup(devNames[i].toRawUTF8());
  142. gRetNames[devNameCount] = nullptr;
  143. #endif
  144. return gRetNames;
  145. }
  146. // -----------------------------------------
  147. CARLA_BACKEND_END_NAMESPACE