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.

254 lines
8.1KB

  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. #include "juce_audio_processors.h"
  31. #include <juce_gui_extra/juce_gui_extra.h>
  32. //==============================================================================
  33. #if JUCE_MAC
  34. #if JUCE_SUPPORT_CARBON && (JUCE_PLUGINHOST_VST || JUCE_PLUGINHOST_AU)
  35. #include <Carbon/Carbon.h>
  36. #include <juce_gui_extra/native/juce_mac_CarbonViewWrapperComponent.h>
  37. #endif
  38. #endif
  39. #if (JUCE_PLUGINHOST_VST || JUCE_PLUGINHOST_VST3) && JUCE_LINUX
  40. #include <X11/Xlib.h>
  41. #include <X11/Xutil.h>
  42. #include <sys/utsname.h>
  43. #undef KeyPress
  44. #endif
  45. #if ! JUCE_WINDOWS && ! JUCE_MAC && ! JUCE_LINUX
  46. #undef JUCE_PLUGINHOST_VST3
  47. #define JUCE_PLUGINHOST_VST3 0
  48. #endif
  49. #if JUCE_PLUGINHOST_AU && (JUCE_MAC || JUCE_IOS)
  50. #include <AudioUnit/AudioUnit.h>
  51. #endif
  52. //==============================================================================
  53. namespace juce
  54. {
  55. #if JUCE_PLUGINHOST_VST || (JUCE_PLUGINHOST_LADSPA && JUCE_LINUX)
  56. static bool arrayContainsPlugin (const OwnedArray<PluginDescription>& list,
  57. const PluginDescription& desc)
  58. {
  59. for (auto* p : list)
  60. if (p->isDuplicateOf (desc))
  61. return true;
  62. return false;
  63. }
  64. #endif
  65. #if JUCE_WINDOWS
  66. //==============================================================================
  67. class HWNDComponentWithParent : public HWNDComponent,
  68. private Timer
  69. {
  70. public:
  71. HWNDComponentWithParent()
  72. {
  73. String className ("JUCE_");
  74. className << String::toHexString (Time::getHighResolutionTicks());
  75. HMODULE moduleHandle = (HMODULE) Process::getCurrentModuleInstanceHandle();
  76. WNDCLASSEX wc = {};
  77. wc.cbSize = sizeof (wc);
  78. wc.lpfnWndProc = (WNDPROC) wndProc;
  79. wc.cbWndExtra = 4;
  80. wc.hInstance = moduleHandle;
  81. wc.lpszClassName = className.toWideCharPointer();
  82. atom = RegisterClassEx (&wc);
  83. jassert (atom != 0);
  84. hwnd = CreateWindow (getClassNameFromAtom(), L"HWNDComponentWithParent",
  85. 0, 0, 0, 0, 0,
  86. nullptr, nullptr, moduleHandle, nullptr);
  87. jassert (hwnd != nullptr);
  88. setHWND (hwnd);
  89. startTimer (30);
  90. }
  91. ~HWNDComponentWithParent() override
  92. {
  93. if (IsWindow (hwnd))
  94. DestroyWindow (hwnd);
  95. UnregisterClass (getClassNameFromAtom(), nullptr);
  96. }
  97. private:
  98. //==============================================================================
  99. static LRESULT CALLBACK wndProc (HWND h, const UINT message, const WPARAM wParam, const LPARAM lParam)
  100. {
  101. if (message == WM_SHOWWINDOW && wParam == TRUE)
  102. return 0;
  103. return DefWindowProc (h, message, wParam, lParam);
  104. }
  105. void timerCallback() override
  106. {
  107. if (HWND child = getChildHWND())
  108. {
  109. stopTimer();
  110. ShowWindow (child, SW_HIDE);
  111. SetParent (child, NULL);
  112. auto windowFlags = GetWindowLongPtr (child, -16);
  113. windowFlags &= ~WS_CHILD;
  114. windowFlags |= WS_POPUP;
  115. SetWindowLongPtr (child, -16, windowFlags);
  116. setHWND (child);
  117. }
  118. }
  119. LPCTSTR getClassNameFromAtom() noexcept { return (LPCTSTR) (pointer_sized_uint) atom; }
  120. HWND getChildHWND() const
  121. {
  122. if (HWND parent = (HWND) getHWND())
  123. return GetWindow (parent, GW_CHILD);
  124. return nullptr;
  125. }
  126. //==============================================================================
  127. ATOM atom;
  128. HWND hwnd;
  129. //==============================================================================
  130. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (HWNDComponentWithParent)
  131. };
  132. #elif JUCE_MAC || JUCE_IOS
  133. #if JUCE_IOS
  134. #define JUCE_IOS_MAC_VIEW UIView
  135. using ViewComponentBaseClass = UIViewComponent;
  136. #else
  137. #define JUCE_IOS_MAC_VIEW NSView
  138. using ViewComponentBaseClass = NSViewComponent;
  139. #endif
  140. //==============================================================================
  141. struct AutoResizingNSViewComponent : public ViewComponentBaseClass,
  142. private AsyncUpdater
  143. {
  144. void childBoundsChanged (Component*) override { triggerAsyncUpdate(); }
  145. void handleAsyncUpdate() override { resizeToFitView(); }
  146. };
  147. //==============================================================================
  148. struct AutoResizingNSViewComponentWithParent : public AutoResizingNSViewComponent,
  149. private Timer
  150. {
  151. AutoResizingNSViewComponentWithParent()
  152. {
  153. JUCE_IOS_MAC_VIEW* v = [[JUCE_IOS_MAC_VIEW alloc] init];
  154. setView (v);
  155. [v release];
  156. startTimer (30);
  157. }
  158. JUCE_IOS_MAC_VIEW* getChildView() const
  159. {
  160. if (JUCE_IOS_MAC_VIEW* parent = (JUCE_IOS_MAC_VIEW*) getView())
  161. if ([[parent subviews] count] > 0)
  162. return [[parent subviews] objectAtIndex: 0];
  163. return nil;
  164. }
  165. void timerCallback() override
  166. {
  167. if (JUCE_IOS_MAC_VIEW* child = getChildView())
  168. {
  169. stopTimer();
  170. setView (child);
  171. }
  172. }
  173. };
  174. #endif
  175. } // namespace juce
  176. #include "format/juce_AudioPluginFormat.cpp"
  177. #include "format/juce_AudioPluginFormatManager.cpp"
  178. #include "format_types/juce_LegacyAudioParameter.cpp"
  179. #include "processors/juce_AudioProcessor.cpp"
  180. #include "processors/juce_AudioPluginInstance.cpp"
  181. #include "processors/juce_AudioProcessorEditor.cpp"
  182. #include "processors/juce_AudioProcessorGraph.cpp"
  183. #include "processors/juce_GenericAudioProcessorEditor.cpp"
  184. #include "processors/juce_PluginDescription.cpp"
  185. #include "format_types/juce_LADSPAPluginFormat.cpp"
  186. #include "format_types/juce_VSTPluginFormat.cpp"
  187. #include "format_types/juce_VST3PluginFormat.cpp"
  188. #include "format_types/juce_AudioUnitPluginFormat.mm"
  189. #include "scanning/juce_KnownPluginList.cpp"
  190. #include "scanning/juce_PluginDirectoryScanner.cpp"
  191. #include "scanning/juce_PluginListComponent.cpp"
  192. #include "processors/juce_AudioProcessorParameterGroup.cpp"
  193. #include "utilities/juce_AudioProcessorParameterWithID.cpp"
  194. #include "utilities/juce_RangedAudioParameter.cpp"
  195. #include "utilities/juce_AudioParameterFloat.cpp"
  196. #include "utilities/juce_AudioParameterInt.cpp"
  197. #include "utilities/juce_AudioParameterBool.cpp"
  198. #include "utilities/juce_AudioParameterChoice.cpp"
  199. #include "utilities/juce_ParameterAttachments.cpp"
  200. #include "utilities/juce_AudioProcessorValueTreeState.cpp"