SoundMatch Class

This class performs synthesizer sound matching by estimating parameters for a synthesizer in order to match a target input sound. It accepts an implementation of SynthBase to estimate parameters for and an implementation of EstimatorBase, which performs the parameter estimation. Optionally, feature extraction can be performed on the target audio file prior to being fed into the estimator using an implementation of FeaturesBase.

Alternatively, instead of a SynthBase object, a synth config file (JSON synth state, see save_state()) can be used. Sound matching can then be used to return parameters only without requiring a synthesizer.

Example

Sound matching with a genetic algorithm

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
import spiegelib as spgl

# Load synth
synth = spgl.synth.SynthVST("/Library/Audio/Plug-Ins/VST/Dexed.vst")

# Setup a basic GA using MFCC error as the evaluation function
ga_extractor = spgl.features.MFCC(num_mfccs=13, hop_size=1024)
ga = spgl.estimator.BasicGA(synth, ga_extractor)

# Setup sound match object with synth and GA
ga_matcher = spgl.SoundMatch(synth, ga)

# Load a target audio file
target = spgl.AudioBuffer('./target.wav')

# Perform sound matching on audio target
result_audio = ga_matcher.match(target)
result_patch = ga_matcher.get_patch()
class spiegelib.SoundMatch(synth, estimator, features=None)
Parameters
  • synth (Object or String) – If an object, must inherit from SynthBase. If it is a string, it must be the path of a synth config JSON file which contains parameter information and the list of overridden parameters for a synthesizer. see save_state()

  • estimator (Object) – must inherit from spiegelib.estimator.EstimatorBase

  • features (Object, optional) – must inherit from spiegelib.features.FeatureBase

Raises

TypeError – If synth, estimator, or features parameters do not inherit from the correct base class.

get_patch()
Returns

The resulting patch after estimation

Return type

list

Raises

Exception – If sound matching has not been run first

match(target)

Attempt to estimate parameters for target audio

Parameters

target (AudioBuffer) – input audio to use as target

Returns

audio output from synthesizer after sound matching

Return type

AudioBuffer

match_parameters(target, expand=False)

Run estimation of parameters and use audio feature extraction if it has been set.

Parameters
  • target (AudioBuffer) – input audio to use as target

  • expand (bool, optional) – If set to True, will take the parameter values returned from sound matching algorithm and expand with overridden parameters.

Returns

estimated parameter values outputed from estimator

Return type

list

match_from_file(path)

Load audio file from disk and perform sound matching on it

Parameters

filepath (str) – location of audio file on disk

Returns

audio output from synthesizer after sound matching

Return type

AudioBuffer

setup_synth_params(config_location)

Setup synth param settings from a synth config file. Once this is setup, full synthesizer parameter settings can be generated without having to use a synth object. Beneficial for running sound matching without linking to the VST.

Parameters

config_location (str) – synth config JSON file