From 0bef104171ec96d92b38df16d5ef76f0319b932a Mon Sep 17 00:00:00 2001 From: Malphaet Date: Wed, 22 May 2019 10:42:53 +0200 Subject: [PATCH] Added verbose option --- mapping/base.py | 9 ++++++--- midiRebind.py | 11 +++++++---- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/mapping/base.py b/mapping/base.py index f713215..34557d2 100644 --- a/mapping/base.py +++ b/mapping/base.py @@ -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): diff --git a/midiRebind.py b/midiRebind.py index daffec0..01f9ff8 100755 --- a/midiRebind.py +++ b/midiRebind.py @@ -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)