π π A Python library for audio.
C audioaudio-processingaudio-productionaudio-researchaudio-unitaugmentationjucemachine-learningpybind11pythonvst3vst3-host
Ensure effect plugins can't accept notes.
Peter Sobote751a5909f81
diff --git a/pedalboard/ExternalPlugin.h b/pedalboard/ExternalPlugin.hindex cfef61b..ba5f073 100644--- a/pedalboard/ExternalPlugin.h+++ b/pedalboard/ExternalPlugin.h@@ -913,6 +913,12 @@ public:spec.numChannels = (juce::uint32)numChannels;prepare(spec);+ if (pluginInstance->getMainBusNumInputChannels() > 0) {+ throw std::invalid_argument(+ "Plugin '" + pluginInstance->getName().toStdString() ++ "' expects audio as input, but was provided MIDI messages.");+ }+if ((size_t)pluginInstance->getMainBusNumOutputChannels() !=numChannels) {throw std::invalid_argument(diff --git a/tests/test_external_plugins.py b/tests/test_external_plugins.pyindex fbfa843..e2b416f 100644--- a/tests/test_external_plugins.py+++ b/tests/test_external_plugins.py@@ -340,6 +340,23 @@ def test_instrument_plugin_accepts_notes(assert np.amax(np.abs(output)) > 0[email protected]("plugin_filename", AVAILABLE_EFFECT_PLUGINS_IN_TEST_ENVIRONMENT)[email protected]("num_channels,sample_rate", [(2, 48000), (2, 44100), (2, 22050)])+def test_effect_plugin_does_not_accept_notes(+ plugin_filename: str, num_channels: int, sample_rate: float+):+ notes = [+ mido.Message("note_on", note=100, velocity=3, time=0),+ mido.Message("note_off", note=100, time=5.0),+ ]+ plugin = load_test_plugin(plugin_filename)+ assert plugin.is_effect+ assert not plugin.is_instrument++ with pytest.raises(ValueError):+ plugin(notes, 6.0, sample_rate, num_channels=num_channels)++@pytest.mark.parametrize("plugin_filename", AVAILABLE_INSTRUMENT_PLUGINS_IN_TEST_ENVIRONMENT)@pytest.mark.parametrize("num_channels,sample_rate", [(2, 48000), (2, 44100), (2, 22050)])def test_instrument_plugin_accepts_buffer_size(