Skip to content

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

Ran clang-format and black.

Peter Sobotdd2bb2fcd8f6
diff --git a/pedalboard/ExternalPlugin.h b/pedalboard/ExternalPlugin.h
index 11f239e..14a52d8 100644
--- a/pedalboard/ExternalPlugin.h
+++ b/pedalboard/ExternalPlugin.h
@@ -227,31 +227,34 @@ public:
}
struct PresetVisitor : public juce::ExtensionsVisitor {
- const std::string presetFilePath;
-
- PresetVisitor(const std::string presetFilePath): presetFilePath(presetFilePath) { }
-
- void visitVST3Client(const juce::ExtensionsVisitor::VST3Client& client) override {
- juce::File presetFile(presetFilePath);
- juce::MemoryBlock presetData;
-
- if (!presetFile.loadFileAsData(presetData)) {
- throw std::runtime_error("Failed to read preset file: " + presetFilePath);
- }
+ const std::string presetFilePath;
- if (!client.setPreset(presetData)) {
- throw std::runtime_error("Plugin returned an error when loading data from preset file: " + presetFilePath);
- }
+ PresetVisitor(const std::string presetFilePath)
+ : presetFilePath(presetFilePath) {}
+
+ void visitVST3Client(
+ const juce::ExtensionsVisitor::VST3Client &client) override {
+ juce::File presetFile(presetFilePath);
+ juce::MemoryBlock presetData;
+
+ if (!presetFile.loadFileAsData(presetData)) {
+ throw std::runtime_error("Failed to read preset file: " +
+ presetFilePath);
}
- };
+ if (!client.setPreset(presetData)) {
+ throw std::runtime_error(
+ "Plugin returned an error when loading data from preset file: " +
+ presetFilePath);
+ }
+ }
+ };
void loadPresetData(std::string presetFilePath) {
- PresetVisitor visitor {presetFilePath};
- pluginInstance->getExtensions(visitor);
+ PresetVisitor visitor{presetFilePath};
+ pluginInstance->getExtensions(visitor);
}
-
void reinstantiatePlugin() {
// If we have an existing plugin, save its state and reload its state later:
juce::MemoryBlock savedState;
@@ -820,8 +823,9 @@ inline void init_external_plugins(py::module &m) {
return ss.str();
})
.def("load_preset",
- &ExternalPlugin<juce::VST3PluginFormat>::loadPresetData,
- "Load a VST3 preset file in .vstpreset format.", py::arg("preset_file_path"))
+ &ExternalPlugin<juce::VST3PluginFormat>::loadPresetData,
+ "Load a VST3 preset file in .vstpreset format.",
+ py::arg("preset_file_path"))
.def_property_readonly_static(
"installed_plugins",
[](py::object /* cls */) { return findInstalledVSTPluginPaths(); },
diff --git a/tests/test_external_plugins.py b/tests/test_external_plugins.py
index 40f0b16..6503d31 100644
--- a/tests/test_external_plugins.py
+++ b/tests/test_external_plugins.py
@@ -189,30 +189,32 @@ def test_at_least_one_parameter(plugin_filename: str):
assert get_parameters(plugin_filename)
+
@pytest.mark.parametrize(
- "plugin_filename,plugin_preset", [
- (plugin,os.path.join(TEST_PRESET_BASE_PATH, plugin+".vstpreset"))
- for plugin in AVAILABLE_PLUGINS_IN_TEST_ENVIRONMENT \
- if os.path.isfile(os.path.join(TEST_PRESET_BASE_PATH, plugin+".vstpreset"))
- ])
+ "plugin_filename,plugin_preset",
+ [
+ (plugin, os.path.join(TEST_PRESET_BASE_PATH, plugin + ".vstpreset"))
+ for plugin in AVAILABLE_PLUGINS_IN_TEST_ENVIRONMENT
+ if os.path.isfile(os.path.join(TEST_PRESET_BASE_PATH, plugin + ".vstpreset"))
+ ],
+)
def test_preset_parameters(plugin_filename: str, plugin_preset: str):
# plugin with default params.
plugin = load_test_plugin(plugin_filename)
- default_params = {
- k: v.raw_value for k, v in plugin.parameters.items() if v.type == float
- }
-
+ default_params = {k: v.raw_value for k, v in plugin.parameters.items() if v.type == float}
# load preset file
plugin.load_preset(plugin_preset)
-
for name, default in default_params.items():
actual = getattr(plugin, name)
if math.isnan(actual):
continue
- assert actual != default, f"Expected attribute {name} was {actual} supposed to be different from default {default}"
+ assert (
+ actual != default
+ ), f"Expected attribute {name} to be different from default ({default}), but was {actual}"
+
@pytest.mark.parametrize("plugin_filename", AVAILABLE_PLUGINS_IN_TEST_ENVIRONMENT)
def test_initial_parameters(plugin_filename: str):