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.

236 lines
7.8KB

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