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.

230 lines
7.9KB

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