Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for instrument plugins that require event loops to run on start. #234

Merged
merged 7 commits into from
Jul 28, 2023

Conversation

psobot
Copy link
Member

@psobot psobot commented Jul 27, 2023

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.

@psobot psobot added the bug Something isn't working label Jul 27, 2023
@psobot psobot requested a review from drubinstein July 27, 2023 18:42
Copy link
Contributor

@drubinstein drubinstein left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense. Can you make the warm up optional or make timeoutMilliseconds configurable from the Python API?

I'm curious if you could decrease warm up time by choosing a smaller bufferSize or sampleRate.

pedalboard/ExternalPlugin.h Outdated Show resolved Hide resolved
@psobot psobot merged commit 4e12405 into master Jul 28, 2023
23 checks passed
@psobot psobot deleted the psobot/plugin-initialization-delay branch July 28, 2023 19:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Some VST3 instruments produce no audio output until a UI is shown.
2 participants