-
Notifications
You must be signed in to change notification settings - Fork 0
/
device_API.py
66 lines (51 loc) · 2.09 KB
/
device_API.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# name=API
# url=https://github.com/dxstiny/py-flstudio-api/
# author=dxstiny
import sys
import mixer
import ui
import midi
import plugins
from API_Finder import Finder
from MidiCommunicatorReceiver import MidiCommunicatorReceiver
import API_logging
print (sys.version)
print()
print("finder.firstParamByName(query: str, plugin: number) -> e.g. (Gain, 2)")
print("finder.firstPluginByCallName(query: str) -> e.g. Lead 1, TwoKnob Piano, ...")
print("finder.firstPluginByPluginName(query: str) -> e.g. Serum, Patcher, ...")
print()
logger = API_logging.GetLogger()
API_logging.SetLevel(API_logging.Level.info)
def OnMidiMsg(event):
receiver.OnMidiMsg(event)
def OnSetCachedPluginCachedParameter(cachedPlugin, cachedParam, value, slot):
logger.trace(str(value) + " " + str(slot))
plugin = finder.firstPluginByCallName(cachedPlugin, slot)
if plugin == -1:
logger.warning("no plugin w/ call name '" + str(cachedPlugin) + "' found")
return
param = finder.firstParamByName(cachedParam, plugin, slot)
if param == -1:
logger.warning("no param w/ call name '" + str(cachedParam) + "' for plugin '" + str(cachedPlugin) + "' found")
return
OnSetParam(plugin = plugin, param = param, value = value, slot = slot)
def OnSetCachedPluginParameter(cachedPlugin, param, value, slot):
plugin = finder.firstPluginByCallName(cachedPlugin)
if plugin == -1:
logger.warning("no plugin w/ call name '" + cachedPlugin + "' found")
return
OnSetParam(plugin, param, value, slot)
def OnSetParam(plugin, param, value, slot = -1):
logger.info("set param '"
+ plugins.getParamName(param, plugin, slot)
+ "' of plugin '"
+ plugins.getPluginName(plugin, slot)
+ "' to '" + str(value) + "'")
plugins.setParamValue(value, param, plugin, slot)
def OnSetMixer(track, volume):
logger.info(str(track) + " " + str(volume))
ui.showWindow(midi.widMixer)
mixer.setTrackVolume(track, volume)
finder = Finder()
receiver = MidiCommunicatorReceiver(OnSetMixer, OnSetParam, OnSetCachedPluginParameter, OnSetCachedPluginCachedParameter)