mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-09 23:34:20 +00:00
AudioUnitPluginFormat: Extract headless plugin format type
This commit is contained in:
parent
0d80e22276
commit
6f24663ed9
7 changed files with 2919 additions and 2753 deletions
|
|
@ -43,35 +43,9 @@ namespace juce
|
|||
|
||||
@tags{Audio}
|
||||
*/
|
||||
class JUCE_API AudioUnitPluginFormat : public AudioPluginFormat
|
||||
class JUCE_API AudioUnitPluginFormat : public AudioUnitPluginFormatHeadless
|
||||
{
|
||||
public:
|
||||
//==============================================================================
|
||||
AudioUnitPluginFormat();
|
||||
~AudioUnitPluginFormat() override;
|
||||
|
||||
//==============================================================================
|
||||
static String getFormatName() { return "AudioUnit"; }
|
||||
String getName() const override { return getFormatName(); }
|
||||
bool canScanForPlugins() const override { return true; }
|
||||
bool isTrivialToScan() const override { return false; }
|
||||
|
||||
void findAllTypesForFile (OwnedArray<PluginDescription>&, const String& fileOrIdentifier) override;
|
||||
bool fileMightContainThisPluginType (const String& fileOrIdentifier) override;
|
||||
String getNameOfPluginFromIdentifier (const String& fileOrIdentifier) override;
|
||||
bool pluginNeedsRescanning (const PluginDescription&) override;
|
||||
StringArray searchPathsForPlugins (const FileSearchPath&, bool recursive, bool) override;
|
||||
bool doesPluginStillExist (const PluginDescription&) override;
|
||||
FileSearchPath getDefaultLocationsToSearch() override;
|
||||
void createARAFactoryAsync (const PluginDescription&, ARAFactoryCreationCallback callback) override;
|
||||
|
||||
private:
|
||||
//==============================================================================
|
||||
void createPluginInstance (const PluginDescription&, double initialSampleRate,
|
||||
int initialBufferSize, PluginCreationCallback) override;
|
||||
bool requiresUnblockedMessageThreadDuringCreation (const PluginDescription&) const override;
|
||||
|
||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AudioUnitPluginFormat)
|
||||
void createPluginInstance (const PluginDescription&, double, int, PluginCreationCallback) override;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -0,0 +1,78 @@
|
|||
/*
|
||||
==============================================================================
|
||||
|
||||
This file is part of the JUCE framework.
|
||||
Copyright (c) Raw Material Software Limited
|
||||
|
||||
JUCE is an open source framework subject to commercial or open source
|
||||
licensing.
|
||||
|
||||
By downloading, installing, or using the JUCE framework, or combining the
|
||||
JUCE framework with any other source code, object code, content or any other
|
||||
copyrightable work, you agree to the terms of the JUCE End User Licence
|
||||
Agreement, and all incorporated terms including the JUCE Privacy Policy and
|
||||
the JUCE Website Terms of Service, as applicable, which will bind you. If you
|
||||
do not agree to the terms of these agreements, we will not license the JUCE
|
||||
framework to you, and you must discontinue the installation or download
|
||||
process and cease use of the JUCE framework.
|
||||
|
||||
JUCE End User Licence Agreement: https://juce.com/legal/juce-8-licence/
|
||||
JUCE Privacy Policy: https://juce.com/juce-privacy-policy
|
||||
JUCE Website Terms of Service: https://juce.com/juce-website-terms-of-service/
|
||||
|
||||
Or:
|
||||
|
||||
You may also use this code under the terms of the AGPLv3:
|
||||
https://www.gnu.org/licenses/agpl-3.0.en.html
|
||||
|
||||
THE JUCE FRAMEWORK IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL
|
||||
WARRANTIES, WHETHER EXPRESSED OR IMPLIED, INCLUDING WARRANTY OF
|
||||
MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ARE DISCLAIMED.
|
||||
|
||||
==============================================================================
|
||||
*/
|
||||
|
||||
namespace juce
|
||||
{
|
||||
|
||||
#if (JUCE_PLUGINHOST_AU && (JUCE_MAC || JUCE_IOS)) || DOXYGEN
|
||||
|
||||
//==============================================================================
|
||||
/**
|
||||
Implements a plugin format manager for AudioUnits.
|
||||
|
||||
@tags{Audio}
|
||||
*/
|
||||
class JUCE_API AudioUnitPluginFormatHeadless : public AudioPluginFormat
|
||||
{
|
||||
public:
|
||||
//==============================================================================
|
||||
AudioUnitPluginFormatHeadless() = default;
|
||||
|
||||
//==============================================================================
|
||||
static String getFormatName() { return "AudioUnit"; }
|
||||
String getName() const override { return getFormatName(); }
|
||||
bool canScanForPlugins() const override { return true; }
|
||||
bool isTrivialToScan() const override { return false; }
|
||||
|
||||
void findAllTypesForFile (OwnedArray<PluginDescription>&, const String& fileOrIdentifier) override;
|
||||
bool fileMightContainThisPluginType (const String& fileOrIdentifier) override;
|
||||
String getNameOfPluginFromIdentifier (const String& fileOrIdentifier) override;
|
||||
bool pluginNeedsRescanning (const PluginDescription&) override;
|
||||
StringArray searchPathsForPlugins (const FileSearchPath&, bool recursive, bool) override;
|
||||
bool doesPluginStillExist (const PluginDescription&) override;
|
||||
FileSearchPath getDefaultLocationsToSearch() override;
|
||||
void createARAFactoryAsync (const PluginDescription&, ARAFactoryCreationCallback callback) override;
|
||||
|
||||
private:
|
||||
//==============================================================================
|
||||
void createPluginInstance (const PluginDescription&, double initialSampleRate,
|
||||
int initialBufferSize, PluginCreationCallback) override;
|
||||
bool requiresUnblockedMessageThreadDuringCreation (const PluginDescription&) const override;
|
||||
|
||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AudioUnitPluginFormatHeadless)
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,204 @@
|
|||
/*
|
||||
==============================================================================
|
||||
|
||||
This file is part of the JUCE framework.
|
||||
Copyright (c) Raw Material Software Limited
|
||||
|
||||
JUCE is an open source framework subject to commercial or open source
|
||||
licensing.
|
||||
|
||||
By downloading, installing, or using the JUCE framework, or combining the
|
||||
JUCE framework with any other source code, object code, content or any other
|
||||
copyrightable work, you agree to the terms of the JUCE End User Licence
|
||||
Agreement, and all incorporated terms including the JUCE Privacy Policy and
|
||||
the JUCE Website Terms of Service, as applicable, which will bind you. If you
|
||||
do not agree to the terms of these agreements, we will not license the JUCE
|
||||
framework to you, and you must discontinue the installation or download
|
||||
process and cease use of the JUCE framework.
|
||||
|
||||
JUCE End User Licence Agreement: https://juce.com/legal/juce-8-licence/
|
||||
JUCE Privacy Policy: https://juce.com/juce-privacy-policy
|
||||
JUCE Website Terms of Service: https://juce.com/juce-website-terms-of-service/
|
||||
|
||||
Or:
|
||||
|
||||
You may also use this code under the terms of the AGPLv3:
|
||||
https://www.gnu.org/licenses/agpl-3.0.en.html
|
||||
|
||||
THE JUCE FRAMEWORK IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL
|
||||
WARRANTIES, WHETHER EXPRESSED OR IMPLIED, INCLUDING WARRANTY OF
|
||||
MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ARE DISCLAIMED.
|
||||
|
||||
==============================================================================
|
||||
*/
|
||||
|
||||
#if JUCE_PLUGINHOST_AU && (JUCE_MAC || JUCE_IOS)
|
||||
|
||||
#include <juce_audio_processors_headless/format_types/juce_AudioUnitPluginFormatImpl.h>
|
||||
|
||||
namespace juce
|
||||
{
|
||||
|
||||
void AudioUnitPluginFormatHeadless::findAllTypesForFile (OwnedArray<PluginDescription>& results,
|
||||
const String& fileOrIdentifier)
|
||||
{
|
||||
if (! fileMightContainThisPluginType (fileOrIdentifier))
|
||||
return;
|
||||
|
||||
PluginDescription desc;
|
||||
desc.fileOrIdentifier = fileOrIdentifier;
|
||||
desc.uniqueId = desc.deprecatedUid = 0;
|
||||
|
||||
if (MessageManager::getInstance()->isThisTheMessageThread()
|
||||
&& requiresUnblockedMessageThreadDuringCreation (desc))
|
||||
return;
|
||||
|
||||
try
|
||||
{
|
||||
auto createdInstance = createInstanceFromDescription (desc, 44100.0, 512);
|
||||
|
||||
if (auto auInstance = dynamic_cast<AudioUnitPluginInstanceHeadless*> (createdInstance.get()))
|
||||
results.add (new PluginDescription (auInstance->getPluginDescription()));
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
// crashed while loading...
|
||||
}
|
||||
}
|
||||
|
||||
void AudioUnitPluginFormatHeadless::createPluginInstance (const PluginDescription& desc,
|
||||
double rate,
|
||||
int blockSize,
|
||||
PluginCreationCallback callback)
|
||||
{
|
||||
createAudioUnitPluginInstance<AudioUnitPluginInstanceHeadless> (*this, desc, rate, blockSize, callback);
|
||||
}
|
||||
|
||||
void AudioUnitPluginFormatHeadless::createARAFactoryAsync (const PluginDescription& desc, ARAFactoryCreationCallback callback)
|
||||
{
|
||||
auto auComponentResult = getAudioComponent (*this, desc);
|
||||
|
||||
if (! auComponentResult.isValid())
|
||||
{
|
||||
callback ({ {}, "Failed to create AudioComponent for " + desc.descriptiveName });
|
||||
return;
|
||||
}
|
||||
|
||||
getOrCreateARAAudioUnit (auComponentResult.component, [cb = std::move (callback)] (auto dylibKeepAliveAudioUnit)
|
||||
{
|
||||
cb ([&]() -> ARAFactoryResult
|
||||
{
|
||||
if (dylibKeepAliveAudioUnit != nullptr)
|
||||
return { ARAFactoryWrapper { ::juce::getARAFactory (std::move (dylibKeepAliveAudioUnit)) }, "" };
|
||||
|
||||
return { {}, "Failed to create ARAFactory from the provided AudioUnit" };
|
||||
}());
|
||||
});
|
||||
}
|
||||
|
||||
bool AudioUnitPluginFormatHeadless::requiresUnblockedMessageThreadDuringCreation (const PluginDescription& desc) const
|
||||
{
|
||||
String pluginName, version, manufacturer;
|
||||
AudioComponentDescription componentDesc;
|
||||
|
||||
if (AudioUnitFormatHelpers::getComponentDescFromIdentifier (desc.fileOrIdentifier, componentDesc,
|
||||
pluginName, version, manufacturer)
|
||||
|| AudioUnitFormatHelpers::getComponentDescFromFile (desc.fileOrIdentifier, componentDesc,
|
||||
pluginName, version, manufacturer))
|
||||
{
|
||||
if (AudioComponent auComp = AudioComponentFindNext (nullptr, &componentDesc))
|
||||
{
|
||||
if (AudioComponentGetDescription (auComp, &componentDesc) == noErr)
|
||||
return AudioUnitFormatHelpers::isPluginAUv3 (componentDesc);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
StringArray AudioUnitPluginFormatHeadless::searchPathsForPlugins (const FileSearchPath&, bool /*recursive*/, bool allowPluginsWhichRequireAsynchronousInstantiation)
|
||||
{
|
||||
StringArray result;
|
||||
AudioComponent comp = nullptr;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
AudioComponentDescription desc;
|
||||
zerostruct (desc);
|
||||
|
||||
comp = AudioComponentFindNext (comp, &desc);
|
||||
|
||||
if (comp == nullptr)
|
||||
break;
|
||||
|
||||
if (AudioComponentGetDescription (comp, &desc) != noErr)
|
||||
continue;
|
||||
|
||||
if (desc.componentType == kAudioUnitType_MusicDevice
|
||||
|| desc.componentType == kAudioUnitType_MusicEffect
|
||||
|| desc.componentType == kAudioUnitType_Effect
|
||||
|| desc.componentType == kAudioUnitType_Generator
|
||||
|| desc.componentType == kAudioUnitType_Panner
|
||||
|| desc.componentType == kAudioUnitType_Mixer
|
||||
|| desc.componentType == kAudioUnitType_MIDIProcessor)
|
||||
{
|
||||
if (allowPluginsWhichRequireAsynchronousInstantiation || ! AudioUnitFormatHelpers::isPluginAUv3 (desc))
|
||||
result.add (AudioUnitFormatHelpers::createPluginIdentifier (desc));
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
bool AudioUnitPluginFormatHeadless::fileMightContainThisPluginType (const String& fileOrIdentifier)
|
||||
{
|
||||
AudioComponentDescription desc;
|
||||
String name, version, manufacturer;
|
||||
|
||||
if (AudioUnitFormatHelpers::getComponentDescFromIdentifier (fileOrIdentifier, desc, name, version, manufacturer))
|
||||
return AudioComponentFindNext (nullptr, &desc) != nullptr;
|
||||
|
||||
auto f = File::createFileWithoutCheckingPath (fileOrIdentifier);
|
||||
|
||||
return (f.hasFileExtension (".component") || f.hasFileExtension (".appex"))
|
||||
&& f.isDirectory();
|
||||
}
|
||||
|
||||
String AudioUnitPluginFormatHeadless::getNameOfPluginFromIdentifier (const String& fileOrIdentifier)
|
||||
{
|
||||
AudioComponentDescription desc;
|
||||
String name, version, manufacturer;
|
||||
AudioUnitFormatHelpers::getComponentDescFromIdentifier (fileOrIdentifier, desc, name, version, manufacturer);
|
||||
|
||||
if (name.isEmpty())
|
||||
name = fileOrIdentifier;
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
bool AudioUnitPluginFormatHeadless::pluginNeedsRescanning (const PluginDescription& desc)
|
||||
{
|
||||
AudioComponentDescription newDesc;
|
||||
String name, version, manufacturer;
|
||||
|
||||
return ! (AudioUnitFormatHelpers::getComponentDescFromIdentifier (desc.fileOrIdentifier, newDesc,
|
||||
name, version, manufacturer)
|
||||
&& version == desc.version);
|
||||
}
|
||||
|
||||
bool AudioUnitPluginFormatHeadless::doesPluginStillExist (const PluginDescription& desc)
|
||||
{
|
||||
if (desc.fileOrIdentifier.startsWithIgnoreCase (AudioUnitFormatHelpers::auIdentifierPrefix))
|
||||
return fileMightContainThisPluginType (desc.fileOrIdentifier);
|
||||
|
||||
return File (desc.fileOrIdentifier).exists();
|
||||
}
|
||||
|
||||
FileSearchPath AudioUnitPluginFormatHeadless::getDefaultLocationsToSearch()
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
} // namespace juce
|
||||
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -41,6 +41,9 @@
|
|||
#error "Incorrect use of JUCE cpp file"
|
||||
#endif
|
||||
|
||||
#define JUCE_CORE_INCLUDE_NATIVE_HEADERS 1
|
||||
#define JUCE_CORE_INCLUDE_OBJC_HELPERS 1
|
||||
|
||||
#include "juce_audio_processors_headless.h"
|
||||
|
||||
#include <juce_audio_processors_headless/processors/juce_AudioProcessorListener.cpp>
|
||||
|
|
@ -61,3 +64,4 @@
|
|||
#include <juce_audio_processors_headless/utilities/juce_AudioParameterBool.cpp>
|
||||
#include <juce_audio_processors_headless/utilities/juce_AudioParameterChoice.cpp>
|
||||
#include <juce_audio_processors_headless/utilities/ARA/juce_ARA_utils.cpp>
|
||||
#include <juce_audio_processors_headless/format_types/juce_AudioUnitPluginFormatHeadless.mm>
|
||||
|
|
|
|||
|
|
@ -89,3 +89,4 @@
|
|||
#include <juce_audio_processors_headless/utilities/juce_AudioParameterChoice.h>
|
||||
#include <juce_audio_processors_headless/utilities/ARA/juce_ARADebug.h>
|
||||
#include <juce_audio_processors_headless/utilities/ARA/juce_ARA_utils.h>
|
||||
#include <juce_audio_processors_headless/format_types/juce_AudioUnitPluginFormatHeadless.h>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue