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.

178 lines
4.0KB

  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. // -------------------------------------------------------------------
  71. protected:
  72. // void audioDeviceIOCallback (const float** inputChannelData,
  73. // int numInputChannels,
  74. // float** outputChannelData,
  75. // int numOutputChannels,
  76. // int numSamples)
  77. // {
  78. // }
  79. //
  80. // void audioDeviceAboutToStart (juce::AudioIODevice* device)
  81. // {
  82. // }
  83. //
  84. // void audioDeviceStopped()
  85. // {
  86. // }
  87. //
  88. // void audioDeviceError (const juce::String& errorMessage)
  89. // {
  90. // }
  91. // -------------------------------------
  92. private:
  93. //juce::AudioIODeviceType* fDeviceType;
  94. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(CarlaEngineJuce)
  95. };
  96. // -----------------------------------------
  97. CarlaEngine* CarlaEngine::newJuce()
  98. {
  99. return new CarlaEngineJuce();
  100. }
  101. size_t CarlaEngine::getJuceApiCount()
  102. {
  103. return 0;
  104. }
  105. const char* CarlaEngine::getJuceApiName(const unsigned int index)
  106. {
  107. return nullptr;
  108. }
  109. const char** CarlaEngine::getJuceApiDeviceNames(const unsigned int index)
  110. {
  111. #if 0
  112. juce::ScopedPointer<juce::AudioIODeviceType> deviceType;
  113. switch(index)
  114. {
  115. case 0:
  116. deviceType = juce::AudioIODeviceType::createAudioIODeviceType_JACK();
  117. break;
  118. default:
  119. //setLastError("");
  120. return nullptr;
  121. }
  122. if (deviceType == nullptr)
  123. {
  124. //setLastError("");
  125. return nullptr;
  126. }
  127. deviceType->scanForDevices();
  128. const juce::StringArray devNames(deviceType->getDeviceNames());
  129. const int devNameCount(devNames.size());
  130. if (devNameCount <= 0)
  131. return nullptr;
  132. gRetNames = new const char*[devNameCount+1];
  133. for (unsigned int i=0; i < devNameCount; ++i)
  134. gRetNames[i] = carla_strdup(devNames[i].toRawUTF8());
  135. gRetNames[devNameCount] = nullptr;
  136. #endif
  137. return gRetNames;
  138. }
  139. // -----------------------------------------
  140. CARLA_BACKEND_END_NAMESPACE