Beispiel #1
0
def load_engine_konkakt(sr,
                        buf,
                        plugin_path,
                        def_dir,
                        def_name,
                        dest_dir,
                        sleep=7.0,
                        verbose=True):
    """

    :param sr: Sample rate to render audio
    :param buf: Buffer size (in samples) for rendering frames
    :param plugin_path: Absolute path to Kontakt.vst or Kontakt.component (AU)
    :param def_dir: Absolute path to the Konkakt defaults directory
    :param def_name: Default Kontakt .nkm file to load Kontakt with a state
    :param sleep: Sleeps for the specified amount of time. Sometimes Kontakt takes some
        time to load all of the samples.
    :return: RenderMan engine that has Konkakt plugin loaded with state provided by def_name
    """
    copy_and_rename_def(def_dir, def_name, dest_dir)
    eng = rm.RenderEngine(sr, buf)
    assert eng.load_plugin(plugin_path)
    if verbose:
        print('Loaded {}'.format(def_name))
    time.sleep(sleep)
    return eng
    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 #3
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 #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)
            print "Successfully loaded plugin."
        else:
            print "Unsuccessful loading of plugin: is the path correct?"
Beispiel #5
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 #6
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 #7
0
def load_engine(sr, buf, plugin_path, sleep=7.0, verbose=True):
    """

    :param sr:
    :param buf:
    :param plugin_path:
    :param preset:
    :param sleep:
    :param verbose:
    :return:
    """
    eng = rm.RenderEngine(sr, buf)
    assert eng.load_plugin(str(plugin_path))

    # Set parameters like so:
    # eng.set_parameter(90, 0.5)

    time.sleep(sleep)
    return eng
Beispiel #8
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
Beispiel #9
0
# Notes: there's an issue with inconsistent versions of python being linked to by the
# RenderMan build process and conda used by jupyter notebooks. For now, I've opted
# to run this script with /usr/include/python2.7, which is the linked version

import librenderman as rm
import wave
import scipy.io.wavfile
import numpy as np

sampleRate = 44100
bufferSize = 512
fftSize = 512

engine = rm.RenderEngine(sampleRate, bufferSize, fftSize)
sylenth_path = '/Library/Audio/Plug-Ins/VST/Sylenth1.vst'
if engine.load_plugin(sylenth_path):
    print('loaded plugin succesfully')

description = engine.get_plugin_parameters_description()
description = description.split('\n')

# Settings to play a note and extract data from the synth.
midiNote = 40
midiVelocity = 127
noteLength = 0.1
renderLength = 5.0

# # Get the patch and display it!
preset_path = '/Users/andrewcoenen/cannoneyed/synth-embeddings/python/test.fxp'
if engine.load_preset(preset_path):
    print('loaded preset succesfully')
def setup_serum(path):
    engine = rm.RenderEngine(SAMPLE_RATE, BUFFER_SIZE, FFT_SIZE)
    engine.load_plugin(path)
    generator = rm.PatchGenerator(engine)
    return engine, generator