The JUCE cross-platform C++ framework, with DISTRHO/KXStudio specific changes
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.

251 lines
8.4KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2022 - Raw Material Software Limited
  5. JUCE is an open source library subject to commercial or open-source
  6. licensing.
  7. By using JUCE, you agree to the terms of both the JUCE 7 End-User License
  8. Agreement and JUCE Privacy Policy.
  9. End User License Agreement: www.juce.com/juce-7-licence
  10. Privacy Policy: www.juce.com/juce-privacy-policy
  11. Or: You may also use this code under the terms of the GPL v3 (see
  12. www.gnu.org/licenses).
  13. JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
  14. EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
  15. DISCLAIMED.
  16. ==============================================================================
  17. */
  18. #ifdef JUCE_AUDIO_PROCESSORS_H_INCLUDED
  19. /* When you add this cpp file to your project, you mustn't include it in a file where you've
  20. already included any other headers - just put it inside a file on its own, possibly with your config
  21. flags preceding it, but don't include anything else. That also includes avoiding any automatic prefix
  22. header files that the compiler may be using.
  23. */
  24. #error "Incorrect use of JUCE cpp file"
  25. #endif
  26. #define JUCE_CORE_INCLUDE_NATIVE_HEADERS 1
  27. #define JUCE_CORE_INCLUDE_OBJC_HELPERS 1
  28. #if ! JUCE_AUDIOPROCESSOR_NO_GUI
  29. #define JUCE_GUI_BASICS_INCLUDE_XHEADERS 1
  30. #endif
  31. #define JUCE_GUI_BASICS_INCLUDE_SCOPED_THREAD_DPI_AWARENESS_SETTER 1
  32. #define JUCE_GRAPHICS_INCLUDE_COREGRAPHICS_HELPERS 1
  33. #include "juce_audio_processors.h"
  34. #include <juce_gui_extra/juce_gui_extra.h>
  35. //==============================================================================
  36. #if (JUCE_PLUGINHOST_VST || JUCE_PLUGINHOST_VST3) && (JUCE_LINUX || JUCE_BSD) && ! JUCE_AUDIOPROCESSOR_NO_GUI
  37. JUCE_BEGIN_IGNORE_WARNINGS_GCC_LIKE ("-Wvariadic-macros")
  38. #include <X11/Xlib.h>
  39. JUCE_END_IGNORE_WARNINGS_GCC_LIKE
  40. #include <X11/Xutil.h>
  41. #include <sys/utsname.h>
  42. #undef KeyPress
  43. #endif
  44. #if ! JUCE_WINDOWS && ! JUCE_MAC && ! JUCE_LINUX
  45. #undef JUCE_PLUGINHOST_VST3
  46. #define JUCE_PLUGINHOST_VST3 0
  47. #endif
  48. #if JUCE_PLUGINHOST_AU && (JUCE_MAC || JUCE_IOS)
  49. #include <AudioUnit/AudioUnit.h>
  50. #endif
  51. namespace juce
  52. {
  53. #if JUCE_PLUGINHOST_VST || (JUCE_PLUGINHOST_LADSPA && (JUCE_LINUX || JUCE_BSD))
  54. static bool arrayContainsPlugin (const OwnedArray<PluginDescription>& list,
  55. const PluginDescription& desc)
  56. {
  57. for (auto* p : list)
  58. if (p->isDuplicateOf (desc))
  59. return true;
  60. return false;
  61. }
  62. #endif
  63. template <typename Callback>
  64. void callOnMessageThread (Callback&& callback)
  65. {
  66. if (MessageManager::getInstance()->existsAndIsLockedByCurrentThread())
  67. {
  68. callback();
  69. return;
  70. }
  71. WaitableEvent completionEvent;
  72. MessageManager::callAsync ([&callback, &completionEvent]
  73. {
  74. callback();
  75. completionEvent.signal();
  76. });
  77. completionEvent.wait();
  78. }
  79. #if JUCE_MAC
  80. //==============================================================================
  81. /* This is an NSViewComponent which holds a long-lived NSView which acts
  82. as the parent view for plugin editors.
  83. Note that this component does not auto-resize depending on the bounds
  84. of the owned view. VST2 and VST3 plugins have dedicated interfaces to
  85. request that the editor bounds are updated. We can call `setSize` on this
  86. component from inside those dedicated callbacks.
  87. */
  88. struct NSViewComponentWithParent : public NSViewComponent,
  89. private AsyncUpdater
  90. {
  91. enum class WantsNudge { no, yes };
  92. explicit NSViewComponentWithParent (WantsNudge shouldNudge)
  93. : wantsNudge (shouldNudge)
  94. {
  95. auto* view = [[getViewClass().createInstance() init] autorelease];
  96. object_setInstanceVariable (view, "owner", this);
  97. setView (view);
  98. }
  99. explicit NSViewComponentWithParent (AudioPluginInstance& instance)
  100. : NSViewComponentWithParent (getWantsNudge (instance)) {}
  101. ~NSViewComponentWithParent() override
  102. {
  103. if (auto* view = static_cast<NSView*> (getView()))
  104. object_setInstanceVariable (view, "owner", nullptr);
  105. cancelPendingUpdate();
  106. }
  107. JUCE_DECLARE_NON_COPYABLE (NSViewComponentWithParent)
  108. JUCE_DECLARE_NON_MOVEABLE (NSViewComponentWithParent)
  109. private:
  110. WantsNudge wantsNudge = WantsNudge::no;
  111. static WantsNudge getWantsNudge (AudioPluginInstance& instance)
  112. {
  113. PluginDescription pd;
  114. instance.fillInPluginDescription (pd);
  115. return pd.manufacturerName == "FabFilter" ? WantsNudge::yes : WantsNudge::no;
  116. }
  117. void handleAsyncUpdate() override
  118. {
  119. if (auto* peer = getTopLevelComponent()->getPeer())
  120. {
  121. auto* view = static_cast<NSView*> (getView());
  122. const auto newArea = peer->getAreaCoveredBy (*this);
  123. [view setFrame: makeNSRect (newArea.withHeight (newArea.getHeight() + 1))];
  124. [view setFrame: makeNSRect (newArea)];
  125. }
  126. }
  127. struct InnerNSView final : public ObjCClass<NSView>
  128. {
  129. InnerNSView()
  130. : ObjCClass ("JuceInnerNSView_")
  131. {
  132. addIvar<NSViewComponentWithParent*> ("owner");
  133. addMethod (@selector (isOpaque), [] (id, SEL) { return YES; });
  134. addMethod (@selector (didAddSubview:), [] (id self, SEL, NSView*)
  135. {
  136. if (auto* owner = getIvar<NSViewComponentWithParent*> (self, "owner"))
  137. if (owner->wantsNudge == WantsNudge::yes)
  138. owner->triggerAsyncUpdate();
  139. });
  140. JUCE_BEGIN_IGNORE_WARNINGS_GCC_LIKE ("-Wundeclared-selector")
  141. addMethod (@selector (clipsToBounds), [] (id, SEL) { return YES; });
  142. JUCE_END_IGNORE_WARNINGS_GCC_LIKE
  143. registerClass();
  144. }
  145. };
  146. static InnerNSView& getViewClass()
  147. {
  148. static InnerNSView result;
  149. return result;
  150. }
  151. };
  152. #endif
  153. } // namespace juce
  154. #include "utilities/juce_FlagCache.h"
  155. #include "format/juce_AudioPluginFormat.cpp"
  156. #include "format/juce_AudioPluginFormatManager.cpp"
  157. #include "format_types/juce_LegacyAudioParameter.cpp"
  158. #include "processors/juce_AudioProcessor.cpp"
  159. #include "processors/juce_AudioPluginInstance.cpp"
  160. #include "processors/juce_AudioProcessorGraph.cpp"
  161. #if ! JUCE_AUDIOPROCESSOR_NO_GUI
  162. #include "processors/juce_AudioProcessorEditor.cpp"
  163. #include "processors/juce_GenericAudioProcessorEditor.cpp"
  164. #endif
  165. #include "processors/juce_PluginDescription.cpp"
  166. #include "format_types/juce_ARACommon.cpp"
  167. #include "format_types/juce_LADSPAPluginFormat.cpp"
  168. #include "format_types/juce_VSTPluginFormat.cpp"
  169. #include "format_types/juce_VST3PluginFormat.cpp"
  170. #include "format_types/juce_AudioUnitPluginFormat.mm"
  171. #include "format_types/juce_ARAHosting.cpp"
  172. #if ! JUCE_AUDIOPROCESSOR_NO_GUI
  173. #include "scanning/juce_KnownPluginList.cpp"
  174. #include "scanning/juce_PluginDirectoryScanner.cpp"
  175. #include "scanning/juce_PluginListComponent.cpp"
  176. #endif
  177. #include "processors/juce_AudioProcessorParameterGroup.cpp"
  178. #include "utilities/juce_AudioProcessorParameterWithID.cpp"
  179. #include "utilities/juce_RangedAudioParameter.cpp"
  180. #include "utilities/juce_AudioParameterFloat.cpp"
  181. #include "utilities/juce_AudioParameterInt.cpp"
  182. #include "utilities/juce_AudioParameterBool.cpp"
  183. #include "utilities/juce_AudioParameterChoice.cpp"
  184. #if ! JUCE_AUDIOPROCESSOR_NO_GUI
  185. #include "utilities/juce_ParameterAttachments.cpp"
  186. #endif
  187. #include "utilities/juce_AudioProcessorValueTreeState.cpp"
  188. #include "utilities/juce_PluginHostType.cpp"
  189. #include "utilities/juce_AAXClientExtensions.cpp"
  190. #include "utilities/juce_VST2ClientExtensions.cpp"
  191. #include "utilities/ARA/juce_ARA_utils.cpp"
  192. #include "format_types/juce_LV2PluginFormat.cpp"
  193. #if JUCE_UNIT_TESTS
  194. #if JUCE_PLUGINHOST_VST3
  195. #include "format_types/juce_VST3PluginFormat_test.cpp"
  196. #endif
  197. #if JUCE_PLUGINHOST_LV2 && (! (JUCE_ANDROID || JUCE_IOS))
  198. #include "format_types/juce_LV2PluginFormat_test.cpp"
  199. #endif
  200. #endif
  201. #if JUCE_AUDIOPROCESSOR_NO_GUI
  202. // commonly used classes in DSP code
  203. namespace juce { Colour::Colour(juce::uint32) noexcept {} }
  204. #endif