-
Notifications
You must be signed in to change notification settings - Fork 259
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
Save and Load Presets Automatically for VST3 Plugins? #187
Comments
Hi @Isak-Andersson! There are a couple ways forward here, in order from easiest to hardest:
Let me know if that first option works for you at all, and if not, I'll see what I can do about adding a |
Thanks for the answer. I'm not very familiar with JSON files. Is there a good reason to use them instead of just pure txt files?
Printing the dict it looks like this: Looks reasonable to me. Any idea what the problem could be? |
Yes; JSON handles serialization for you, so you don't need to define your own file format, or write your own serialization and deserialization code. JSON is widely compatible with various programming languages, has types (i.e.: string, float, boolean, etc), is human readable, and can be nicely formatted automatically.
Aha, great find - I haven't tested this code snippet with many plugins, and this falls over due to a problem in Pedalboard with boolean parameters. This is a bit longer but should work instead: my_plugin = load_plugin(...)
my_plugin.show_editor() # make some edits
# Read out the value of every parameter that this plugin exposes:
param_value_dict = {parameter_name: getattr(my_plugin, parameter_name) for parameter_name in
my_plugin.parameters.keys()}
# Unwrap boolean values (which Pedalboard tries to transparently wrap
# for developer convenience, but the JSON library is unfamiliar with):
from pedalboard.pedalboard import WrappedBool
param_value_dict = {k: (bool(v) if isinstance(v, WrappedBool) else v) for k, v in param_value_dict.items()}
# Do something with param_value_dict, like serializing it to JSON:
with open("params.json", "w") as f:
json.dump(param_value_dict, f)
# To reload, just iterate over this dictionary and use `setattr` instead:
for parameter_name, serialized_value in param_value_dict.items():
setattr(my_plugin, parameter_name, serialized_value) |
Thank you. This works nicely for my purpose. |
Just for the record, the path of class WrappedBool had beed modified. The import path is |
If you already have a JSON file configured with the parameter values and you want to use that JSON to assign the values to the object parameters :
|
Hi @psobot, First of all, congrats for the great work!
I hit this corner case with the VST plugins of MeldaProduction. Tested with the MSpectralPan plugin on Windows. The plugin functions properly once I configure it using If you have a quick hack or suggestion for the |
I noticed one more thing. Some of the plugin setting values do work and are loaded from the JSON. Those saved values are applied to the VST plugin in terms of its effect on the audio. But the plugin interface doesn't show the custom values. Therefore, the updates by Edit> I also tried to provide the custom values as "parameter_values" when calling |
@psobot I would love this functionality as a bit of a 'just in case' fallback, as it's hard to know ahead of time what plugins are going to 'behave' in exposing all their features, and which aren't.
@famzah Looking at the pedalboard docs for
Does that work for you? Edit: My bad.. only just saw your edit that said you tried that already. Edit 2: I also wonder if this issue is potentially related? |
This other issue may also be be relevant here, as it talks about another way of controlling preset loading/changing within VST plugins: |
Just wanted to note that #297 just got merged, which may provide one potential angle of a solution here:
Docs:
|
@famzah I was just reading a bit more about how this works in VST3, and it seems there are technically 2 separate types of state; the state that affects the audio, and the rest of the plugin GUI/etc state. I documented some of this + reference links on another issue in this comment: So while I'm not 100% certain, I suspect that may be why you're seeing the difference between the audio effect and GUI. Edit: With regards to this bit:
The following snippet from my other post seems like it can answer it:
Specifically, it seems like the |
Thank you all for your work! I can confirm that the new Here is an example: effect = load_plugin(r'C:\Program Files\Common Files\VST3\MeldaProduction\Stereo\MSpectralPan.vst3')
try:
with open('params.bin', 'rb') as file:
effect.raw_state = file.read()
except FileNotFoundError:
pass
effect.show_editor()
with open('params.bin', 'wb') as file:
file.write(effect.raw_state)
board = Pedalboard([effect]) |
Chorus GAS has its own data structure, so ChorusGAS presets are designed exclusively for it and trying to plug them into other plugins will not work. |
Hello. I'm trying to save the changes I make after I use the show_editor function. What's the best way of saving presets for plugins?
I tried dumping the whole session with dill.dump_session but this gives me this warning and error:
PicklingWarning: Pickling a PyCapsule (None) does not pickle any C data structures and could cause segmentation faults or other memory errors when unpickling. TypeError: cannot pickle 'pedalboard_native.io.WriteableAudioFile' object
Using load_preset with .fxp files isn't much better. It doesn't work with certain plugins and I also don't see a way of saving it. Maybe a save_preset function could be a feature in future versions?
Trying to load a preset for ChorusGAS.vst3 gives me this error:
RuntimeError: Plugin returned an error when loading data from preset file
Any ideas on how to approach this issue?
The text was updated successfully, but these errors were encountered: