π π A Python library for audio.
C audioaudio-processingaudio-productionaudio-researchaudio-unitaugmentationjucemachine-learningpybind11pythonvst3vst3-host
Set midi messages timestamp relative to buffer start (#259)
Damien Ronssince16742bfcbe
diff --git a/pedalboard/ExternalPlugin.h b/pedalboard/ExternalPlugin.hindex f20f02f..3100dd3 100644--- a/pedalboard/ExternalPlugin.h+++ b/pedalboard/ExternalPlugin.h@@ -1179,7 +1179,7 @@ public:channelPointers.data(), channelPointers.size(), chunkSampleCount);juce::MidiBuffer midiChunk;- midiChunk.addEvents(midiInputBuffer, i, chunkSampleCount, 0);+ midiChunk.addEvents(midiInputBuffer, i, chunkSampleCount, -i);pluginInstance->processBlock(audioChunk, midiChunk);}diff --git a/tests/test_external_plugins.py b/tests/test_external_plugins.pyindex f399e05..e36da55 100644--- a/tests/test_external_plugins.py+++ b/tests/test_external_plugins.py@@ -780,6 +780,23 @@ def test_explicit_instrument_reset():assert max_volume_of(plugin([], 5.0, sr, reset=False)) < 0.00001[email protected](not plugin_named("Magical8BitPlug"), reason="Missing Magical8BitPlug 2 plugin.")[email protected]("buffer_size", [1, 10, 10000])+def test_instrument_notes_span_across_buffers(buffer_size: int):+ plugin = load_test_plugin(plugin_named("Magical8BitPlug"), disable_caching=True)+ sr = 44100+ notes = [+ mido.Message("note_on", note=127, velocity=127, time=0.5),+ mido.Message("note_off", note=127, velocity=127, time=1.0),+ ]++ output = plugin(notes, duration=2, sample_rate=sr, buffer_size=buffer_size)+ output /= np.amax(np.abs(output))+ assert np.mean(np.abs(output[:, : int(sr * 0.5)])) < 0.001+ assert np.mean(np.abs(output[:, int(sr * 0.5) : int(sr * 1)])) > 0.999+ assert np.mean(np.abs(output[:, int(sr * 1) :])) < 0.001++@pytest.mark.parametrize("plugin_filename", AVAILABLE_EFFECT_PLUGINS_IN_TEST_ENVIRONMENT)def test_explicit_reset_in_pedalboard(plugin_filename: str):sr = 44100