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.

225 lines
7.8KB

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