def __init__(self, config, vst_config):
        super(VSTEnv, self).__init__()

        self.config = config
        self.vst_config = vst_config

        self.num_knobs = len(vst_config['rnd'])
        self.num_audio_samples = int(
            config['sampleRate'] *
            config['renderLength'])  # Keep audio samples divisible by fftSize
        self.num_audio_samples = self.num_audio_samples - (
            self.num_audio_samples % config['fftSize'])
        self.num_freq = int(1 + (config['fftSize'] / 2.0))
        self.num_mfcc = 20
        #self.num_windows = int((self.num_audio_samples / config['fftSize'] - 1.0) * (config['fftSize'] / config['hopSize']) + 1.0)
        self.num_windows = int((self.num_audio_samples / config['fftSize']) *
                               (config['fftSize'] / config['hopSize']) + 1.0)

        # Mapping from action index (0, 1, ..., num_knobs) to VST parameter
        self.action_to_param = list(vst_config['rnd'].keys())

        self.action_space = MultiDiscrete([self.num_knobs, 4])
        #self.observation_space = spaces.Box(low=-1.0, high=1.0, shape=(self.num_freq, self.num_windows,))
        self.observation_space = spaces.Box(low=-1.0,
                                            high=1.0,
                                            shape=(self.num_mfcc,
                                                   self.num_windows))
        #self.observation_space = spaces.Box(low=0, high=255, shape=(self.num_freq, self.num_windows, 1))

        # Create VST engine and generator
        self.engine = rm.RenderEngine(config['sampleRate'],
                                      config['bufferSize'], config['fftSize'])
        self.engine.load_plugin(vst_config['vstPath'])
        self.generator = rm.PatchGenerator(self.engine)
Beispiel #2
0
    def load_plugin(self, plugin_path):
        """
        Loads a synth VST plugin

        :param plugin_path: path to vst plugin binary
        :type plugin_path: str
        """
        try:
            self.engine = rm.RenderEngine(self.sample_rate, self.buffer_size,
                                          self.buffer_size)

            if self.engine.load_plugin(plugin_path):
                self.loaded_plugin = True
                self.generator = rm.PatchGenerator(self.engine)
                self.patch = self.engine.get_patch()
                self.parameters = parse_parameters(
                    self.engine.get_plugin_parameters_description())

                for i in range(len(self.overridden_params)):
                    index, value = self.overridden_params[i]
                    self.engine.override_plugin_parameter(int(index), value)

            else:
                raise Exception('Could not load VST at path: %s' % plugin_path)

        except Exception as error:
            print(error)
Beispiel #3
0
    def load_plugin(self, plugin_path):
        self.engine = rm.RenderEngine(self.sample_rate, self.buffer_size, 2048)
        if plugin_path == "":
            print "Please supply a non-empty path"
            return

        if self.engine.load_plugin(plugin_path):
            self.loaded_plugin = True
            self.generator = rm.PatchGenerator(self.engine)
            print "Successfully loaded plugin."
        else:
            print "Unsuccessful loading of plugin: is the path correct?"
Beispiel #4
0
 def load_plugin(self, plugin_path):
     self.engine = rm.RenderEngine(self.sample_rate, self.buffer_size, 2048)
     if plugin_path == "":
         print("Please supply a non-empty path")
         return
     if self.engine.load_plugin(plugin_path):
         self.loaded_plugin = True
         self.generator = rm.PatchGenerator(self.engine)
         for i in range(len(self.overriden_parameters)):
             index, value = self.overriden_parameters[i]
             self.engine.override_plugin_parameter(int(index), value)
         print("Successfully loaded plugin.")
     else:
         print("Unsuccessful loading of plugin: is the path correct?")
Beispiel #5
0
def create_synth(dataset, path='synth/diva.64.so'):
    with open("synth/diva_params.txt") as f:
        diva_midi_desc = ast.literal_eval(f.read())
    rev_idx = {diva_midi_desc[key]: key for key in diva_midi_desc}
    if dataset == "toy":
        with open("synth/param_nomod.json") as f:
            param_defaults = json.load(f)
    else:
        with open("synth/param_default_32.json") as f:
            param_defaults = json.load(f)
    engine = rm.RenderEngine(44100, 512, 512)
    engine.load_plugin(path)
    generator = rm.PatchGenerator(engine)
    return engine, generator, param_defaults, rev_idx
Beispiel #6
0
    def __init__(self, plugin_path="/home/gwendal/Jupyter/AudioPlugins/Dexed.so",
                 midi_note_duration_s=3.0, render_duration_s=4.0,
                 sample_rate=22050,  # librosa default sr
                 buffer_size=512, fft_size=512,
                 fadeout_duration_s=0.1):
        self.fadeout_duration_s = fadeout_duration_s  # To reduce STFT discontinuities with long-release presets
        self.midi_note_duration_s = midi_note_duration_s
        self.render_duration_s = render_duration_s

        self.plugin_path = plugin_path
        self.Fs = sample_rate
        self.buffer_size = buffer_size
        self.fft_size = fft_size  # FFT not used

        self.engine = rm.RenderEngine(self.Fs, self.buffer_size, self.fft_size)
        self.engine.load_plugin(self.plugin_path)

        # A generator preset is a list of (int, float) tuples.
        self.preset_gen = rm.PatchGenerator(self.engine)  # 'RenderMan' generator
        self.current_preset = None
# Important settings. These are good general ones.
sampleRate = 44100
bufferSize = 512
fftSize = 512

# This will host a VST. It will render the features and audio we need.
engine = rm.RenderEngine(sampleRate, bufferSize, fftSize)

# Load the VST into the RenderEngine.
path = "/mnt/f/Repos/SHD19/Synthesizer/anysynth-master/notebooks/amsynth_vst.so"
engine.load_plugin(path)

# Create a patch generator. We can initialise it to generate the correct
# patches for a given synth by passing it a RenderEngine which has
# loaded a instance of the synthesiser.
generator = rm.PatchGenerator(engine)

# We can also get a string of information about the
# available parameters.
#print engine.get_plugin_parameters_description()
paramsDict = engine.get_plugin_parameters_description()
paramsDict = {
    p.split(':')[1].strip(): int(p.split(':')[0].strip())
    for p in paramsDict.split('\n')[:-1]
}
print paramsDict

# In[51]:

# Settings to play a note and extract data from the synth.
midiNote = 80
def setup_serum(path):
    engine = rm.RenderEngine(SAMPLE_RATE, BUFFER_SIZE, FFT_SIZE)
    engine.load_plugin(path)
    generator = rm.PatchGenerator(engine)
    return engine, generator