Skip to content

πŸŽ› πŸ”Š A Python library for audio.

Fix handling of Audio Unit container plugins.

Peter Sobotd7438746d9c6
diff --git a/.gitmodules b/.gitmodules
index d9b34b0..eba99dc 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -1,6 +1,6 @@
[submodule "JUCE"]
path = JUCE
- url = https://github.com/psobot/JUCE.git
+ url = https://github.com/juce-framework/JUCE.git
[submodule "vendors/rubberband"]
path = vendors/rubberband
url = https://github.com/BreakfastQuay/Rubberband.git
diff --git a/JUCE b/JUCE
index f0fc4a1..ddaa091 160000
--- a/JUCE
+++ b/JUCE
@@ -1 +1 @@
-Subproject commit f0fc4a1f67bb6070cfa338cebcddfc7612c4104d
+Subproject commit ddaa09110392a4419fecbb6d3022bede89b7e841
diff --git a/pedalboard/AudioUnitParser.h b/pedalboard/AudioUnitParser.h
new file mode 100644
index 0000000..5190814
--- /dev/null
+++ b/pedalboard/AudioUnitParser.h
@@ -0,0 +1,33 @@
+/*
+ * pedalboard
+ * Copyright 2021 Spotify AB
+ *
+ * Licensed under the GNU Public License, Version 3.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.gnu.org/licenses/gpl-3.0.html
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#pragma once
+
+#include <mutex>
+#include <optional>
+
+#include "JuceHeader.h"
+
+#if JUCE_MAC
+
+namespace Pedalboard {
+// This uses Objective-C++ code, so its implementation can't be defined inline:
+std::vector<std::string>
+getAudioUnitIdentifiersFromFile(const juce::String &filename);
+} // namespace Pedalboard
+
+#endif
\ No newline at end of file
diff --git a/pedalboard/AudioUnitParser.mm b/pedalboard/AudioUnitParser.mm
new file mode 100644
index 0000000..20dc263
--- /dev/null
+++ b/pedalboard/AudioUnitParser.mm
@@ -0,0 +1,108 @@
+/*
+ * pedalboard
+ * Copyright 2021 Spotify AB
+ *
+ * Licensed under the GNU Public License, Version 3.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.gnu.org/licenses/gpl-3.0.html
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "AudioUnitParser.h"
+
+#if JUCE_MAC
+#include <AudioToolbox/AudioUnitUtilities.h>
+
+namespace Pedalboard {
+
+static OSType stringToOSType(juce::String s) {
+ if (s.trim().length() >= 4) // (to avoid trimming leading spaces)
+ s = s.trim();
+
+ s += " ";
+
+ return (((OSType)(unsigned char)s[0]) << 24) |
+ (((OSType)(unsigned char)s[1]) << 16) |
+ (((OSType)(unsigned char)s[2]) << 8) | ((OSType)(unsigned char)s[3]);
+}
+
+static juce::String osTypeToString(OSType type) noexcept {
+ const juce::juce_wchar s[4] = {(juce::juce_wchar)((type >> 24) & 0xff),
+ (juce::juce_wchar)((type >> 16) & 0xff),
+ (juce::juce_wchar)((type >> 8) & 0xff),
+ (juce::juce_wchar)(type & 0xff)};
+ return juce::String(s, 4);
+}
+
+const char *AU_IDENTIFIER_PREFIX = "AudioUnit:";
+
+static juce::String
+createPluginIdentifier(const AudioComponentDescription &desc) {
+ juce::String s(AU_IDENTIFIER_PREFIX);
+
+ if (desc.componentType == kAudioUnitType_MusicDevice)
+ s << "Synths/";
+ else if (desc.componentType == kAudioUnitType_MusicEffect ||
+ desc.componentType == kAudioUnitType_Effect)
+ s << "Effects/";
+ else if (desc.componentType == kAudioUnitType_Generator)
+ s << "Generators/";
+ else if (desc.componentType == kAudioUnitType_Panner)
+ s << "Panners/";
+ else if (desc.componentType == kAudioUnitType_Mixer)
+ s << "Mixers/";
+ else if (desc.componentType == kAudioUnitType_MIDIProcessor)
+ s << "MidiEffects/";
+
+ s << osTypeToString(desc.componentType) << ","
+ << osTypeToString(desc.componentSubType) << ","
+ << osTypeToString(desc.componentManufacturer);
+
+ return s;
+}
+
+inline juce::String nsStringToJuce(NSString *s) {
+ return juce::CharPointer_UTF8([s UTF8String]);
+}
+
+std::vector<std::string>
+getAudioUnitIdentifiersFromFile(const juce::String &filename) {
+ std::vector<std::string> identifiers;
+
+ const juce::File file(filename);
+ if (!file.hasFileExtension(".component") &&
+ !file.hasFileExtension(".appex")) {
+ return identifiers;
+ }
+
+ // Use NSBundle to open and extract identifiers:
+ NSBundle *bundle =
+ [[NSBundle alloc] initWithPath:(NSString *)filename.toCFString()];
+
+ NSArray *audioComponents =
+ [bundle objectForInfoDictionaryKey:@"AudioComponents"];
+ for (NSDictionary *component in audioComponents) {
+ AudioComponentDescription desc;
+ desc.componentManufacturer = stringToOSType(
+ nsStringToJuce((NSString *)[component valueForKey:@"manufacturer"]));
+ desc.componentType = stringToOSType(
+ nsStringToJuce((NSString *)[component valueForKey:@"type"]));
+ desc.componentSubType = stringToOSType(
+ nsStringToJuce((NSString *)[component valueForKey:@"subtype"]));
+ identifiers.push_back(createPluginIdentifier(desc).toStdString());
+ }
+
+ [bundle release];
+
+ return identifiers;
+}
+
+}
+#endif
\ No newline at end of file
diff --git a/pedalboard/ExternalPlugin.h b/pedalboard/ExternalPlugin.h
index 84635a9..825748b 100644
--- a/pedalboard/ExternalPlugin.h
+++ b/pedalboard/ExternalPlugin.h
@@ -25,9 +25,14 @@
#include <sys/utsname.h>
#endif
+#include "AudioUnitParser.h"
#include "Plugin.h"
#include <pybind11/stl.h>
+#if JUCE_MAC
+#include <AudioToolbox/AudioUnitUtilities.h>
+#endif
+
namespace Pedalboard {
// JUCE external plugins use some global state; here we lock that state
@@ -35,6 +40,11 @@ namespace Pedalboard {
static std::mutex EXTERNAL_PLUGIN_MUTEX;
static int NUM_ACTIVE_EXTERNAL_PLUGINS = 0;
+static const std::string AUDIO_UNIT_NOT_INSTALLED_ERROR =
+ "macOS requires plugin files to be moved to "
+ "/Library/Audio/Plug-Ins/Components/ or "
+ "~/Library/Audio/Plug-Ins/Components/ before loading.";
+
inline std::vector<std::string> findInstalledVSTPluginPaths() {
// Ensure we have a MessageManager, which is required by the VST wrapper
// Without this, we get an assert(false) from JUCE at runtime
@@ -110,6 +120,46 @@ private:
};
#endif
+static bool audioUnitIsInstalled(const juce::String audioUnitFilePath) {
+ return audioUnitFilePath.contains("/Library/Audio/Plug-Ins/Components/");
+}
+
+template <typename ExternalPluginType>
+static std::vector<std::string> getPluginNamesForFile(std::string filename) {
+ juce::MessageManager::getInstance();
+
+ ExternalPluginType format;
+ juce::OwnedArray<juce::PluginDescription> typesFound;
+
+ std::string errorMessage = "Unable to scan plugin " + filename +
+ ": unsupported plugin format or scan failure.";
+
+ if constexpr (std::is_same<ExternalPluginType,
+ juce::AudioUnitPluginFormat>::value) {
+ auto identifiers = getAudioUnitIdentifiersFromFile(filename);
+ // For each plugin in the identified bundle, scan using its AU identifier:
+ for (int i = 0; i < identifiers.size(); i++) {
+ format.findAllTypesForFile(typesFound, identifiers[i]);
+ }
+
+ if (typesFound.isEmpty() && !audioUnitIsInstalled(filename)) {
+ errorMessage += " " + AUDIO_UNIT_NOT_INSTALLED_ERROR;
+ }
+ } else {
+ format.findAllTypesForFile(typesFound, filename);
+ }
+
+ if (typesFound.isEmpty()) {
+ throw pybind11::import_error(errorMessage);
+ }
+
+ std::vector<std::string> pluginNames;
+ for (int i = 0; i < typesFound.size(); i++) {
+ pluginNames.push_back(typesFound[i]->name.toStdString());
+ }
+ return pluginNames;
+}
+
class StandalonePluginWindow : public juce::DocumentWindow {
public:
StandalonePluginWindow(juce::AudioProcessor &processor)
@@ -223,13 +273,9 @@ public:
// Without this, we get an assert(false) from JUCE at runtime
juce::MessageManager::getInstance();
- juce::KnownPluginList pluginList;
-
juce::OwnedArray<juce::PluginDescription> typesFound;
ExternalPluginType format;
- juce::String pluginLoadError =
- "Plugin not found or not in the appropriate format.";
pluginFormatManager.addDefaultFormats();
auto pluginFileStripped =
@@ -243,7 +289,16 @@ public:
": plugin file not found.");
}
- pluginList.scanAndAddFile(pluginFileStripped, false, typesFound, format);
+ if constexpr (std::is_same<ExternalPluginType,
+ juce::AudioUnitPluginFormat>::value) {
+ auto identifiers = getAudioUnitIdentifiersFromFile(pluginFileStripped);
+ // For each plugin in the identified bundle, scan using its AU identifier:
+ for (int i = 0; i < identifiers.size(); i++) {
+ format.findAllTypesForFile(typesFound, identifiers[i]);
+ }
+ } else {
+ format.findAllTypesForFile(typesFound, pluginFileStripped);
+ }
if (!typesFound.isEmpty()) {
if (typesFound.size() == 1) {
@@ -287,6 +342,9 @@ public:
reinstantiatePlugin();
} else {
+ std::string errorMessage = "Unable to load plugin " +
+ pathToPluginFile.toStdString() +
+ ": unsupported plugin format or load failure.";
#if JUCE_LINUX
auto machineName = []() -> juce::String {
struct utsname unameData;
@@ -305,30 +363,20 @@ public:
.getChildFile(machineName + "-linux")
.getChildFile(pluginBundle.getFileNameWithoutExtension() + ".so");
- throw pybind11::import_error(
- "Unable to load plugin " + pathToPluginFile.toStdString() +
- ": unsupported plugin format or load failure. Plugin files or " +
- "shared library dependencies may be missing. (Try running `ldd \"" +
- pathToSharedObjectFile.getFullPathName().toStdString() + "\"` to " +
- "see which dependencies might be missing.).");
+ errorMessage += " Plugin files or shared library dependencies may be "
+ "missing. (Try running `ldd \"" +
+ pathToSharedObjectFile.getFullPathName().toStdString() +
+ "\"` to see which dependencies might be missing.).";
#else
-
-// On certain Macs, plugins will only load if installed in the appropriate path.
-#if JUCE_MAC
- bool pluginIsInstalled =
- pluginFileStripped.contains("/Library/Audio/Plug-Ins/Components/");
- if (!pluginIsInstalled) {
- throw pybind11::import_error(
- "Unable to load plugin " + pathToPluginFile.toStdString() +
- ": unsupported plugin format or load failure. Plugin file may need "
- "to be moved to /Library/Audio/Plug-Ins/Components/ or "
- "~/Library/Audio/Plug-Ins/Components/.");
+ if constexpr (std::is_same<ExternalPluginType,
+ juce::AudioUnitPluginFormat>::value) {
+ if (!audioUnitIsInstalled(pathToPluginFile)) {
+ errorMessage += " " + AUDIO_UNIT_NOT_INSTALLED_ERROR;
+ }
}
#endif
- throw pybind11::import_error(
- "Unable to load plugin " + pathToPluginFile.toStdString() +
- ": unsupported plugin format or load failure.");
-#endif
+
+ throw pybind11::import_error(errorMessage);
}
}
@@ -375,7 +423,8 @@ public:
}
void reinstantiatePlugin() {
- // If we have an existing plugin, save its state and reload its state later:
+ // If we have an existing plugin, save its state and reload its state
+ // later:
juce::MemoryBlock savedState;
std::map<int, float> currentParameters;
@@ -399,9 +448,9 @@ public:
{
if (foundPluginDescription.numInputChannels == 0) {
throw std::invalid_argument(
- "Plugin '" + foundPluginDescription.name.toStdString() +
- "' does not accept audio input. It may be an instrument plug-in "
- "and not an audio effect processor.");
+ "Plugin '" + foundPluginDescription.name.toStdString() +
+ "' does not accept audio input. It may be an instrument plug-in "
+ "and not an audio effect processor.");
}
std::lock_guard<std::mutex> lock(EXTERNAL_PLUGIN_MUTEX);
@@ -451,9 +500,9 @@ public:
pluginInstance->setStateInformation(savedState.getData(),
savedState.getSize());
- // Set all of the parameters twice: we may have meta-parameters that change
- // the validity of other `setValue` calls. (i.e.: param1 can't be set until
- // param2 is set.)
+ // Set all of the parameters twice: we may have meta-parameters that
+ // change the validity of other `setValue` calls. (i.e.: param1 can't be
+ // set until param2 is set.)
for (int i = 0; i < 2; i++) {
for (auto *parameter : pluginInstance->getParameters()) {
if (currentParameters.count(parameter->getParameterIndex()) > 0) {
@@ -681,7 +730,8 @@ public:
lastSpec.maximumBlockSize < spec.maximumBlockSize ||
lastSpec.numChannels != spec.numChannels) {
- // Changing the number of channels requires releaseResources to be called:
+ // Changing the number of channels requires releaseResources to be
+ // called:
if (lastSpec.numChannels != spec.numChannels) {
pluginInstance->releaseResources();
setNumChannels(spec.numChannels);
@@ -906,7 +956,8 @@ inline void init_external_plugins(py::module &m) {
},
py::arg("string_value"),
"Returns the raw value of the supplied text. Plugins may handle "
- "errors however they see fit, but will likely not raise exceptions.")
+ "errors however they see fit, but will likely not raise "
+ "exceptions.")
.def_property_readonly(
"is_orientation_inverted",
&juce::AudioProcessorParameter::isOrientationInverted,
@@ -915,10 +966,11 @@ inline void init_external_plugins(py::module &m) {
.def_property_readonly("is_automatable",
&juce::AudioProcessorParameter::isAutomatable,
"Returns true if this parameter can be automated.")
- .def_property_readonly(
- "is_automatable", &juce::AudioProcessorParameter::isAutomatable,
- "Returns true if this parameter can be automated (i.e.: scheduled to "
- "change over time, in real-time, in a DAW).")
+ .def_property_readonly("is_automatable",
+ &juce::AudioProcessorParameter::isAutomatable,
+ "Returns true if this parameter can be "
+ "automated (i.e.: scheduled to "
+ "change over time, in real-time, in a DAW).")
.def_property_readonly(
"is_meta_parameter", &juce::AudioProcessorParameter::isMetaParameter,
"A meta-parameter is a parameter that changes other parameters.")
@@ -960,6 +1012,14 @@ inline void init_external_plugins(py::module &m) {
&ExternalPlugin<juce::VST3PluginFormat>::loadPresetData,
"Load a VST3 preset file in .vstpreset format.",
py::arg("preset_file_path"))
+ .def_static(
+ "get_plugin_names_for_file",
+ [](std::string filename) {
+ return getPluginNamesForFile<juce::VST3PluginFormat>(filename);
+ },
+ "Return a list of plugin names contained within a given VST3 "
+ "plugin (i.e.: a \".vst3\"). If the provided file cannot be scanned, "
+ "an ImportError will be raised.")
.def_property_readonly_static(
"installed_plugins",
[](py::object /* cls */) { return findInstalledVSTPluginPaths(); },
@@ -1008,6 +1068,14 @@ inline void init_external_plugins(py::module &m) {
ss << ">";
return ss.str();
})
+ .def_static(
+ "get_plugin_names_for_file",
+ [](std::string filename) {
+ return getPluginNamesForFile<juce::AudioUnitPluginFormat>(filename);
+ },
+ "Return a list of plugin names contained within a given Audio Unit "
+ "bundle (i.e.: a \".component\"). If the provided file cannot be "
+ "scanned, an ImportError will be raised.")
.def_property_readonly_static(
"installed_plugins",
[](py::object /* cls */) {
diff --git a/pedalboard/pedalboard.py b/pedalboard/pedalboard.py
index e3417a2..c502c6c 100644
--- a/pedalboard/pedalboard.py
+++ b/pedalboard/pedalboard.py
@@ -14,6 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+import re
import platform
import weakref
from functools import update_wrapper
@@ -151,7 +152,10 @@ BooleanWithParameter = wrap_type(WrappedBool)
# expose every possible MIDI CC value as a separate parameter
# (i.e.: MIDI CC [0-16]|[0-128], resulting in 2,048 parameters).
# This hugely delays load times and adds complexity to the interface.
-PARAMETER_NAME_SUBSTRINGS_TO_IGNORE = {"MIDI CC "}
+# Guitar Rig also seems to expose 512 parameters, each matching "P\d\d\d"
+PARAMETER_NAME_REGEXES_TO_IGNORE = set(
+ [re.compile(pattern) for pattern in ["MIDI CC ", r"P\d\d\d"]]
+)
TRUE_BOOLEANS = {"on", "yes", "true", "enabled"}
@@ -446,9 +450,7 @@ class ExternalPlugin(object):
parameters = {}
for cpp_parameter in self._parameters:
- if any(
- [substr in cpp_parameter.name for substr in PARAMETER_NAME_SUBSTRINGS_TO_IGNORE]
- ):
+ if any([regex.match(cpp_parameter.name) for regex in PARAMETER_NAME_REGEXES_TO_IGNORE]):
continue
if cpp_parameter.name not in self.__python_parameter_cache__:
self.__python_parameter_cache__[cpp_parameter.name] = AudioProcessorParameter(
@@ -531,7 +533,7 @@ try:
raise TypeError(
"Expected a dictionary to be passed to parameter_values, but received a"
f" {type(parameter_values).__name__}. (If passing a plugin name, pass"
- " \"plugin_name=...\" as a keyword argument instead.)"
+ ' "plugin_name=..." as a keyword argument instead.)'
)
super().__init__(path_to_plugin_file, plugin_name)
self.__set_initial_parameter_values__(parameter_values)
@@ -555,7 +557,7 @@ try:
raise TypeError(
"Expected a dictionary to be passed to parameter_values, but received a"
f" {type(parameter_values).__name__}. (If passing a plugin name, pass"
- " \"plugin_name=...\" as a keyword argument instead.)"
+ ' "plugin_name=..." as a keyword argument instead.)'
)
super().__init__(path_to_plugin_file, plugin_name)
self.__set_initial_parameter_values__(parameter_values)
diff --git a/setup.py b/setup.py
index c43ecae..4edf515 100644
--- a/setup.py
+++ b/setup.py
@@ -188,6 +188,8 @@ if platform.system() == "Darwin":
)
if matching_cpp_source:
ALL_SOURCE_PATHS[ALL_SOURCE_PATHS.index(matching_cpp_source)] = objc_source
+ else:
+ ALL_SOURCE_PATHS.append(objc_source)
ALL_RESOLVED_SOURCE_PATHS = [str(p.resolve()) for p in ALL_SOURCE_PATHS]
elif platform.system() == "Linux":
for package in ['freetype2']:
diff --git a/tests/test_external_plugins.py b/tests/test_external_plugins.py
index 5c62df1..e02001e 100644
--- a/tests/test_external_plugins.py
+++ b/tests/test_external_plugins.py
@@ -53,13 +53,18 @@ if os.getenv("CIBW_TEST_REQUIRES") or os.getenv("CI"):
f for f in AVAILABLE_PLUGINS_IN_TEST_ENVIRONMENT if "component" not in f
]
-# Waves is the only known plugin vendor who regularly bundles multiple VSTs/AUs into one file:
-KNOWN_CONTAINER_PLUGIN_NAMES = {"WaveShell"}
+
+def is_container_plugin(filename: str):
+ for klass in pedalboard.AVAILABLE_PLUGIN_CLASSES:
+ try:
+ return len(klass.get_plugin_names_for_file(filename)) > 1
+ except ImportError:
+ pass
+ return False
+
AVAILABLE_CONTAINER_PLUGINS_IN_TEST_ENVIRONMENT = [
- filename
- for filename in AVAILABLE_PLUGINS_IN_TEST_ENVIRONMENT
- if any(container_name in filename for container_name in KNOWN_CONTAINER_PLUGIN_NAMES)
+ filename for filename in AVAILABLE_PLUGINS_IN_TEST_ENVIRONMENT if is_container_plugin(filename)
]
@@ -70,10 +75,7 @@ def get_parameters(plugin_filename: str):
TEST_PLUGIN_CACHE = {}
TEST_PLUGIN_ORIGINAL_PARAMETER_CACHE = {}
-# If true, copy all test Audio Units into the appropriate install path
-# before running tests. On some versions of macOS, this is necessary or
-# else Audio Units won't load.
-TEMPORARILY_INSTALL_AUDIO_UNITS = True
+
PLUGIN_FILES_TO_DELETE = set()
MACOS_PLUGIN_INSTALL_PATH = Path.home() / "Library" / "Audio" / "Plug-Ins" / "Components"
@@ -91,13 +93,9 @@ def load_test_plugin(plugin_filename: str, disable_caching: bool = False, *args,
if key not in TEST_PLUGIN_CACHE or disable_caching:
plugin_path = os.path.join(TEST_PLUGIN_BASE_PATH, platform.system(), plugin_filename)
- if (
- platform.system() == "Darwin"
- and plugin_filename.endswith(".component")
- and TEMPORARILY_INSTALL_AUDIO_UNITS
- ):
- # On certain macOS machines, it seems AudioUnit components must be
- # installed in ~/Library/Audio/Plug-Ins/Components in order to be loaded.
+ if platform.system() == "Darwin" and plugin_filename.endswith(".component"):
+ # On macOS, AudioUnit components must be installed in
+ # ~/Library/Audio/Plug-Ins/Components in order to be loaded.
installed_plugin_path = os.path.join(MACOS_PLUGIN_INSTALL_PATH, plugin_filename)
plugin_already_installed = os.path.exists(installed_plugin_path)
if not plugin_already_installed:
@@ -158,9 +156,7 @@ if os.environ.get("ENABLE_TESTING_WITH_LOCAL_PLUGINS", False):
# Even if the plugin failed to load, add it to
# the list of known container plugins if necessary:
- if any(
- container_name in plugin_path for container_name in KNOWN_CONTAINER_PLUGIN_NAMES
- ):
+ if is_container_plugin(plugin_path):
AVAILABLE_CONTAINER_PLUGINS_IN_TEST_ENVIRONMENT.append(plugin_path)
@@ -678,7 +674,7 @@ def test_show_editor(plugin_filename: str):
psutil.Process(os.getpid()).exe(),
"-c",
"import pedalboard;"
- f'pedalboard.load_plugin(r"{full_plugin_filename}").show_editor();',
+ f"pedalboard.load_plugin(r\"{full_plugin_filename}\").show_editor();",
],
timeout=5,
stderr=subprocess.STDOUT,
@@ -702,7 +698,7 @@ def test_plugin_container_handling(plugin_filename: str):
"""
Some plugins can have multiple sub-plugins within them.
As of v0.4.5, Pedalboard requires indicating the specific plugin to open within the container.
- These plugins will fail by default:
+ These plugins will fail by default.
"""
with pytest.raises(ValueError) as e:
load_test_plugin(plugin_filename, disable_caching=True)
@@ -711,10 +707,41 @@ def test_plugin_container_handling(plugin_filename: str):
# Hackily parse out the plugin names:
message = e.value.args[0]
- plugin_names = [line.strip().strip("\"") for line in message.split("\n")[1:]]
+ plugin_names = [line.strip().strip('"') for line in message.split("\n")[1:]]
assert f"{len(plugin_names)} plugins" in message
# Try to re-load each of the component plugins here:
for plugin_name in plugin_names:
plugin = load_test_plugin(plugin_filename, disable_caching=True, plugin_name=plugin_name)
assert plugin_name == plugin.name
+
+
[email protected]("plugin_filename", AVAILABLE_PLUGINS_IN_TEST_ENVIRONMENT)
+def test_get_plugin_name_from_regular_plugin(plugin_filename: str):
+ plugin_path = os.path.join(TEST_PLUGIN_BASE_PATH, platform.system(), plugin_filename)
+ if ".vst3" in plugin_filename:
+ names = pedalboard.VST3Plugin.get_plugin_names_for_file(plugin_path)
+ elif ".component" in plugin_filename:
+ names = pedalboard.AudioUnitPlugin.get_plugin_names_for_file(plugin_path)
+ else:
+ raise ValueError("Plugin does not seem to be a .vst3 or .component.")
+
+ assert len(names) == 1
+ assert load_test_plugin(plugin_filename).name == names[0]
+
+
+ not AVAILABLE_CONTAINER_PLUGINS_IN_TEST_ENVIRONMENT,
+ reason="No plugin containers installed in test environment!",
+)
[email protected]("plugin_filename", AVAILABLE_CONTAINER_PLUGINS_IN_TEST_ENVIRONMENT)
+def test_get_plugin_names_from_container(plugin_filename: str):
+ plugin_path = os.path.join(TEST_PLUGIN_BASE_PATH, platform.system(), plugin_filename)
+ if ".vst3" in plugin_filename:
+ names = pedalboard.VST3Plugin.get_plugin_names_for_file(plugin_path)
+ elif ".component" in plugin_filename:
+ names = pedalboard.AudioUnitPlugin.get_plugin_names_for_file(plugin_path)
+ else:
+ raise ValueError("Plugin does not seem to be a .vst3 or .component.")
+
+ assert len(names) > 1