SynthVST Class

SynthVST is a class for interacting with VST synthesizer plugins.

This class relies on the librenderman package developed by Leon Feddon for interacting with VSTs. A VST can be loaded, parameters displayed and modified, random patches generated, and audio rendered for further processing.

class spiegelib.synth.SynthVST(plugin_path=None, **kwargs)

Bases: spiegelib.synth.synth_base.SynthBase

Parameters
  • plugin_path (str, optional) – path to vst plugin binary, defaults to None

  • arguments (keyword) – see spiegelib.synth.synth_base.SynthBase for details

load_plugin(plugin_path)

Loads a synth VST plugin

Parameters

plugin_path (str) – path to vst plugin binary

load_patch()

Update patch parameter. Overridden parameters will not be effected.

is_valid_parameter_setting(parameter)

Checks to see if a parameter is valid for the currently loaded synth.

Parameters

parameter (tuple) – A parameter tuple with form (parameter_index, parameter_value)

render_patch()

Render the current patch. Uses the values of midi_note, midi_velocity, note_length_secs, and render_length_secs to render audio. Plugin must be loaded first.

get_audio()

Return monophonic audio from rendered patch

Returns

An audio buffer of the rendered patch

Return type

spiegelib.core.audio_buffer.AudioBuffer

randomize_patch()

Randomize the current patch. Overridden parameteres will be unaffected.

static expand_sub_patch(patch, param_indices, overridden)

Convert an ordered list of parameter values into a list of tuples containing the parameter indices linked to the parameter values. Does so by comparing the overridden parameters to the full list of paramater indices and using the differences to label the patch values.

Parameters
  • patch (list) – An ordered list of parameter values

  • param_indices (list) – A full list of all parameter indices

  • overridden (list of tuples) – A list of tuples which contain the parameter indices and values of the overridden parameters

Returns

a list of tuples representing a full patch setting

Return type

list

get_parameters()

Returns parameters for the synth

Returns

A dictionary of parameters with the parameter index (int) as the key and the parameter name short description as the value

Return type

Dictionary

get_patch(skip_overridden=True)

Get current patch

Parameters

skip_overridden (bool, optional) – Indicates whether to remove overridden parameters from results, defaults to True

get_random_example()

Returns audio from a new random patch

Returns

An audio buffer

Return type

np.array

load_state(path)

Load parameter state from JSON file. Will set a new patch and overridden parameters.

Parameters

path (str) – Location to load JSON file from

static load_synth_config(path)

Loads and extracts patch setting and overridden parameters from a saved synth JSON file

Parameters

path (str) – location to load JSON file from

Returns

patch list and overridden parameter list

Return type

list, list

save_state(path)

Save parameters and current state to a JSON file. Includes whether or not a parameter has been overridden so this can be used to save synth configuration

Parameters

path (str) – Location to save JSON file to

set_overridden_parameters(parameters)

Override parameters with specific values

Parameters

parameters – List of parameter tuples with parameter index and parameter value that will be patched and then the parameter frozen.

set_patch(parameters)

Set a new patch with updated parameter values with a list of flaots or a list of tuples referring to parameter indices and values.

Parameters

parameters (list) – A list of floats or tuples. If passing in a list of numbers, the length must be either the number of non-overridden parameters of the number of total parameters for this synth. Parameter values will then be mapped to corresponding parameter in order. If a list of tuples is provided, the tuples must have the shape (int, float) where the int is the parameter number and the float is the parameter value.