Skip to content

Instantly share code, notes, and snippets.

@SrMouraSilva
Last active September 17, 2017 14:20
Show Gist options
  • Save SrMouraSilva/c140d80f41c19def4351951005b6ced5 to your computer and use it in GitHub Desktop.
Save SrMouraSilva/c140d80f41c19def4351951005b6ced5 to your computer and use it in GitHub Desktop.
Mod-ui pedalboard to PluginsManager
// From: http://pedalpi.github.io/WebService/#bank-management-manages-a-bank-by-index-put
{
"index": -1,
"name": "My new bank",
"pedalboards": [
{
"name": "The awesome pedalboard",
"effects": [], <-- Effects list
"connections": [], <-- Connections
"data": {} <-- optional
}
]
}
// From: http://pedalpi.github.io/WebService/#effect-connections-management-manages-by-key-post
// pedalboard.connections are a list of dicts in the following sctructure:
{
"output": {
"effect": 0,
"symbol": "out",
"index": 1
},
"input": {
"effect": 1,
"symbol": "in_l",
"index": 0
}
}
//http://drobilla.net/plugins/fomp/cs_chorus1
// From: http://pedalpi.github.io/WebService/#effect-management
{
"active": true,
"params": [
{
"index": 2,
"maximum": 30,
"value": 7.5,
"symbol": "delay",
"minimum": 0
},
{
"index": 3,
"maximum": 10,
"value": 0.20000000298023224,
"symbol": "mod_freq_1",
"minimum": 0.003000000026077032
},
{
"index": 4,
"maximum": 10,
"value": 2.5,
"symbol": "mod_amp_1",
"minimum": 0
},
{
"index": 5,
"maximum": 30,
"value": 0.800000011920929,
"symbol": "mod_freq_2",
"minimum": 0.009999999776482582
},
{
"index": 6,
"maximum": 3,
"value": 0.75,
"symbol": "mod_amp_2",
"minimum": 0
}
],
"plugin": "http://drobilla.net/plugins/fomp/cs_chorus1",
"technology": "lv2"
}
{
"title": "teste",
"plugins": [
{
"bypassed": false,
"bypassCC": {
"hasRanges": false,
"control": 0,
"channel": -1,
"maximum": 1,
"minimum": 0
},
"preset": "",
"ports": [
{
"value": 0,
"symbol": "CBass",
"midiCC": {
"hasRanges": false,
"control": 0,
"channel": -1,
"maximum": 1,
"minimum": 0
},
"valid": true
},
{
"value": 1,
"symbol": "CLevel",
"midiCC": {
"hasRanges": false,
"control": 0,
"channel": -1,
"maximum": 1,
"minimum": 0
},
"valid": true
},
{
"value": 0,
"symbol": "CTreble",
"midiCC": {
"hasRanges": false,
"control": 0,
"channel": -1,
"maximum": 1,
"minimum": 0
},
"valid": true
},
{
"value": 0,
"symbol": "c_model",
"midiCC": {
"hasRanges": false,
"control": 0,
"channel": -1,
"maximum": 1,
"minimum": 0
},
"valid": true
}
],
"instance": "CABINET",
"x": 653,
"y": 174,
"uri": "http://guitarix.sourceforge.net/plugins/gx_cabinet#CABINET",
"valid": true
}
],
"height": 1176,
"hardware": {
"midi_outs": [],
"midi_ins": [],
"cv_ins": 0,
"serial_midi_out": false,
"audio_outs": 2,
"serial_midi_in": false,
"cv_outs": 0,
"audio_ins": 2
},
"connections": [
{
"source": "capture_2",
"target": "playback_2",
"valid": true
},
{
"source": "capture_1",
"target": "CABINET/in",
"valid": true
},
{
"source": "CABINET/out",
"target": "playback_1",
"valid": true
}
],
"width": 1342,
"timeInfo": {
"rollingCC": {
"hasRanges": false,
"control": 0,
"channel": -1,
"maximum": 0,
"minimum": 0
},
"available": 7,
"bpm": 120,
"bpb": 4,
"rolling": false,
"bpbCC": {
"hasRanges": false,
"control": 0,
"channel": -1,
"maximum": 0,
"minimum": 0
},
"bpmCC": {
"hasRanges": false,
"control": 0,
"channel": -1,
"maximum": 0,
"minimum": 0
}
}
}
import mod
pedalboard_info = mod.utils.get_pedalboard_info('<pedalboard folder>/my_awesome.pedalboard')
print(pedalboard_info)
@SrMouraSilva
Copy link
Author

SrMouraSilva commented Sep 17, 2017

  • Mod-ui python function.py contains information about obtains pedalboard data
  • Example mod-ui pedalboard structure.json is an output example of Mod-ui python function.py. It contains
    • connections: List of connections
    • plugins: Plugins instances informations

An option for creatint the json is creating a simple plugins-manager script.
Obtain data from plugins from the library plugins manager will avoid work on writing the json structure, which requires the minimum and maximum parameters and the order of the parameters.

plugins_json_path = 'plugins_data.json'

import lilvlib
import json

with open(plugins_json_path) as file:
    json.dumps(lilvlib.get_plugin_info_helper(''), file)

from pluginsmanager.model.lv2.lv2_effect_builder import Lv2EffectBuilder
from pluginsmanager.model.pedalboard import Pedalboard

pedalboard = Pedalboard('Name')

builder = Lv2EffectBuilder(plugins_json_path)
effect = builder.build('<effect uri>')
pedalboard.append(effect)
reverb.params['<param symbol string>'].value = param_value

# Generate json
print(pedalboard.json)

Note: Lv2EffectBuilder requires plugins_data generated by lilvlib

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment