Finished the base midi thingy, colors and better config with toggle or smth ?
This commit is contained in:
parent
e0a978cff2
commit
9f6667adb6
|
|
@ -38,3 +38,5 @@ To do so add a custom patch (or use a currently defined one, but chances are pat
|
|||
* Make toggles a function modifying a variable/state and sending result
|
||||
* Allow for a multi-in interfaces
|
||||
* Allow for a null interface out
|
||||
* URGENT : /funct with an existing trigger might not work, should be with an empty trigger anyway.
|
||||
* Add asynchroneous mode ?
|
||||
|
|
|
|||
|
|
@ -133,11 +133,11 @@ class BasicActions(object):
|
|||
else:
|
||||
keys[key_i]+=self.makeAllKeys(key_i,actions_t,startkey=startkey,stopkey=stopkey)
|
||||
else:
|
||||
for trigger in keys[key_i]:
|
||||
if special:
|
||||
trigger.addspecial(special,actions_t)
|
||||
else:
|
||||
keys[key_i]=self.makeAllKeys(key_i,actions_t,startkey=startkey,stopkey=stopkey) #Do a different trigger for every ; and link to a different interface for every n/
|
||||
if special in ["val","toggle"]: # Only do the function once # TODO: ADD FUNCTION WITH MESSAGE
|
||||
for trigger in keys[key_i]:
|
||||
trigger.addspecial(special,actions_t) # Should only do this for /toggle and /val
|
||||
else:
|
||||
keys[key_i]+=self.makeAllKeys(key_i,actions_t,startkey=startkey,stopkey=stopkey) #Do a different trigger for every ; and link to a different interface for every n/
|
||||
|
||||
def makeTriggers(self,conf):
|
||||
"Take a section of a config and put all triggers in a dict"
|
||||
|
|
@ -353,11 +353,11 @@ class BasicMidiTrigger(object):
|
|||
def execspecialfn(self,val):
|
||||
"Executing a special function"
|
||||
try:
|
||||
vprint("[Sent:({}.)]: {} - Note {} / Parameters : {}".format(self.interface_short_name,self.funct,self.received_note,self.params))
|
||||
vprint("[Sent:({}.)]: Note {} / Parameters : {}".format(self.interface_short_name,self.received_note,self.params))
|
||||
# self.funct(self.params)
|
||||
if self.funct:
|
||||
vprint("[Sending function {} - Note {} / Parameters : {}".format(self.funct.__name__,self.received_note,self.params))
|
||||
return self.funct(val,self.received_note,*self.params)
|
||||
print("Done")
|
||||
except Exception as e:
|
||||
print("[ERROR] The function for trigger {} stopped in an unexpected way".format(self))
|
||||
print("[ERROR] {}".format(e))
|
||||
|
|
@ -393,6 +393,7 @@ class EmptyTrigger(BasicMidiTrigger):
|
|||
|
||||
def __call__(self, val):
|
||||
"Send the message"
|
||||
vprint("[Sending function (call) {} - Note {} / Parameters : {}".format(self.funct.__name__,self.received_note,self.params))
|
||||
self.execspecialfn(val)
|
||||
|
||||
def changevalue(self,val):
|
||||
|
|
@ -401,6 +402,7 @@ class EmptyTrigger(BasicMidiTrigger):
|
|||
|
||||
def sendmessage(self,val):
|
||||
"It's empty, can't send any message"
|
||||
vprint("[Sending function (send) {} - Note {} / Parameters : {}".format(self.funct,self.received_note,self.params))
|
||||
self.execspecialfn(val)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -9,24 +9,27 @@ import pyautogui
|
|||
from mapping.midi import MessageParse
|
||||
from mapping.midi import Actions
|
||||
|
||||
BASE_NOTE=56
|
||||
BASE_NOTE_INPUT=56
|
||||
BASE_NOTE_MASTERM=48
|
||||
|
||||
def presskey(val,note,*params):
|
||||
"Press the given keys"
|
||||
pass#print(val,note,params)
|
||||
|
||||
def switchinput(val,note,*params):
|
||||
"Switch to the desired layer"
|
||||
topress=note-BASE_NOTE+1
|
||||
print(val,note)
|
||||
"Switch to the desired layer i1"
|
||||
topress=note-BASE_NOTE_INPUT+1
|
||||
pyautogui.hotkey("i",str(topress))
|
||||
|
||||
def takeall():
|
||||
"TA"
|
||||
pass
|
||||
def takeall(val,note,*params):
|
||||
"Take all TA"
|
||||
pyautogui.hotkey("t","a")
|
||||
|
||||
def mastermemory(val,note,*params):
|
||||
"Switch to the desired master memory M1"
|
||||
topress=note-BASE_NOTE_MASTERM+1
|
||||
pyautogui.hotkey("m",str(topress))
|
||||
|
||||
def mastermemory():
|
||||
"M1"
|
||||
# MidiInterface(config)
|
||||
class MidiInterface(BasicMidiInterface):
|
||||
"Adding a couple of custom functions"
|
||||
|
|
@ -35,3 +38,5 @@ class MidiInterface(BasicMidiInterface):
|
|||
super(MidiInterface,self).__init__(configfile)
|
||||
self.functionlist["presskey"]=presskey
|
||||
self.functionlist["switchinput"]=switchinput
|
||||
self.functionlist["mastermemory"]=mastermemory
|
||||
self.functionlist["takeall"]=takeall
|
||||
|
|
|
|||
|
|
@ -20,5 +20,8 @@
|
|||
62 = 1/on/56/0 ;1/on/57/0 ;1/on/58/0 ;1/on/59/0 ;1/on/60/0 ;1/on/61/0 ;1/on/62/127;1/on/63/0
|
||||
63 = 1/on/56/0 ;1/on/57/0 ;1/on/58/0 ;1/on/59/0 ;1/on/60/0 ;1/on/61/0 ;1/on/62/0 ;1/on/63/127
|
||||
|
||||
48-55/funct = mastermemory()
|
||||
98/funct = takeall()
|
||||
|
||||
#[control_change]
|
||||
# 16-18 = 2/cc/1
|
||||
|
|
|
|||
Loading…
Reference in New Issue