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.

238 lines
8.0KB

  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. #define JUCE_GUI_BASICS_INCLUDE_XHEADERS 1
  29. #define JUCE_GUI_BASICS_INCLUDE_SCOPED_THREAD_DPI_AWARENESS_SETTER 1
  30. #define JUCE_GRAPHICS_INCLUDE_COREGRAPHICS_HELPERS 1
  31. #include "juce_audio_processors.h"
  32. #include <juce_gui_extra/juce_gui_extra.h>
  33. //==============================================================================
  34. #if (JUCE_PLUGINHOST_VST || JUCE_PLUGINHOST_VST3) && (JUCE_LINUX || JUCE_BSD)
  35. JUCE_BEGIN_IGNORE_WARNINGS_GCC_LIKE ("-Wvariadic-macros")
  36. #include <X11/Xlib.h>
  37. JUCE_END_IGNORE_WARNINGS_GCC_LIKE
  38. #include <X11/Xutil.h>
  39. #include <sys/utsname.h>
  40. #undef KeyPress
  41. #endif
  42. #if ! JUCE_WINDOWS && ! JUCE_MAC && ! JUCE_LINUX
  43. #undef JUCE_PLUGINHOST_VST3
  44. #define JUCE_PLUGINHOST_VST3 0
  45. #endif
  46. #if JUCE_PLUGINHOST_AU && (JUCE_MAC || JUCE_IOS)
  47. #include <AudioUnit/AudioUnit.h>
  48. #endif
  49. namespace juce
  50. {
  51. #if JUCE_PLUGINHOST_VST || (JUCE_PLUGINHOST_LADSPA && (JUCE_LINUX || JUCE_BSD))
  52. static bool arrayContainsPlugin (const OwnedArray<PluginDescription>& list,
  53. const PluginDescription& desc)
  54. {
  55. for (auto* p : list)
  56. if (p->isDuplicateOf (desc))
  57. return true;
  58. return false;
  59. }
  60. #endif
  61. template <typename Callback>
  62. void callOnMessageThread (Callback&& callback)
  63. {
  64. if (MessageManager::getInstance()->existsAndIsLockedByCurrentThread())
  65. {
  66. callback();
  67. return;
  68. }
  69. WaitableEvent completionEvent;
  70. MessageManager::callAsync ([&callback, &completionEvent]
  71. {
  72. callback();
  73. completionEvent.signal();
  74. });
  75. completionEvent.wait();
  76. }
  77. #if JUCE_MAC
  78. //==============================================================================
  79. /* This is an NSViewComponent which holds a long-lived NSView which acts
  80. as the parent view for plugin editors.
  81. Note that this component does not auto-resize depending on the bounds
  82. of the owned view. VST2 and VST3 plugins have dedicated interfaces to
  83. request that the editor bounds are updated. We can call `setSize` on this
  84. component from inside those dedicated callbacks.
  85. */
  86. struct NSViewComponentWithParent : public NSViewComponent,
  87. private AsyncUpdater
  88. {
  89. enum class WantsNudge { no, yes };
  90. explicit NSViewComponentWithParent (WantsNudge shouldNudge)
  91. : wantsNudge (shouldNudge)
  92. {
  93. auto* view = [[getViewClass().createInstance() init] autorelease];
  94. object_setInstanceVariable (view, "owner", this);
  95. setView (view);
  96. }
  97. explicit NSViewComponentWithParent (AudioPluginInstance& instance)
  98. : NSViewComponentWithParent (getWantsNudge (instance)) {}
  99. ~NSViewComponentWithParent() override
  100. {
  101. if (auto* view = static_cast<NSView*> (getView()))
  102. object_setInstanceVariable (view, "owner", nullptr);
  103. cancelPendingUpdate();
  104. }
  105. JUCE_DECLARE_NON_COPYABLE (NSViewComponentWithParent)
  106. JUCE_DECLARE_NON_MOVEABLE (NSViewComponentWithParent)
  107. private:
  108. WantsNudge wantsNudge = WantsNudge::no;
  109. static WantsNudge getWantsNudge (AudioPluginInstance& instance)
  110. {
  111. PluginDescription pd;
  112. instance.fillInPluginDescription (pd);
  113. return pd.manufacturerName == "FabFilter" ? WantsNudge::yes : WantsNudge::no;
  114. }
  115. void handleAsyncUpdate() override
  116. {
  117. if (auto* peer = getTopLevelComponent()->getPeer())
  118. {
  119. auto* view = static_cast<NSView*> (getView());
  120. const auto newArea = peer->getAreaCoveredBy (*this);
  121. [view setFrame: makeNSRect (newArea.withHeight (newArea.getHeight() + 1))];
  122. [view setFrame: makeNSRect (newArea)];
  123. }
  124. }
  125. struct InnerNSView final : public ObjCClass<NSView>
  126. {
  127. InnerNSView()
  128. : ObjCClass ("JuceInnerNSView_")
  129. {
  130. addIvar<NSViewComponentWithParent*> ("owner");
  131. addMethod (@selector (isOpaque), [] (id, SEL) { return YES; });
  132. addMethod (@selector (didAddSubview:), [] (id self, SEL, NSView*)
  133. {
  134. if (auto* owner = getIvar<NSViewComponentWithParent*> (self, "owner"))
  135. if (owner->wantsNudge == WantsNudge::yes)
  136. owner->triggerAsyncUpdate();
  137. });
  138. JUCE_BEGIN_IGNORE_WARNINGS_GCC_LIKE ("-Wundeclared-selector")
  139. addMethod (@selector (clipsToBounds), [] (id, SEL) { return YES; });
  140. JUCE_END_IGNORE_WARNINGS_GCC_LIKE
  141. registerClass();
  142. }
  143. };
  144. static InnerNSView& getViewClass()
  145. {
  146. static InnerNSView result;
  147. return result;
  148. }
  149. };
  150. #endif
  151. } // namespace juce
  152. #include "utilities/juce_FlagCache.h"
  153. #include "format/juce_AudioPluginFormat.cpp"
  154. #include "format/juce_AudioPluginFormatManager.cpp"
  155. #include "format_types/juce_LegacyAudioParameter.cpp"
  156. #include "processors/juce_AudioProcessor.cpp"
  157. #include "processors/juce_AudioPluginInstance.cpp"
  158. #include "processors/juce_AudioProcessorEditor.cpp"
  159. #include "processors/juce_AudioProcessorGraph.cpp"
  160. #include "processors/juce_GenericAudioProcessorEditor.cpp"
  161. #include "processors/juce_PluginDescription.cpp"
  162. #include "format_types/juce_ARACommon.cpp"
  163. #include "format_types/juce_LADSPAPluginFormat.cpp"
  164. #include "format_types/juce_VSTPluginFormat.cpp"
  165. #include "format_types/juce_VST3PluginFormat.cpp"
  166. #include "format_types/juce_AudioUnitPluginFormat.mm"
  167. #include "format_types/juce_ARAHosting.cpp"
  168. #include "scanning/juce_KnownPluginList.cpp"
  169. #include "scanning/juce_PluginDirectoryScanner.cpp"
  170. #include "scanning/juce_PluginListComponent.cpp"
  171. #include "processors/juce_AudioProcessorParameterGroup.cpp"
  172. #include "utilities/juce_AudioProcessorParameterWithID.cpp"
  173. #include "utilities/juce_RangedAudioParameter.cpp"
  174. #include "utilities/juce_AudioParameterFloat.cpp"
  175. #include "utilities/juce_AudioParameterInt.cpp"
  176. #include "utilities/juce_AudioParameterBool.cpp"
  177. #include "utilities/juce_AudioParameterChoice.cpp"
  178. #include "utilities/juce_ParameterAttachments.cpp"
  179. #include "utilities/juce_AudioProcessorValueTreeState.cpp"
  180. #include "utilities/juce_PluginHostType.cpp"
  181. #include "utilities/juce_AAXClientExtensions.cpp"
  182. #include "utilities/juce_VST2ClientExtensions.cpp"
  183. #include "utilities/ARA/juce_ARA_utils.cpp"
  184. #include "format_types/juce_LV2PluginFormat.cpp"
  185. #if JUCE_UNIT_TESTS
  186. #if JUCE_PLUGINHOST_VST3
  187. #include "format_types/juce_VST3PluginFormat_test.cpp"
  188. #endif
  189. #if JUCE_PLUGINHOST_LV2 && (! (JUCE_ANDROID || JUCE_IOS))
  190. #include "format_types/juce_LV2PluginFormat_test.cpp"
  191. #endif
  192. #endif