JUCE-7.0.12-0-g4f43011b96 JUCE-7.0.12-0-g4f43011b96
JUCE — C++ application framework with suport for VST, VST3, LV2 audio plug-ins

« « « Anklang Documentation
Loading...
Searching...
No Matches
juce_audio_processors.cpp
Go to the documentation of this file.
1 /*
2 ==============================================================================
3
4 This file is part of the JUCE library.
5 Copyright (c) 2022 - Raw Material Software Limited
6
7 JUCE is an open source library subject to commercial or open-source
8 licensing.
9
10 By using JUCE, you agree to the terms of both the JUCE 7 End-User License
11 Agreement and JUCE Privacy Policy.
12
13 End User License Agreement: www.juce.com/juce-7-licence
14 Privacy Policy: www.juce.com/juce-privacy-policy
15
16 Or: You may also use this code under the terms of the GPL v3 (see
17 www.gnu.org/licenses).
18
19 JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
20 EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
21 DISCLAIMED.
22
23 ==============================================================================
24*/
25
26#ifdef JUCE_AUDIO_PROCESSORS_H_INCLUDED
27 /* When you add this cpp file to your project, you mustn't include it in a file where you've
28 already included any other headers - just put it inside a file on its own, possibly with your config
29 flags preceding it, but don't include anything else. That also includes avoiding any automatic prefix
30 header files that the compiler may be using.
31 */
32 #error "Incorrect use of JUCE cpp file"
33#endif
34
35#define JUCE_CORE_INCLUDE_NATIVE_HEADERS 1
36#define JUCE_CORE_INCLUDE_OBJC_HELPERS 1
37#define JUCE_GUI_BASICS_INCLUDE_XHEADERS 1
38#define JUCE_GUI_BASICS_INCLUDE_SCOPED_THREAD_DPI_AWARENESS_SETTER 1
39#define JUCE_GRAPHICS_INCLUDE_COREGRAPHICS_HELPERS 1
40
43
44//==============================================================================
45#if (JUCE_PLUGINHOST_VST || JUCE_PLUGINHOST_VST3) && (JUCE_LINUX || JUCE_BSD)
46 JUCE_BEGIN_IGNORE_WARNINGS_GCC_LIKE ("-Wvariadic-macros")
47 #include <X11/Xlib.h>
48 JUCE_END_IGNORE_WARNINGS_GCC_LIKE
49 #include <X11/Xutil.h>
50 #include <sys/utsname.h>
51 #undef KeyPress
52#endif
53
54#if ! JUCE_WINDOWS && ! JUCE_MAC && ! JUCE_LINUX
55 #undef JUCE_PLUGINHOST_VST3
56 #define JUCE_PLUGINHOST_VST3 0
57#endif
58
59#if JUCE_PLUGINHOST_AU && (JUCE_MAC || JUCE_IOS)
60 #include <AudioUnit/AudioUnit.h>
61#endif
62
63namespace juce
64{
65
66#if JUCE_PLUGINHOST_VST || (JUCE_PLUGINHOST_LADSPA && (JUCE_LINUX || JUCE_BSD))
67
69 const PluginDescription& desc)
70{
71 for (auto* p : list)
72 if (p->isDuplicateOf (desc))
74
75 return false;
76}
77
78#endif
79
80template <typename Callback>
81void callOnMessageThread (Callback&& callback)
82{
83 if (MessageManager::getInstance()->existsAndIsLockedByCurrentThread())
84 {
85 callback();
86 return;
87 }
88
89 WaitableEvent completionEvent;
90
92 {
93 callback();
94 completionEvent.signal();
95 });
96
97 completionEvent.wait();
98}
99
100#if JUCE_MAC
101
102//==============================================================================
103/* This is an NSViewComponent which holds a long-lived NSView which acts
104 as the parent view for plugin editors.
105
106 Note that this component does not auto-resize depending on the bounds
107 of the owned view. VST2 and VST3 plugins have dedicated interfaces to
108 request that the editor bounds are updated. We can call `setSize` on this
109 component from inside those dedicated callbacks.
110*/
111struct NSViewComponentWithParent : public NSViewComponent,
112 private AsyncUpdater
113{
114 enum class WantsNudge { no, yes };
115
118 {
119 auto* view = [[getViewClass().createInstance() init] autorelease];
120 object_setInstanceVariable (view, "owner", this);
121 setView (view);
122 }
123
124 explicit NSViewComponentWithParent (AudioPluginInstance& instance)
126
128 {
129 if (auto* view = static_cast<NSView*> (getView()))
130 object_setInstanceVariable (view, "owner", nullptr);
131
132 cancelPendingUpdate();
133 }
134
137
138private:
139 WantsNudge wantsNudge = WantsNudge::no;
140
141 static WantsNudge getWantsNudge (AudioPluginInstance& instance)
142 {
143 PluginDescription pd;
144 instance.fillInPluginDescription (pd);
145 return pd.manufacturerName == "FabFilter" ? WantsNudge::yes : WantsNudge::no;
146 }
147
148 void handleAsyncUpdate() override
149 {
150 if (auto* peer = getTopLevelComponent()->getPeer())
151 {
152 auto* view = static_cast<NSView*> (getView());
153 const auto newArea = peer->getAreaCoveredBy (*this);
154 [view setFrame: makeNSRect (newArea.withHeight (newArea.getHeight() + 1))];
155 [view setFrame: makeNSRect (newArea)];
156 }
157 }
158
159 struct InnerNSView final : public ObjCClass<NSView>
160 {
161 InnerNSView()
162 : ObjCClass ("JuceInnerNSView_")
163 {
164 addIvar<NSViewComponentWithParent*> ("owner");
165
166 addMethod (@selector (isOpaque), [] (id, SEL) { return YES; });
167
168 addMethod (@selector (didAddSubview:), [] (id self, SEL, NSView*)
169 {
170 if (auto* owner = getIvar<NSViewComponentWithParent*> (self, "owner"))
171 if (owner->wantsNudge == WantsNudge::yes)
172 owner->triggerAsyncUpdate();
173 });
174
175 JUCE_BEGIN_IGNORE_WARNINGS_GCC_LIKE ("-Wundeclared-selector")
176 addMethod (@selector (clipsToBounds), [] (id, SEL) { return YES; });
177 JUCE_END_IGNORE_WARNINGS_GCC_LIKE
178
179 registerClass();
180 }
181 };
182
183 static InnerNSView& getViewClass()
184 {
185 static InnerNSView result;
186 return result;
187 }
188};
189
190#endif
191
192} // namespace juce
193
208#include "format_types/juce_AudioUnitPluginFormat.mm"
226
228
229#if JUCE_UNIT_TESTS
230 #if JUCE_PLUGINHOST_VST3
231 #include "format_types/juce_VST3PluginFormat_test.cpp"
232 #endif
233
234 #if JUCE_PLUGINHOST_LV2 && (! (JUCE_ANDROID || JUCE_IOS))
235 #include "format_types/juce_LV2PluginFormat_test.cpp"
236 #endif
237#endif
static bool callAsync(std::function< void()> functionToCall)
Asynchronously invokes a function or C++11 lambda on the message thread.
static MessageManager * getInstance()
Returns the global instance of the MessageManager.
#define JUCE_DECLARE_NON_MOVEABLE(className)
This is a shorthand macro for deleting a class's move constructor and move assignment operator.
#define JUCE_DECLARE_NON_COPYABLE(className)
This is a shorthand macro for deleting a class's copy constructor and copy assignment operator.
JUCE Namespace.
Type unalignedPointerCast(void *ptr) noexcept
Casts a pointer to another type via void*, which suppresses the cast-align warning which sometimes ar...
Definition juce_Memory.h:88