LMMS
Loading...
Searching...
No Matches
juce_AudioPluginFormatManager.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
26namespace juce
27{
28
31
32//==============================================================================
34{
35 #if JUCE_PLUGINHOST_VST && (JUCE_MAC || JUCE_WINDOWS || JUCE_LINUX || JUCE_BSD || JUCE_IOS)
36 #define HAS_VST 1
37 #else
38 #define HAS_VST 0
39 #endif
40
41 #if JUCE_PLUGINHOST_VST3 && (JUCE_MAC || JUCE_WINDOWS || JUCE_LINUX || JUCE_BSD)
42 #define HAS_VST3 1
43 #else
44 #define HAS_VST3 0
45 #endif
46
47 #if JUCE_PLUGINHOST_AU && (JUCE_MAC || JUCE_IOS)
48 #define HAS_AU 1
49 #else
50 #define HAS_AU 0
51 #endif
52
53 #if JUCE_PLUGINHOST_LADSPA && (JUCE_LINUX || JUCE_BSD)
54 #define HAS_LADSPA 1
55 #else
56 #define HAS_LADSPA 0
57 #endif
58
59 #if JUCE_PLUGINHOST_LV2 && (JUCE_MAC || JUCE_LINUX || JUCE_BSD || JUCE_WINDOWS)
60 #define HAS_LV2 1
61 #else
62 #define HAS_LV2 0
63 #endif
64
65 #if JUCE_DEBUG
66 // you should only call this method once!
67 for (auto* format : formats)
68 {
70
71 #if HAS_VST
72 jassert (dynamic_cast<VSTPluginFormat*> (format) == nullptr);
73 #endif
74
75 #if HAS_VST3
76 jassert (dynamic_cast<VST3PluginFormat*> (format) == nullptr);
77 #endif
78
79 #if HAS_AU
80 jassert (dynamic_cast<AudioUnitPluginFormat*> (format) == nullptr);
81 #endif
82
83 #if HAS_LADSPA
84 jassert (dynamic_cast<LADSPAPluginFormat*> (format) == nullptr);
85 #endif
86
87 #if HAS_LV2
88 jassert (dynamic_cast<LV2PluginFormat*> (format) == nullptr);
89 #endif
90 }
91 #endif
92
93 #if HAS_AU
94 formats.add (new AudioUnitPluginFormat());
95 #endif
96
97 #if HAS_VST
98 formats.add (new VSTPluginFormat());
99 #endif
100
101 #if HAS_VST3
102 formats.add (new VST3PluginFormat());
103 #endif
104
105 #if HAS_LADSPA
106 formats.add (new LADSPAPluginFormat());
107 #endif
108
109 #if HAS_LV2
110 formats.add (new LV2PluginFormat());
111 #endif
112}
113
116
123
128
129std::unique_ptr<AudioPluginInstance> AudioPluginFormatManager::createPluginInstance (const PluginDescription& description,
130 double rate, int blockSize,
131 String& errorMessage) const
132{
133 if (auto* format = findFormatForDescription (description, errorMessage))
134 return format->createInstanceFromDescription (description, rate, blockSize, errorMessage);
135
136 return {};
137}
138
141{
142 String errorMessage;
143
144 if (auto* format = findFormatForDescription (description, errorMessage))
145 {
146 format->createARAFactoryAsync (description, callback);
147 }
148 else
149 {
150 errorMessage = NEEDS_TRANS ("Couldn't find format for the provided description");
151 callback ({ {}, std::move (errorMessage) });
152 }
153}
154
156 double initialSampleRate, int initialBufferSize,
158{
160
161 if (auto* format = findFormatForDescription (description, error))
162 return format->createPluginInstanceAsync (description, initialSampleRate, initialBufferSize, std::move (callback));
163
164 struct DeliverError : public CallbackMessage
165 {
167 : call (std::move (c)), error (e)
168 {
169 post();
170 }
171
172 void messageCallback() override { call (nullptr, error); }
173
176 };
177
178 new DeliverError (std::move (callback), error);
179}
180
182 String& errorMessage) const
183{
184 errorMessage = {};
185
186 for (auto* format : formats)
187 if (format->getName() == description.pluginFormatName
188 && format->fileMightContainThisPluginType (description.fileOrIdentifier))
189 return format;
190
191 errorMessage = NEEDS_TRANS ("No compatible plug-in format exists for this plug-in");
192
193 return {};
194}
195
197{
198 for (auto* format : formats)
199 if (format->getName() == description.pluginFormatName)
200 return format->doesPluginStillExist (description);
201
202 return false;
203}
204
205} // namespace juce
uint8_t a
Definition Spc_Cpu.h:141
Definition juce_Array.h:56
Definition juce_AudioPluginFormat.h:38
std::function< void(ARAFactoryResult)> ARAFactoryCreationCallback
Definition juce_AudioPluginFormat.h:144
std::function< void(std::unique_ptr< AudioPluginInstance >, const String &)> PluginCreationCallback
Definition juce_AudioPluginFormat.h:77
AudioPluginFormat * findFormatForDescription(const PluginDescription &, String &errorMessage) const
Definition juce_AudioPluginFormatManager.cpp:181
Array< AudioPluginFormat * > getFormats() const
Definition juce_AudioPluginFormatManager.cpp:117
AudioPluginFormat * getFormat(int index) const
Definition juce_AudioPluginFormatManager.cpp:115
int getNumFormats() const
Definition juce_AudioPluginFormatManager.cpp:114
bool doesPluginStillExist(const PluginDescription &) const
Definition juce_AudioPluginFormatManager.cpp:196
AudioPluginFormatManager()
Definition juce_AudioPluginFormatManager.cpp:29
void addFormat(AudioPluginFormat *)
Definition juce_AudioPluginFormatManager.cpp:124
std::unique_ptr< AudioPluginInstance > createPluginInstance(const PluginDescription &description, double initialSampleRate, int initialBufferSize, String &errorMessage) const
Definition juce_AudioPluginFormatManager.cpp:129
~AudioPluginFormatManager()
Definition juce_AudioPluginFormatManager.cpp:30
void createARAFactoryAsync(const PluginDescription &description, AudioPluginFormat::ARAFactoryCreationCallback callback) const
Definition juce_AudioPluginFormatManager.cpp:139
OwnedArray< AudioPluginFormat > formats
Definition juce_AudioPluginFormatManager.h:137
void createPluginInstanceAsync(const PluginDescription &description, double initialSampleRate, int initialBufferSize, AudioPluginFormat::PluginCreationCallback callback)
Definition juce_AudioPluginFormatManager.cpp:155
void addDefaultFormats()
Definition juce_AudioPluginFormatManager.cpp:33
Definition juce_CallbackMessage.h:49
Definition juce_PluginDescription.h:43
String pluginFormatName
Definition juce_PluginDescription.h:65
String fileOrIdentifier
Definition juce_PluginDescription.h:82
Definition juce_String.h:53
* e
Definition inflate.c:1404
#define NEEDS_TRANS(stringLiteral)
Definition juce_LocalisedStrings.h:218
#define jassert(expression)
Definition carla_juce.cpp:31
void ignoreUnused(Types &&...) noexcept
Definition juce_MathsFunctions.h:333
RECT const char void(* callback)(const char *droppath))) SWELL_API_DEFINE(BOOL
Definition swell-functions.h:1004
return c
Definition crypt.c:175
int error
Definition extract.c:1038
ZCONST char * post
Definition fileio.c:2493
_WDL_CSTRING_PREFIX void INT_PTR const char * format
Definition wdlcstring.h:263