fix macOS build (following Projucer changes made in Windows, which removed /Applications/JUCE/modules from its headers). move JUCE headers under source control, so that Windows and macOS can both build against same version of JUCE. remove AUv3 target (I think it's an iOS thing, so it will never work with this macOS fluidsynth dylib).
This commit is contained in:
214
modules/juce_audio_processors/format/juce_AudioPluginFormat.cpp
Normal file
214
modules/juce_audio_processors/format/juce_AudioPluginFormat.cpp
Normal file
@ -0,0 +1,214 @@
|
||||
/*
|
||||
==============================================================================
|
||||
|
||||
This file is part of the JUCE library.
|
||||
Copyright (c) 2017 - ROLI Ltd.
|
||||
|
||||
JUCE is an open source library subject to commercial or open-source
|
||||
licensing.
|
||||
|
||||
By using JUCE, you agree to the terms of both the JUCE 5 End-User License
|
||||
Agreement and JUCE 5 Privacy Policy (both updated and effective as of the
|
||||
27th April 2017).
|
||||
|
||||
End User License Agreement: www.juce.com/juce-5-licence
|
||||
Privacy Policy: www.juce.com/juce-5-privacy-policy
|
||||
|
||||
Or: You may also use this code under the terms of the GPL v3 (see
|
||||
www.gnu.org/licenses).
|
||||
|
||||
JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
|
||||
EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
|
||||
DISCLAIMED.
|
||||
|
||||
==============================================================================
|
||||
*/
|
||||
|
||||
namespace juce
|
||||
{
|
||||
|
||||
namespace AudioPluginFormatHelpers
|
||||
{
|
||||
struct CallbackInvoker
|
||||
{
|
||||
struct InvokeOnMessageThread : public CallbackMessage
|
||||
{
|
||||
InvokeOnMessageThread (AudioPluginInstance* inInstance, const String& inError,
|
||||
AudioPluginFormat::InstantiationCompletionCallback* inCompletion,
|
||||
CallbackInvoker* invoker)
|
||||
: instance (inInstance), error (inError), compCallback (inCompletion), owner (invoker)
|
||||
{}
|
||||
|
||||
void messageCallback() override { compCallback->completionCallback (instance, error); }
|
||||
|
||||
//==============================================================================
|
||||
AudioPluginInstance* instance;
|
||||
String error;
|
||||
std::unique_ptr<AudioPluginFormat::InstantiationCompletionCallback> compCallback;
|
||||
std::unique_ptr<CallbackInvoker> owner;
|
||||
};
|
||||
|
||||
//==============================================================================
|
||||
CallbackInvoker (AudioPluginFormat::InstantiationCompletionCallback* cc) : completion (cc)
|
||||
{}
|
||||
|
||||
void completionCallback (AudioPluginInstance* instance, const String& error)
|
||||
{
|
||||
(new InvokeOnMessageThread (instance, error, completion, this))->post();
|
||||
}
|
||||
|
||||
static void staticCompletionCallback (void* userData, AudioPluginInstance* instance, const String& error)
|
||||
{
|
||||
reinterpret_cast<CallbackInvoker*> (userData)->completionCallback (instance, error);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
AudioPluginFormat::InstantiationCompletionCallback* completion;
|
||||
};
|
||||
}
|
||||
|
||||
AudioPluginFormat::AudioPluginFormat() noexcept {}
|
||||
AudioPluginFormat::~AudioPluginFormat() {}
|
||||
|
||||
AudioPluginInstance* AudioPluginFormat::createInstanceFromDescription (const PluginDescription& desc,
|
||||
double initialSampleRate,
|
||||
int initialBufferSize)
|
||||
{
|
||||
String errorMessage;
|
||||
return createInstanceFromDescription (desc, initialSampleRate, initialBufferSize, errorMessage);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
struct EventSignaler : public AudioPluginFormat::InstantiationCompletionCallback
|
||||
{
|
||||
EventSignaler (WaitableEvent& inEvent, AudioPluginInstance*& inInstance, String& inErrorMessage)
|
||||
: event (inEvent), outInstance (inInstance), outErrorMessage (inErrorMessage)
|
||||
{}
|
||||
|
||||
void completionCallback (AudioPluginInstance* newInstance, const String& result) override
|
||||
{
|
||||
outInstance = newInstance;
|
||||
outErrorMessage = result;
|
||||
event.signal();
|
||||
}
|
||||
|
||||
static void staticCompletionCallback (void* userData, AudioPluginInstance* pluginInstance, const String& error)
|
||||
{
|
||||
reinterpret_cast<EventSignaler*> (userData)->completionCallback (pluginInstance, error);
|
||||
}
|
||||
|
||||
WaitableEvent& event;
|
||||
AudioPluginInstance*& outInstance;
|
||||
String& outErrorMessage;
|
||||
|
||||
JUCE_DECLARE_NON_COPYABLE (EventSignaler)
|
||||
};
|
||||
|
||||
AudioPluginInstance* AudioPluginFormat::createInstanceFromDescription (const PluginDescription& desc,
|
||||
double initialSampleRate,
|
||||
int initialBufferSize,
|
||||
String& errorMessage)
|
||||
{
|
||||
if (MessageManager::getInstance()->isThisTheMessageThread()
|
||||
&& requiresUnblockedMessageThreadDuringCreation(desc))
|
||||
{
|
||||
errorMessage = NEEDS_TRANS ("This plug-in cannot be instantiated synchronously");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
WaitableEvent waitForCreation;
|
||||
AudioPluginInstance* instance = nullptr;
|
||||
|
||||
std::unique_ptr<EventSignaler> eventSignaler (new EventSignaler (waitForCreation, instance, errorMessage));
|
||||
|
||||
if (! MessageManager::getInstance()->isThisTheMessageThread())
|
||||
createPluginInstanceAsync (desc, initialSampleRate, initialBufferSize, eventSignaler.release());
|
||||
else
|
||||
createPluginInstance (desc, initialSampleRate, initialBufferSize,
|
||||
eventSignaler.get(), EventSignaler::staticCompletionCallback);
|
||||
|
||||
|
||||
waitForCreation.wait();
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
void AudioPluginFormat::createPluginInstanceAsync (const PluginDescription& description,
|
||||
double initialSampleRate,
|
||||
int initialBufferSize,
|
||||
AudioPluginFormat::InstantiationCompletionCallback* callback)
|
||||
{
|
||||
if (MessageManager::getInstance()->isThisTheMessageThread())
|
||||
{
|
||||
createPluginInstanceOnMessageThread (description, initialSampleRate, initialBufferSize, callback);
|
||||
return;
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
struct InvokeOnMessageThread : public CallbackMessage
|
||||
{
|
||||
InvokeOnMessageThread (AudioPluginFormat* myself,
|
||||
const PluginDescription& descriptionParam,
|
||||
double initialSampleRateParam,
|
||||
int initialBufferSizeParam,
|
||||
AudioPluginFormat::InstantiationCompletionCallback* callbackParam)
|
||||
: owner (myself), descr (descriptionParam), sampleRate (initialSampleRateParam),
|
||||
bufferSize (initialBufferSizeParam), call (callbackParam)
|
||||
{}
|
||||
|
||||
void messageCallback() override
|
||||
{
|
||||
owner->createPluginInstanceOnMessageThread (descr, sampleRate, bufferSize, call);
|
||||
}
|
||||
|
||||
AudioPluginFormat* owner;
|
||||
PluginDescription descr;
|
||||
double sampleRate;
|
||||
int bufferSize;
|
||||
AudioPluginFormat::InstantiationCompletionCallback* call;
|
||||
};
|
||||
|
||||
(new InvokeOnMessageThread (this, description, initialSampleRate, initialBufferSize, callback))->post();
|
||||
}
|
||||
|
||||
void AudioPluginFormat::createPluginInstanceAsync (const PluginDescription& description,
|
||||
double initialSampleRate,
|
||||
int initialBufferSize,
|
||||
std::function<void (AudioPluginInstance*, const String&)> f)
|
||||
{
|
||||
struct CallbackInvoker : public AudioPluginFormat::InstantiationCompletionCallback
|
||||
{
|
||||
CallbackInvoker (std::function<void (AudioPluginInstance*, const String&)> inCompletion)
|
||||
: completion (inCompletion)
|
||||
{}
|
||||
|
||||
void completionCallback (AudioPluginInstance* instance, const String& error) override
|
||||
{
|
||||
completion (instance, error);
|
||||
}
|
||||
|
||||
std::function<void (AudioPluginInstance*, const String&)> completion;
|
||||
};
|
||||
|
||||
createPluginInstanceAsync (description, initialSampleRate, initialBufferSize, new CallbackInvoker (f));
|
||||
}
|
||||
|
||||
void AudioPluginFormat::createPluginInstanceOnMessageThread (const PluginDescription& description,
|
||||
double initialSampleRate,
|
||||
int initialBufferSize,
|
||||
AudioPluginFormat::InstantiationCompletionCallback* callback)
|
||||
{
|
||||
jassert (callback != nullptr);
|
||||
jassert (MessageManager::getInstance()->isThisTheMessageThread());
|
||||
|
||||
//==============================================================================
|
||||
|
||||
|
||||
//==============================================================================
|
||||
AudioPluginFormatHelpers::CallbackInvoker* completion = new AudioPluginFormatHelpers::CallbackInvoker (callback);
|
||||
|
||||
createPluginInstance (description, initialSampleRate, initialBufferSize, completion,
|
||||
AudioPluginFormatHelpers::CallbackInvoker::staticCompletionCallback);
|
||||
}
|
||||
|
||||
} // namespace juce
|
171
modules/juce_audio_processors/format/juce_AudioPluginFormat.h
Normal file
171
modules/juce_audio_processors/format/juce_AudioPluginFormat.h
Normal file
@ -0,0 +1,171 @@
|
||||
/*
|
||||
==============================================================================
|
||||
|
||||
This file is part of the JUCE library.
|
||||
Copyright (c) 2017 - ROLI Ltd.
|
||||
|
||||
JUCE is an open source library subject to commercial or open-source
|
||||
licensing.
|
||||
|
||||
By using JUCE, you agree to the terms of both the JUCE 5 End-User License
|
||||
Agreement and JUCE 5 Privacy Policy (both updated and effective as of the
|
||||
27th April 2017).
|
||||
|
||||
End User License Agreement: www.juce.com/juce-5-licence
|
||||
Privacy Policy: www.juce.com/juce-5-privacy-policy
|
||||
|
||||
Or: You may also use this code under the terms of the GPL v3 (see
|
||||
www.gnu.org/licenses).
|
||||
|
||||
JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
|
||||
EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
|
||||
DISCLAIMED.
|
||||
|
||||
==============================================================================
|
||||
*/
|
||||
|
||||
namespace juce
|
||||
{
|
||||
|
||||
//==============================================================================
|
||||
/**
|
||||
The base class for a type of plugin format, such as VST, AudioUnit, LADSPA, etc.
|
||||
|
||||
@see AudioPluginFormatManager
|
||||
|
||||
@tags{Audio}
|
||||
*/
|
||||
class JUCE_API AudioPluginFormat
|
||||
{
|
||||
public:
|
||||
//==============================================================================
|
||||
/** Structure used for callbacks when instantiation is completed. */
|
||||
struct JUCE_API InstantiationCompletionCallback
|
||||
{
|
||||
virtual ~InstantiationCompletionCallback() {}
|
||||
virtual void completionCallback (AudioPluginInstance* instance, const String& error) = 0;
|
||||
|
||||
JUCE_LEAK_DETECTOR (InstantiationCompletionCallback)
|
||||
};
|
||||
|
||||
//==============================================================================
|
||||
/** Destructor. */
|
||||
virtual ~AudioPluginFormat();
|
||||
|
||||
//==============================================================================
|
||||
/** Returns the format name.
|
||||
E.g. "VST", "AudioUnit", etc.
|
||||
*/
|
||||
virtual String getName() const = 0;
|
||||
|
||||
/** This tries to create descriptions for all the plugin types available in
|
||||
a binary module file.
|
||||
|
||||
The file will be some kind of DLL or bundle.
|
||||
|
||||
Normally there will only be one type returned, but some plugins
|
||||
(e.g. VST shells) can use a single DLL to create a set of different plugin
|
||||
subtypes, so in that case, each subtype is returned as a separate object.
|
||||
*/
|
||||
virtual void findAllTypesForFile (OwnedArray<PluginDescription>& results,
|
||||
const String& fileOrIdentifier) = 0;
|
||||
|
||||
/** Tries to recreate a type from a previously generated PluginDescription.
|
||||
@see AudioPluginFormatManager::createInstance
|
||||
*/
|
||||
AudioPluginInstance* createInstanceFromDescription (const PluginDescription&,
|
||||
double initialSampleRate,
|
||||
int initialBufferSize);
|
||||
|
||||
/** Same as above but with the possibility of returning an error message.
|
||||
|
||||
@see AudioPluginFormatManager::createInstance
|
||||
*/
|
||||
AudioPluginInstance* createInstanceFromDescription (const PluginDescription&,
|
||||
double initialSampleRate,
|
||||
int initialBufferSize,
|
||||
String& errorMessage);
|
||||
|
||||
/** Tries to recreate a type from a previously generated PluginDescription.
|
||||
|
||||
@see AudioPluginFormatManager::createInstanceAsync
|
||||
*/
|
||||
void createPluginInstanceAsync (const PluginDescription& description,
|
||||
double initialSampleRate,
|
||||
int initialBufferSize,
|
||||
InstantiationCompletionCallback* completionCallback);
|
||||
|
||||
void createPluginInstanceAsync (const PluginDescription& description,
|
||||
double initialSampleRate,
|
||||
int initialBufferSize,
|
||||
std::function<void (AudioPluginInstance*, const String&)> completionCallback);
|
||||
|
||||
/** Should do a quick check to see if this file or directory might be a plugin of
|
||||
this format.
|
||||
|
||||
This is for searching for potential files, so it shouldn't actually try to
|
||||
load the plugin or do anything time-consuming.
|
||||
*/
|
||||
virtual bool fileMightContainThisPluginType (const String& fileOrIdentifier) = 0;
|
||||
|
||||
/** Returns a readable version of the name of the plugin that this identifier refers to. */
|
||||
virtual String getNameOfPluginFromIdentifier (const String& fileOrIdentifier) = 0;
|
||||
|
||||
/** Returns true if this plugin's version or date has changed and it should be re-checked. */
|
||||
virtual bool pluginNeedsRescanning (const PluginDescription&) = 0;
|
||||
|
||||
/** Checks whether this plugin could possibly be loaded.
|
||||
It doesn't actually need to load it, just to check whether the file or component
|
||||
still exists.
|
||||
*/
|
||||
virtual bool doesPluginStillExist (const PluginDescription&) = 0;
|
||||
|
||||
/** Returns true if this format needs to run a scan to find its list of plugins. */
|
||||
virtual bool canScanForPlugins() const = 0;
|
||||
|
||||
/** Searches a suggested set of directories for any plugins in this format.
|
||||
The path might be ignored, e.g. by AUs, which are found by the OS rather
|
||||
than manually.
|
||||
|
||||
@param directoriesToSearch This specifies which directories shall be
|
||||
searched for plug-ins.
|
||||
@param recursive Should the search recursively traverse folders.
|
||||
@param allowPluginsWhichRequireAsynchronousInstantiation
|
||||
If this is false then plug-ins which require
|
||||
asynchronous creation will be excluded.
|
||||
*/
|
||||
virtual StringArray searchPathsForPlugins (const FileSearchPath& directoriesToSearch,
|
||||
bool recursive,
|
||||
bool allowPluginsWhichRequireAsynchronousInstantiation = false) = 0;
|
||||
|
||||
/** Returns the typical places to look for this kind of plugin.
|
||||
|
||||
Note that if this returns no paths, it means that the format doesn't search in
|
||||
files or folders, e.g. AudioUnits.
|
||||
*/
|
||||
virtual FileSearchPath getDefaultLocationsToSearch() = 0;
|
||||
|
||||
protected:
|
||||
//==============================================================================
|
||||
friend class AudioPluginFormatManager;
|
||||
|
||||
AudioPluginFormat() noexcept;
|
||||
|
||||
/** Implementors must override this function. This is guaranteed to be called on
|
||||
the message thread. You may call the callback on any thread.
|
||||
*/
|
||||
virtual void createPluginInstance (const PluginDescription&, double initialSampleRate,
|
||||
int initialBufferSize, void* userData,
|
||||
void (*callback) (void*, AudioPluginInstance*, const String&)) = 0;
|
||||
|
||||
virtual bool requiresUnblockedMessageThreadDuringCreation (const PluginDescription&) const noexcept = 0;
|
||||
|
||||
private:
|
||||
/** @internal */
|
||||
void createPluginInstanceOnMessageThread (const PluginDescription&, double rate, int size,
|
||||
AudioPluginFormat::InstantiationCompletionCallback*);
|
||||
|
||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AudioPluginFormat)
|
||||
};
|
||||
|
||||
} // namespace juce
|
@ -0,0 +1,182 @@
|
||||
/*
|
||||
==============================================================================
|
||||
|
||||
This file is part of the JUCE library.
|
||||
Copyright (c) 2017 - ROLI Ltd.
|
||||
|
||||
JUCE is an open source library subject to commercial or open-source
|
||||
licensing.
|
||||
|
||||
By using JUCE, you agree to the terms of both the JUCE 5 End-User License
|
||||
Agreement and JUCE 5 Privacy Policy (both updated and effective as of the
|
||||
27th April 2017).
|
||||
|
||||
End User License Agreement: www.juce.com/juce-5-licence
|
||||
Privacy Policy: www.juce.com/juce-5-privacy-policy
|
||||
|
||||
Or: You may also use this code under the terms of the GPL v3 (see
|
||||
www.gnu.org/licenses).
|
||||
|
||||
JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
|
||||
EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
|
||||
DISCLAIMED.
|
||||
|
||||
==============================================================================
|
||||
*/
|
||||
|
||||
namespace juce
|
||||
{
|
||||
|
||||
namespace PluginFormatManagerHelpers
|
||||
{
|
||||
struct ErrorCallbackOnMessageThread : public CallbackMessage
|
||||
{
|
||||
ErrorCallbackOnMessageThread (const String& inError,
|
||||
AudioPluginFormat::InstantiationCompletionCallback* c)
|
||||
: error (inError), callback (c)
|
||||
{
|
||||
}
|
||||
|
||||
void messageCallback() override { callback->completionCallback (nullptr, error); }
|
||||
|
||||
String error;
|
||||
std::unique_ptr<AudioPluginFormat::InstantiationCompletionCallback> callback;
|
||||
};
|
||||
|
||||
struct ErrorLambdaOnMessageThread : public CallbackMessage
|
||||
{
|
||||
ErrorLambdaOnMessageThread (const String& inError,
|
||||
std::function<void (AudioPluginInstance*, const String&)> f)
|
||||
: error (inError), lambda (f)
|
||||
{
|
||||
}
|
||||
|
||||
void messageCallback() override { lambda (nullptr, error); }
|
||||
|
||||
String error;
|
||||
std::function<void (AudioPluginInstance*, const String&)> lambda;
|
||||
};
|
||||
}
|
||||
|
||||
AudioPluginFormatManager::AudioPluginFormatManager() {}
|
||||
AudioPluginFormatManager::~AudioPluginFormatManager() {}
|
||||
|
||||
//==============================================================================
|
||||
void AudioPluginFormatManager::addDefaultFormats()
|
||||
{
|
||||
#if JUCE_DEBUG
|
||||
// you should only call this method once!
|
||||
for (auto* format : formats)
|
||||
{
|
||||
ignoreUnused (format);
|
||||
|
||||
#if JUCE_PLUGINHOST_VST && (JUCE_MAC || JUCE_WINDOWS || JUCE_LINUX || JUCE_IOS)
|
||||
jassert (dynamic_cast<VSTPluginFormat*> (format) == nullptr);
|
||||
#endif
|
||||
|
||||
#if JUCE_PLUGINHOST_VST3 && (JUCE_MAC || JUCE_WINDOWS)
|
||||
jassert (dynamic_cast<VST3PluginFormat*> (format) == nullptr);
|
||||
#endif
|
||||
|
||||
#if JUCE_PLUGINHOST_AU && (JUCE_MAC || JUCE_IOS)
|
||||
jassert (dynamic_cast<AudioUnitPluginFormat*> (format) == nullptr);
|
||||
#endif
|
||||
|
||||
#if JUCE_PLUGINHOST_LADSPA && JUCE_LINUX
|
||||
jassert (dynamic_cast<LADSPAPluginFormat*> (format) == nullptr);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#if JUCE_PLUGINHOST_AU && (JUCE_MAC || JUCE_IOS)
|
||||
formats.add (new AudioUnitPluginFormat());
|
||||
#endif
|
||||
|
||||
#if JUCE_PLUGINHOST_VST && (JUCE_MAC || JUCE_WINDOWS || JUCE_LINUX || JUCE_IOS)
|
||||
formats.add (new VSTPluginFormat());
|
||||
#endif
|
||||
|
||||
#if JUCE_PLUGINHOST_VST3 && (JUCE_MAC || JUCE_WINDOWS)
|
||||
formats.add (new VST3PluginFormat());
|
||||
#endif
|
||||
|
||||
#if JUCE_PLUGINHOST_LADSPA && JUCE_LINUX
|
||||
formats.add (new LADSPAPluginFormat());
|
||||
#endif
|
||||
}
|
||||
|
||||
int AudioPluginFormatManager::getNumFormats()
|
||||
{
|
||||
return formats.size();
|
||||
}
|
||||
|
||||
AudioPluginFormat* AudioPluginFormatManager::getFormat (int index)
|
||||
{
|
||||
return formats[index];
|
||||
}
|
||||
|
||||
void AudioPluginFormatManager::addFormat (AudioPluginFormat* format)
|
||||
{
|
||||
formats.add (format);
|
||||
}
|
||||
|
||||
AudioPluginInstance* AudioPluginFormatManager::createPluginInstance (const PluginDescription& description, double rate,
|
||||
int blockSize, String& errorMessage) const
|
||||
{
|
||||
if (auto* format = findFormatForDescription (description, errorMessage))
|
||||
return format->createInstanceFromDescription (description, rate, blockSize, errorMessage);
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void AudioPluginFormatManager::createPluginInstanceAsync (const PluginDescription& description,
|
||||
double initialSampleRate,
|
||||
int initialBufferSize,
|
||||
AudioPluginFormat::InstantiationCompletionCallback* callback)
|
||||
{
|
||||
String error;
|
||||
|
||||
if (auto* format = findFormatForDescription (description, error))
|
||||
return format->createPluginInstanceAsync (description, initialSampleRate, initialBufferSize, callback);
|
||||
|
||||
(new PluginFormatManagerHelpers::ErrorCallbackOnMessageThread (error, callback))->post();
|
||||
}
|
||||
|
||||
void AudioPluginFormatManager::createPluginInstanceAsync (const PluginDescription& description,
|
||||
double initialSampleRate,
|
||||
int initialBufferSize,
|
||||
std::function<void (AudioPluginInstance*, const String&)> f)
|
||||
{
|
||||
String error;
|
||||
|
||||
if (auto* format = findFormatForDescription (description, error))
|
||||
return format->createPluginInstanceAsync (description, initialSampleRate, initialBufferSize, f);
|
||||
|
||||
(new PluginFormatManagerHelpers::ErrorLambdaOnMessageThread (error, f))->post();
|
||||
}
|
||||
|
||||
AudioPluginFormat* AudioPluginFormatManager::findFormatForDescription (const PluginDescription& description,
|
||||
String& errorMessage) const
|
||||
{
|
||||
errorMessage = {};
|
||||
|
||||
for (auto* format : formats)
|
||||
if (format->getName() == description.pluginFormatName
|
||||
&& format->fileMightContainThisPluginType (description.fileOrIdentifier))
|
||||
return format;
|
||||
|
||||
errorMessage = NEEDS_TRANS ("No compatible plug-in format exists for this plug-in");
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool AudioPluginFormatManager::doesPluginStillExist (const PluginDescription& description) const
|
||||
{
|
||||
for (auto* format : formats)
|
||||
if (format->getName() == description.pluginFormatName)
|
||||
return format->doesPluginStillExist (description);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace juce
|
@ -0,0 +1,140 @@
|
||||
/*
|
||||
==============================================================================
|
||||
|
||||
This file is part of the JUCE library.
|
||||
Copyright (c) 2017 - ROLI Ltd.
|
||||
|
||||
JUCE is an open source library subject to commercial or open-source
|
||||
licensing.
|
||||
|
||||
By using JUCE, you agree to the terms of both the JUCE 5 End-User License
|
||||
Agreement and JUCE 5 Privacy Policy (both updated and effective as of the
|
||||
27th April 2017).
|
||||
|
||||
End User License Agreement: www.juce.com/juce-5-licence
|
||||
Privacy Policy: www.juce.com/juce-5-privacy-policy
|
||||
|
||||
Or: You may also use this code under the terms of the GPL v3 (see
|
||||
www.gnu.org/licenses).
|
||||
|
||||
JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
|
||||
EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
|
||||
DISCLAIMED.
|
||||
|
||||
==============================================================================
|
||||
*/
|
||||
|
||||
namespace juce
|
||||
{
|
||||
|
||||
//==============================================================================
|
||||
/**
|
||||
This maintains a list of known AudioPluginFormats.
|
||||
|
||||
@see AudioPluginFormat
|
||||
|
||||
@tags{Audio}
|
||||
*/
|
||||
class JUCE_API AudioPluginFormatManager
|
||||
{
|
||||
public:
|
||||
//==============================================================================
|
||||
AudioPluginFormatManager();
|
||||
|
||||
/** Destructor. */
|
||||
~AudioPluginFormatManager();
|
||||
|
||||
//==============================================================================
|
||||
/** Adds any formats that it knows about, e.g. VST.
|
||||
*/
|
||||
void addDefaultFormats();
|
||||
|
||||
//==============================================================================
|
||||
/** Returns the number of types of format that are available.
|
||||
|
||||
Use getFormat() to get one of them.
|
||||
*/
|
||||
int getNumFormats();
|
||||
|
||||
/** Returns one of the available formats.
|
||||
|
||||
@see getNumFormats
|
||||
*/
|
||||
AudioPluginFormat* getFormat (int index);
|
||||
|
||||
//==============================================================================
|
||||
/** Adds a format to the list.
|
||||
|
||||
The object passed in will be owned and deleted by the manager.
|
||||
*/
|
||||
void addFormat (AudioPluginFormat* format);
|
||||
|
||||
|
||||
//==============================================================================
|
||||
/** Tries to load the type for this description, by trying all the formats
|
||||
that this manager knows about.
|
||||
|
||||
The caller is responsible for deleting the object that is returned.
|
||||
|
||||
If it can't load the plugin, it returns nullptr and leaves a message in the
|
||||
errorMessage string.
|
||||
|
||||
If you intend to instantiate a AudioUnit v3 plug-in then you must either
|
||||
use the non-blocking asynchrous version below - or call this method from a
|
||||
thread other than the message thread and without blocking the message
|
||||
thread.
|
||||
*/
|
||||
AudioPluginInstance* createPluginInstance (const PluginDescription& description,
|
||||
double initialSampleRate,
|
||||
int initialBufferSize,
|
||||
String& errorMessage) const;
|
||||
|
||||
/** Tries to asynchronously load the type for this description, by trying
|
||||
all the formats that this manager knows about.
|
||||
|
||||
The caller must supply a callback object which will be called when
|
||||
the instantantiation has completed.
|
||||
|
||||
If it can't load the plugin then the callback function will be called
|
||||
passing a nullptr as the instance argument along with an error message.
|
||||
|
||||
The callback function will be called on the message thread so the caller
|
||||
must not block the message thread.
|
||||
|
||||
The callback object will be deleted automatically after it has been
|
||||
invoked.
|
||||
|
||||
The caller is responsible for deleting the instance that is passed to
|
||||
the callback function.
|
||||
|
||||
If you intend to instantiate a AudioUnit v3 plug-in then you must use
|
||||
this non-blocking asynchrous version - or call the synchrous method
|
||||
from an auxiliary thread.
|
||||
*/
|
||||
void createPluginInstanceAsync (const PluginDescription& description,
|
||||
double initialSampleRate,
|
||||
int initialBufferSize,
|
||||
AudioPluginFormat::InstantiationCompletionCallback* callback);
|
||||
|
||||
void createPluginInstanceAsync (const PluginDescription& description,
|
||||
double initialSampleRate,
|
||||
int initialBufferSize,
|
||||
std::function<void (AudioPluginInstance*, const String&)> completionCallback);
|
||||
|
||||
/** Checks that the file or component for this plugin actually still exists.
|
||||
|
||||
(This won't try to load the plugin)
|
||||
*/
|
||||
bool doesPluginStillExist (const PluginDescription& description) const;
|
||||
|
||||
private:
|
||||
//==============================================================================
|
||||
//@internal
|
||||
AudioPluginFormat* findFormatForDescription (const PluginDescription&, String& errorMessage) const;
|
||||
|
||||
OwnedArray<AudioPluginFormat> formats;
|
||||
|
||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AudioPluginFormatManager)
|
||||
};
|
||||
|
||||
} // namespace juce
|
Reference in New Issue
Block a user