Skip to content

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

Add test for negative sample counts being returned by external plugins.

Peter Sobot2ddcffa6f2a9
diff --git a/pedalboard/process.h b/pedalboard/process.h
index c34e9aa..56830aa 100644
--- a/pedalboard/process.h
+++ b/pedalboard/process.h
@@ -317,6 +317,12 @@ process<float>(const py::array_t<float, py::array::c_style> inputArray,
juce::dsp::ProcessContextReplacing<float> context(ioBlock);
int outputSamples = plugin->process(context);
+ if (outputSamples < 0) {
+ throw std::runtime_error(
+ "A plugin returned a negative number of output samples! "
+ "This is an internal Pedalboard error and should be reported."
+ );
+ }
pluginSamplesReceived += outputSamples;
int missingSamples = blockSize - outputSamples;
diff --git a/tests/test_external_plugins.py b/tests/test_external_plugins.py
index 6b7bd42..5cf66d5 100644
--- a/tests/test_external_plugins.py
+++ b/tests/test_external_plugins.py
@@ -603,7 +603,7 @@ def test_parameter_name_normalization(_input: str, expected: str):
@pytest.mark.skipif(not plugin_named("CHOWTapeModel"), reason="Missing CHOWTapeModel plugin.")
[email protected]("buffer_size", [128, 8192, 65536])
[email protected]("buffer_size", [16, 128, 8192, 65536])
@pytest.mark.parametrize("oversampling", [1, 2, 4, 8, 16])
def test_external_plugin_latency_compensation(buffer_size: int, oversampling: int):
"""