Finished the test of empty messages, and functions, should work as intended
This commit is contained in:
parent
b11eb913f1
commit
58f05a4911
|
|
@ -136,8 +136,15 @@ class BasicActions(object):
|
|||
for trigger in (keys[int(i)]): # TODO : If the key doesn't exist, throw a # WARNING: instead of an error
|
||||
trigger.addspecial(atype,conf[key])
|
||||
else:
|
||||
for trigger in keys[trunc(float(note))]:
|
||||
trigger.addspecial(atype,conf[key])
|
||||
# Special function can be executed with no triggers associated
|
||||
try:
|
||||
for trigger in keys[trunc(float(note))]:
|
||||
trigger.addspecial(atype,conf[key])
|
||||
except KeyError:
|
||||
trigg=EmptyTrigger(self)
|
||||
trigg.addspecial(atype,conf[key])
|
||||
keys[trunc(float(note))]=[trigg]
|
||||
# print("No el key")
|
||||
elif "-" in key: # There is a range of values to map
|
||||
nmin,nmax=key.split("-")
|
||||
nmin,nmax=trunc(float(nmin)),trunc(float(nmax))
|
||||
|
|
@ -338,6 +345,7 @@ class BasicMidiTrigger(object):
|
|||
# print("[ERROR] Can't evaluate function {}".format(val))
|
||||
|
||||
def execspecialfn(self):
|
||||
# self.funct(self.params)
|
||||
return self.funct(self.params)
|
||||
|
||||
def addstate(self,valtrue,valfalse):
|
||||
|
|
@ -348,3 +356,39 @@ class BasicMidiTrigger(object):
|
|||
|
||||
def __repr__(self):
|
||||
return "<MT>({}/{}/{})@{}".format(self.messagetype,self.value,self.intensity,self.output)
|
||||
|
||||
class EmptyTrigger(BasicMidiTrigger):
|
||||
"""An empty trigger, used mainly for function only triggers"""
|
||||
def __init__(self,parent):
|
||||
self.output=None
|
||||
self.messagetype=None
|
||||
self.intensity=None
|
||||
self.interface=None
|
||||
self.value=None
|
||||
self.valuefn=None
|
||||
self.binded=None
|
||||
self.parent=parent
|
||||
self.toggle=None
|
||||
self.valuetype={}
|
||||
self.message=None
|
||||
|
||||
def __call__(self, val):
|
||||
"Send the message"
|
||||
pass
|
||||
|
||||
def changevalue(self,val):
|
||||
"It's empty, can't change valu"
|
||||
pass
|
||||
|
||||
def sendmessage(self):
|
||||
"It's empty, can't send any message"
|
||||
pass
|
||||
|
||||
|
||||
def addvalfn(self,nf):
|
||||
"There's no value to ajust"
|
||||
pass
|
||||
|
||||
def addstate(self):
|
||||
"No state to add"
|
||||
pass
|
||||
|
|
|
|||
|
|
@ -43,5 +43,5 @@
|
|||
15 = 1/cc/2;2/note/19/127
|
||||
|
||||
[custom]
|
||||
77 = 1/cc/0
|
||||
#77 = 1/cc/0
|
||||
77/funct = testfunction(123,zz)
|
||||
|
|
|
|||
4
test.py
4
test.py
|
|
@ -18,7 +18,7 @@ class mappingTest(minitest.simpleTestUnit):
|
|||
"""Testing the parsing/mapping"""
|
||||
def __init__(self):
|
||||
super(mappingTest, self).__init__("parsing/mapping")
|
||||
|
||||
self.verbose=True
|
||||
def _testParsing(self):
|
||||
self.currentTest("Loading default mappings")
|
||||
from mapping import GrandMA2
|
||||
|
|
@ -161,7 +161,7 @@ class mappingTest(minitest.simpleTestUnit):
|
|||
acts=self.act.findAction("custom",77,"2")
|
||||
# print(acts)
|
||||
for act in acts:
|
||||
# print(act,act.funct)
|
||||
#print(act,act.funct)
|
||||
if not act.funct or not act.execspecialfn():
|
||||
st=False
|
||||
self.addFailure("No custom function defined")
|
||||
|
|
|
|||
Loading…
Reference in New Issue