Fixed a small issue with fixed value

Discovered 2 big issues
This commit is contained in:
Malphaet 2019-05-15 15:34:13 +02:00
parent 5cf2cc2ac4
commit 1fa78612ab
4 changed files with 32 additions and 7 deletions

View File

@ -27,4 +27,7 @@ To do so add a custom patch (or use a currently defined one, but chances are pat
* 57/toggle = 0/127: Toggle the val between 127 and 0 every time the note is received
# Adding another mapping interface
* Good luck
* TODO: Explain it better than just "look at the ones I made"
# Improvements
* Add Fix values

View File

@ -2,6 +2,8 @@
import configparser
import mido,re
from math import trunc
from math import sin,cos,tan
from random import randint
class BasicMidiInterface(object):
"Basic midi interface"
@ -149,10 +151,12 @@ class BasicActions(object):
for a in action.split(";"):
allactions+=self.makeAllKeys(key,a,startkey,stopkey)
return allactions
binded=False
try:
pack=action.split("/")
if len(pack)==4:
interfaceout,midiaction,note,intensity=pack
binded=True
elif len(pack)==2:
midiaction,note=pack
interfaceout,intensity=1,127
@ -160,6 +164,7 @@ class BasicActions(object):
if pack[0][0] not in self.dec10: #Extremely cheesy way to know if it's the interface nb or a command
midiaction,note,intensity=pack
interfaceout=1
binded=True
else:
interfaceout,midiaction,note=pack
intensity=127
@ -171,7 +176,7 @@ class BasicActions(object):
try:
interF=self.interface.interfaceOut(int(interfaceout))
noteN=self.findNote(key,startkey,stopkey,note)
return [BasicMidiTrigger(interF,midiaction,noteN,intensity)]
return [BasicMidiTrigger(interF,midiaction,noteN,intensity,binded)]
except (KeyError):
print("[WARNING] Can't find interface {} for note {} action {}, legal interfaces are {}".format(interfaceout,note,action,[i for i in self.interface.outputs.keys()]))
return [] #This choice is not necessary the best, but I figure it's easier that forcing the config to be perfect
@ -234,13 +239,15 @@ class MatchError(Exception):
class BasicMidiTrigger(object):
"""A midi trigger, will do a specific action when called"""
def __init__(self,interface,messagetype,value,intensity):
def __init__(self,interface,messagetype,value,intensity,binded):
self.output=interface
self.messagetype=messagetype
self.value=value
self.intensity=intensity
print(value,intensity)
self.interface=interface
self.valuefn=None
self.binded=binded
message=RecognisedMessagesTypes[messagetype]
attributes={}
self.toggle=None
@ -264,14 +271,16 @@ class BasicMidiTrigger(object):
# if not cond(val):
# return #A condition isn't met, returning
change=self.value
if self.valuefn:
change=self.valuefn(val)
elif self.toggle!=None:
elif self.toggle!=None: # I fear this is intensity that is supposed to change, debug incomming...
if self.toggle:
change=self.valtrue
else:
change=self.valfalse
elif self.binded:
val=self.intensity
print("bind {}".format(val))
else:
change=val
if change != None and change !="":

2
midiRebind.py Normal file → Executable file
View File

@ -1,3 +1,5 @@
#!/bin/python3
import mido, argparse, sys
import configparser,importlib

View File

@ -10,7 +10,18 @@
[note_on]
0-99 = 1/on/0
0-99/toggle = 127/0
0-99. = 2/on/0
#0-99. = 2/on/0
0-10 = 2/cc/1/45;2/cc/2/56
[note_off]
#0-99 = 2/off/1
#0-99./toggle = 45/12
[control_change]
1-100 = 2/cc/0
16-19 = 2/cc/1
16-19/val = lambda x:min(randint(x,x+4),127)
20-23 = 2/cc/1
20-23/val = lambda x:min(60,x)
24-27 = 2/cc/1
24-27/val = lambda x:int((sin(18*x*3.14/127)*60+60))
62-63 = 2/cc/1-1;2/cc/2-2;2/cc/3-3