Add support for instrument plugins that require event loops to run on start. #234
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #233.
The VST3 API allows plugins to assume that an event loop is always running; and as such, many plugins add callbacks to that event loop to handle asynchronous tasks like resource loading. Pedalboard doesn't pump this event loop (unless a GUI is being shown) and so these plugins may never get their callbacks, which usually results in them rendering silent audio when
process(...)
is called.This PR adds a workaround: when loading an instrument plugin, we now perform a quick test at the end of the plugin's load function. We send a single MIDI note (channel 1, middle C, full velocity) and pump the event loop until we get audio back, or until we hit a 5-second timeout.
When tested with a variety of instrument plugins, plugin load time seems to increase by between 0ms and 250ms on my machine - but crucially, we no longer render silent audio for these plugins.