You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There is a problem arising from implementing VST3Plugin.parameters as a python dict to store the parameters of a VST3 plugin. In fact, as the parameter names are used as keys, if a synthesizer has several parameters with the same name (e.g., Diva envelope 1 and 2 have the same names), they overwrite each other.
This is not a major problem since parameters can still be accessed with the _parameters attribute since this one is implemented as list, but I guess it would be good to find a workaround, e.g., modifying normalize_python_parameter_name() to take an additional index argument (passed to the method by to_python_parameter_name()) which would be prepended to the parameter name. This would generate keys of the form <parameter-index>-<normalized-name> and would ensure that each synthesizer parameter generates a unique key for the dict. This could be implemented as:
defto_python_parameter_name(parameter: _AudioProcessorParameter) ->Optional[str]:
ifnotparameter.nameandnotparameter.label:
returnNonename=parameter.nameifparameter.labelandnotparameter.label.startswith(":"):
name="{} {}".format(name, parameter.label)
returnnormalize_python_parameter_name(name, index)
defnormalize_python_parameter_name(name: str, index: int) ->str:
name=name.lower().strip()
# Special case: some plugins expose parameters with "#"/"♯" or "b"/"♭" in their names.name=name.replace("#", "_sharp").replace("♯", "_sharp").replace("♭", "_flat")
# Replace all non-alphanumeric characters with underscoresname_chars= [
cif (c.isalpha() orc.isnumeric()) andc.isprintable() andord(c) <128else"_"forcinname
]
# Remove any double-underscores:name_chars= [afora, binzip(name_chars, name_chars[1:]) ifa!=borb!="_"] + [
name_chars[-1]
]
# Remove any leading or trailing underscores:name="".join(name_chars).strip("_")
# Prepend parameter index to the namename="".join((str(index), "-", name))
returnname
Here is an example of the issue using Diva:
frompedalboardimportload_pluginsynth=load_plugin(
path_to_plugin_file="C:/Program Files/Audio Plugins/VST3/u-he/Diva(x64).vst3",
plugin_name="Diva",
)
### Get Diva parameters (excl. MIDI CC) using the synth.parameters dictionary {param_name: param_object}params_from_dict= [paramforname, paraminsynth.parameters.items() ifnotname.startswith("cc_")]
### Get Diva parameters (excl. MIDI CC) using the synth._parameters list [param_object]params_from_list= [paramforparaminsynth._parametersifnotparam.name.startswith("CC ")]
# print number of parametersprint("Number of parameters in params dict: ", len(params_from_dict)) # >> 191print("Number of parameters in params list: ", len(params_from_list)) # >> 282# So let print out the parameter names for the first and second envelopes for both synth.parameters and synth._parameters# We can see in the `from list` column that the parameters of the second envelop have the same names as the parameters of the first one,# and since the parameter names are used as keys in synth.parameters(), they overwrite each other in the dict.print(f"{'':<14}{'from list':<14}{'from dict':<18}{'same?'}")
foriinrange(33, 55):
print(
f"Parameter {i}: {params_from_list[i].name:10} -> {params_from_dict[i].name:15} "f"| {params_from_list[i].name==params_from_dict[i].name}"
)
Hi,
thanks for the nice library!
There is a problem arising from implementing
VST3Plugin.parameters
as a python dict to store the parameters of a VST3 plugin. In fact, as the parameter names are used as keys, if a synthesizer has several parameters with the same name (e.g., Diva envelope 1 and 2 have the same names), they overwrite each other.This is not a major problem since parameters can still be accessed with the
_parameters
attribute since this one is implemented as list, but I guess it would be good to find a workaround, e.g., modifying normalize_python_parameter_name() to take an additionalindex
argument (passed to the method by to_python_parameter_name()) which would be prepended to the parameter name. This would generate keys of the form<parameter-index>-<normalized-name>
and would ensure that each synthesizer parameter generates a unique key for the dict. This could be implemented as:Here is an example of the issue using Diva:
which output
The text was updated successfully, but these errors were encountered: