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.

237 lines
8.1KB

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