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

Some VST3 plugins unable to load preset data until editor UI is shown #394

Open
ben-hayes opened this issue Jan 21, 2025 · 1 comment
Open

Comments

@ben-hayes
Copy link

Hey all 😊

It seems that there exists at least one VSTi (Surge XT) where the UI needs to be rendered before setting preset data has any effect. That is, with a preset that should set the parameter "a_osc_1_type" to "Modern", the following fails:

from pedalboard import VST3Plugin

p = VST3Plugin("/Library/Audio/Plug-Ins/VST3/Surge XT.vst3")
p.load_preset("presets/surge-base.vstpreset")
assert p.a_osc_1_type == "Modern"  # AssertionError

And the following works:

p = VST3Plugin("/Library/Audio/Plug-Ins/VST3/Surge XT.vst3")
p.show_editor()  # then manually or programmatically close editor
p.load_preset("presets/surge-base.vstpreset")
assert p.a_osc_1_type == "Modern"  # All good!

However, it doesn't seem that opening the UI will cause previously loaded preset data to have an effect:

# However...
p = VST3Plugin("/Library/Audio/Plug-Ins/VST3/Surge XT.vst3")
p.load_preset("presets/surge-base.vstpreset")
p.show_editor()  # then manually or programmatically close editor
assert p.a_osc_1_type == "Modern"  # AssertionError again...

I would guess this is related to #233, in that some crucial state is initialised on the UI thread, although interestingly the following doesn't work:

import matplotlib.pyplot as plt
p = VST3Plugin("/Library/Audio/Plug-Ins/VST3/Surge XT.vst3")
plt.plot([]); plt.show()
p.load_preset("presets/surge-base.vstpreset")
assert p.a_osc_1_type == "Modern"  # AssertionError

It's not the end of the world as the KeyboardInterrupt workaround does the job, but just thought I'd bring yet-another-ungodly-audio-plugin-edge-case to your attention 😇

Cheers!

@psobot
Copy link
Member

psobot commented Jan 22, 2025

@ben-hayes! Great to hear from you.

I think I know why this happens; technically, Pedalboard is non-conformant to the VST3 Host spec, as we only use one thread for everything. The spec says that plugins should expect to be called from multiple threads (one for UI/events, one for audio rendering) and that the main thread runs an event loop. We've had a couple small issues like this before, and I've "fixed" them by manually pumping the event loop after certain operations; this might be fixable just with a small time-limited juce::MessageManager::run call after load_preset.

I can't commit to any specific timeline for looking into this at the moment, but this might be a fairly quick fix (and I'd be very open to PRs if you or anybody else were to put one up 😀)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants