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.

213 lines
7.5KB

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