Added verbose option
This commit is contained in:
parent
75ad6ce95c
commit
0bef104171
|
|
@ -5,6 +5,9 @@ from math import trunc
|
|||
from math import sin,cos,tan
|
||||
from random import randint
|
||||
|
||||
def vprint(message):
|
||||
pass
|
||||
|
||||
class BasicMidiInterface(object):
|
||||
"Basic midi interface"
|
||||
def __init__(self,configfile):
|
||||
|
|
@ -84,7 +87,6 @@ class BasicActions(object):
|
|||
self.config=midiInterface.config
|
||||
self.interface=midiInterface
|
||||
self.sections={}
|
||||
#self.outputs={} #Have every output in a dict THIS PART IS SUPPOSEDLY ALREADY TAKEN CARE OF
|
||||
|
||||
# Very cheesy way to figure out notes from control, I should find a better way, but I can't be bothered to
|
||||
self.dec10=[str(x) for x in range(10)]
|
||||
|
|
@ -126,7 +128,7 @@ class BasicActions(object):
|
|||
for trigger in (keys[int(i)]):
|
||||
trigger.addspecial(atype,conf[key])
|
||||
else:
|
||||
print(note,trunc(float(note)))
|
||||
#print(note,trunc(float(note)))
|
||||
for trigger in keys[trunc(float(note))]:
|
||||
trigger.addspecial(atype,conf[key])
|
||||
elif "-" in key: # There is a range of values to map
|
||||
|
|
@ -242,6 +244,7 @@ class MatchError(Exception):
|
|||
class BasicMidiTrigger(object):
|
||||
"""A midi trigger, will do a specific action when called"""
|
||||
def __init__(self,interface,messagetype,value,intensity,binded):
|
||||
#self.vprint=vprint
|
||||
self.output=interface
|
||||
self.messagetype=messagetype
|
||||
self.value=value
|
||||
|
|
@ -289,9 +292,9 @@ class BasicMidiTrigger(object):
|
|||
self.message=self.message.copy(**self.valuetype)
|
||||
|
||||
def sendmessage(self):
|
||||
vprint("[Sent]: {}".format(self.message)) #TODO Add Verbose option
|
||||
if self.toggle!=None:
|
||||
self.toggle=not self.toggle
|
||||
#print("SENDING:",self.message) #TODO Add Verbose option
|
||||
self.interface.send(self.message)
|
||||
|
||||
def addspecial(self,typ,val):
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
#!/bin/python3
|
||||
|
||||
import mido, argparse, sys
|
||||
import configparser,importlib
|
||||
import configparser,importlib,mapping
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
@ -20,17 +20,20 @@ if __name__ == '__main__':
|
|||
|
||||
Module=importlib.import_module(interpath)
|
||||
|
||||
#from mapping import GrandMA2
|
||||
Inter=Module.MidiInterface(path) # TODO, take directly a config object, will save some time
|
||||
Par=Module.MessageParse()
|
||||
Acts=Module.Actions(Inter)
|
||||
|
||||
if args.verbose:
|
||||
def vprint(msg):
|
||||
print(msg)
|
||||
mapping.base.vprint=vprint
|
||||
for msg in Inter.input:
|
||||
if args.verbose:
|
||||
try:
|
||||
print("[Received] {}".format(str.join([hex(i).split('x')[1] for i in msg.data])))
|
||||
print("[Received]: {}".format(str.join([hex(i).split('x')[1] for i in msg.data])))
|
||||
except:
|
||||
print("[Received {}".format(msg))
|
||||
print("[Received]: {}".format(msg))
|
||||
try:
|
||||
match=Par(msg)
|
||||
res=Acts(match)
|
||||
|
|
|
|||
Loading…
Reference in New Issue