Started to work on a not so important side project
This commit is contained in:
parent
9f6667adb6
commit
8d2330fbb8
|
|
@ -5,8 +5,8 @@ import re,configparser
|
|||
commandlist={1:"go",2:"stop",3:"resume",4:"timed_go",6:"set",7:"fire",10:"go_off"}
|
||||
# Doc says 11 is go_off, test says otherwise
|
||||
|
||||
def testfunction(*params):
|
||||
print("testfunction used in GMA",params)
|
||||
def testfunction(trigger,*params):
|
||||
print("testfunction used in GMA",trigger,params)
|
||||
return 1 # Not mandatory or even codex, just for testing purposes
|
||||
|
||||
#A MessageParse object MUST be included in the file, the rest is implementation Specific
|
||||
|
|
|
|||
|
|
@ -225,7 +225,8 @@ class BasicActions(object):
|
|||
return int(note)
|
||||
|
||||
def findAction(self,command,number,page):
|
||||
"Find the correct Action when a command is received"
|
||||
""""Find the correct Action when a command is received
|
||||
Should be : (command/actiontype,note,page)"""
|
||||
try:
|
||||
return self.sections[command][str(page)][int(number)]
|
||||
except:
|
||||
|
|
@ -357,7 +358,7 @@ class BasicMidiTrigger(object):
|
|||
# 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)
|
||||
return self.funct(self,val,self.received_note,*self.params)
|
||||
except Exception as e:
|
||||
print("[ERROR] The function for trigger {} stopped in an unexpected way".format(self))
|
||||
print("[ERROR] {}".format(e))
|
||||
|
|
|
|||
|
|
@ -9,26 +9,121 @@ import pyautogui
|
|||
from mapping.midi import MessageParse
|
||||
from mapping.midi import Actions
|
||||
|
||||
BASE_NOTE_INPUT=56
|
||||
BASE_NOTE_MASTERM=48
|
||||
PLUGGED=[0,0,1,0,0,0,1,0]
|
||||
|
||||
def presskey(val,note,*params):
|
||||
class demvars():
|
||||
def __init__(self):
|
||||
self.interface_nb=1
|
||||
self.output=None
|
||||
self.BASE_NOTE_INPUT=56
|
||||
self.BASE_NOTE_MASTERM=48
|
||||
self.BASE_COLORS=[ [1,1,1,1,1,1,1,1],
|
||||
[0,0,0,0,0,0,0,0],
|
||||
[0,0,0,0,0,0,0,0],
|
||||
[0,0,0,0,0,0,0,0],
|
||||
[0,0,0,0,0,0,0,0],
|
||||
[0,0,0,0,0,0,0,0],
|
||||
[0,0,0,0,0,0,0,0],
|
||||
[0,0,0,0,0,0,0,0]
|
||||
]
|
||||
self.active_input=None
|
||||
self.PLUGGED=PLUGGED
|
||||
self.COLORS={"black":0,"green":1,"blinking_green":2,"red":3,"blinking_red":4,"yellow":5,"blinking_yellow":6}
|
||||
# self.
|
||||
def findit(self,col,row):
|
||||
"All index start at zero"
|
||||
return self.BASE_NOTE_INPUT+col-8*row
|
||||
|
||||
def lightcolor(self,col,row,color):
|
||||
self.light(col,row,val=self.COLORS[color])
|
||||
|
||||
def light(self,col,row,val=1):
|
||||
self.lightnote(self.findit(col,row),val)
|
||||
|
||||
def lightnote(self,note,val=1):
|
||||
self.output.send(mido.Message("note_on",note=note,velocity=val))
|
||||
|
||||
VARS=demvars()
|
||||
|
||||
A=[[1,1,1,0],[1,0,0,1],[1,0,0,1],[1,1,1,0],[1,0,0,1],[1,0,0,1],[1,1,1,0]]
|
||||
B=[[1,1,1,0],[0,1,0,0],[0,1,0,0],[0,1,0,0],[0,1,0,0],[0,1,0,0],[1,1,1,0]]
|
||||
C=[[1,1,1,0],[0,1,0,0],[0,1,0,0],[0,1,0,0],[0,1,0,0],[0,1,0,0],[0,1,0,0]]
|
||||
D=[[1,1,1,0],[1,0,0,0],[1,0,0,0],[1,1,1,0],[1,0,0,0],[1,0,0,0],[1,1,1,0]]
|
||||
|
||||
WORD=[A,B,C,D]
|
||||
|
||||
def makeword(table):
|
||||
final=[[] for i in range(8)]
|
||||
|
||||
for letter in table:
|
||||
linef=[]
|
||||
for i in range(len(letter)):
|
||||
linef=letter[i]+[0]
|
||||
final[i]+=linef
|
||||
return final
|
||||
|
||||
BIGWORD=makeword(WORD)
|
||||
|
||||
def _onload(self):
|
||||
"Send a reset colors"
|
||||
import time,sys
|
||||
VARS.output=self.outputs[VARS.interface_nb]
|
||||
for i in range(64):
|
||||
VARS.lightnote(i,0)
|
||||
|
||||
def printletter(letter):
|
||||
for i in range(4):
|
||||
for j in range(7):
|
||||
VARS.light(i,j,letter[j][i])
|
||||
|
||||
def printmatrix(matrix,decx=0,decy=0):
|
||||
maxi,maxj=len(matrix[0]),len(matrix)
|
||||
for i in range(8):
|
||||
for j in range(8):
|
||||
try:
|
||||
VARS.light(i,j,BIGWORD[j-decy][i+decx])
|
||||
except IndexError:
|
||||
pass
|
||||
time.sleep(0.01)
|
||||
|
||||
|
||||
for j in range(20):
|
||||
for i in range(64):
|
||||
VARS.lightnote(i,0)
|
||||
time.sleep(0.05)
|
||||
|
||||
printmatrix(BIGWORD,j,0)
|
||||
time.sleep(0.01)
|
||||
|
||||
# while 1:
|
||||
# for k in range(4):
|
||||
# printletter(WORD[k])
|
||||
# time.sleep(0.5)
|
||||
sys.exit()
|
||||
|
||||
|
||||
def presskey(trigger,val,note,*params):
|
||||
"Press the given keys"
|
||||
pass#print(val,note,params)
|
||||
|
||||
def switchinput(val,note,*params):
|
||||
def switchinput(trigger,val,note,*params):
|
||||
"Switch to the desired layer i1"
|
||||
topress=note-BASE_NOTE_INPUT+1
|
||||
pyautogui.hotkey("i",str(topress))
|
||||
topress=VARS.findit(note-VARS.BASE_NOTE_INPUT+1,0)
|
||||
|
||||
def takeall(val,note,*params):
|
||||
VARS.active_input=topress
|
||||
|
||||
for trigger in trigger.parent.findAction('note_on',note,"*"):
|
||||
print(trigger.value,trigger.intensity)
|
||||
#pyautogui.hotkey("i",str(topress))
|
||||
|
||||
def takeall(trigger,val,note,*params):
|
||||
"Take all TA"
|
||||
pyautogui.hotkey("t","a")
|
||||
#pyautogui.hotkey("t","a")
|
||||
|
||||
def mastermemory(val,note,*params):
|
||||
def mastermemory(trigger,val,note,*params):
|
||||
"Switch to the desired master memory M1"
|
||||
topress=note-BASE_NOTE_MASTERM+1
|
||||
pyautogui.hotkey("m",str(topress))
|
||||
#pyautogui.hotkey("m",str(topress))
|
||||
|
||||
# MidiInterface(config)
|
||||
class MidiInterface(BasicMidiInterface):
|
||||
|
|
@ -36,6 +131,7 @@ class MidiInterface(BasicMidiInterface):
|
|||
|
||||
def __init__(self,configfile):
|
||||
super(MidiInterface,self).__init__(configfile)
|
||||
_onload(self)
|
||||
self.functionlist["presskey"]=presskey
|
||||
self.functionlist["switchinput"]=switchinput
|
||||
self.functionlist["mastermemory"]=mastermemory
|
||||
|
|
|
|||
|
|
@ -49,10 +49,12 @@ if __name__ == '__main__':
|
|||
print("[Error] There was an error while loading patch {} ({})".format(path,e))
|
||||
except KeyboardInterrupt:
|
||||
print("[Keyboard Interrupt] : Exiting...")
|
||||
del Inter
|
||||
#del Inter
|
||||
sys.exit()
|
||||
except OSError:
|
||||
except OSError as e:
|
||||
print('[Error] The patch "patch/{}.ini" is ill-formed or non-existent'.format(args.patch))
|
||||
except TypeError:
|
||||
print("[Error] Can't iterate ofver an emplty list, check the list of inputs for an available input")
|
||||
print(e)
|
||||
except TypeError as e:
|
||||
print("[Error] Can't iterate over an emplty list, check the list of inputs for an available input")
|
||||
print(e)
|
||||
# except KeyError
|
||||
|
|
|
|||
|
|
@ -0,0 +1,12 @@
|
|||
[interface]
|
||||
input=APC MINI MIDI 1
|
||||
output1=APC MINI MIDI 1
|
||||
inputchanel = 1
|
||||
outputchannel1 = 1
|
||||
#outputchannel2 = 1
|
||||
mapping = keystrokes
|
||||
# 1 Green / Blinking green 3 Red 5 Yellow
|
||||
|
||||
[note_on]
|
||||
0-99 = 1/on/0-99
|
||||
0-99/toggle = 1/0
|
||||
|
|
@ -5,23 +5,22 @@
|
|||
outputchannel1 = 1
|
||||
#outputchannel2 = 1
|
||||
mapping = keystrokes
|
||||
|
||||
# 1 Green / Blinking green 3 Red 5 Yellow
|
||||
[note_on]
|
||||
#1-99 = 1/on/1
|
||||
#1-99/toggle = 127/0
|
||||
|
||||
56-63/funct = switchinput()
|
||||
|
||||
56 = 1/on/56/127;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/0
|
||||
57 = 1/on/56/0 ;1/on/57/127;1/on/58/0 ;1/on/59/0 ;1/on/60/0 ;1/on/61/0 ;1/on/62/0 ;1/on/63/0
|
||||
58 = 1/on/56/0 ;1/on/57/0 ;1/on/58/127;1/on/59/0 ;1/on/60/0 ;1/on/61/0 ;1/on/62/0 ;1/on/63/0
|
||||
59 = 1/on/56/0 ;1/on/57/0 ;1/on/58/0 ;1/on/59/127;1/on/60/0 ;1/on/61/0 ;1/on/62/0 ;1/on/63/0
|
||||
60 = 1/on/56/0 ;1/on/57/0 ;1/on/58/0 ;1/on/59/0 ;1/on/60/127;1/on/61/0 ;1/on/62/0 ;1/on/63/0
|
||||
61 = 1/on/56/0 ;1/on/57/0 ;1/on/58/0 ;1/on/59/0 ;1/on/60/0 ;1/on/61/127;1/on/62/0 ;1/on/63/0
|
||||
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
|
||||
56 = 1/on/56/3 ;1/on/57/5 ;1/on/58/5 ;1/on/59/5 ;1/on/60/2 ;1/on/61/5 ;1/on/62/5 ;1/on/63/5
|
||||
57 = 1/on/56/5 ;1/on/57/3 ;1/on/58/5 ;1/on/59/5 ;1/on/60/2 ;1/on/61/5 ;1/on/62/5 ;1/on/63/5
|
||||
58 = 1/on/56/5 ;1/on/57/5 ;1/on/58/3 ;1/on/59/5 ;1/on/60/2 ;1/on/61/5 ;1/on/62/5 ;1/on/63/5
|
||||
59 = 1/on/56/5 ;1/on/57/5 ;1/on/58/5 ;1/on/59/3 ;1/on/60/2 ;1/on/61/5 ;1/on/62/5 ;1/on/63/5
|
||||
60 = 1/on/56/5 ;1/on/57/5 ;1/on/58/5 ;1/on/59/5 ;1/on/60/3 ;1/on/61/5 ;1/on/62/5 ;1/on/63/5
|
||||
61 = 1/on/56/5 ;1/on/57/5 ;1/on/58/5 ;1/on/59/5 ;1/on/60/2 ;1/on/61/3 ;1/on/62/5 ;1/on/63/5
|
||||
62 = 1/on/56/5 ;1/on/57/5 ;1/on/58/5 ;1/on/59/5 ;1/on/60/2 ;1/on/61/5 ;1/on/62/3 ;1/on/63/5
|
||||
63 = 1/on/56/5 ;1/on/57/5 ;1/on/58/5 ;1/on/59/5 ;1/on/60/2 ;1/on/61/5 ;1/on/62/5 ;1/on/63/3
|
||||
|
||||
48-55/funct = mastermemory()
|
||||
98/funct = takeall()
|
||||
|
||||
#98/funct = takeall()
|
||||
|
||||
#[control_change]
|
||||
# 16-18 = 2/cc/1
|
||||
|
|
|
|||
Loading…
Reference in New Issue