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.

183 lines
4.1KB

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