From 5556905785441ba7610ed620d46f20a55a8c63b8 Mon Sep 17 00:00:00 2001 From: Dandaedre Date: Sun, 19 Sep 2021 12:40:42 +0200 Subject: [PATCH] Started to work on the function interface --- README.md | 4 ++++ gui.py | 7 +++++++ mapping/base.py | 11 ++++++++++- mapping/keystrokes.py | 4 ++++ 4 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 gui.py create mode 100644 mapping/keystrokes.py diff --git a/README.md b/README.md index e412674..564172b 100644 --- a/README.md +++ b/README.md @@ -25,9 +25,13 @@ To do so add a custom patch (or use a currently defined one, but chances are pat * Advanced usage: Can add logic to the notes. NB: they must be defined first * 56/cond = lambda x: x==50 # Function choosing conditions on the value to send * 57/toggle = 0/127: Toggle the val between 127 and 0 every time the note is received + * 68/func = functionMappedInTheMappingInterface(note,intensity,parameters) # Adding another mapping interface * TODO: Explain it better than just "look at the ones I made" # Improvements * Add Fix values +* Better note / cc / pc notation +* Add Fade (in ms) from one value to another +* Have a way to know last value for the note/cc (the last one sent/received) diff --git a/gui.py b/gui.py new file mode 100644 index 0000000..a7190b2 --- /dev/null +++ b/gui.py @@ -0,0 +1,7 @@ +#!/bin/python3 + +import dearpygui.dearpygui as dpg +from dearpygui.demo import show_demo + +show_demo() +dpg.start_dearpygui() diff --git a/mapping/base.py b/mapping/base.py index 47dc81d..16edabf 100644 --- a/mapping/base.py +++ b/mapping/base.py @@ -118,7 +118,7 @@ class BasicActions(object): def makeTriggers(self,conf): "Take a section of a config and put all triggers in a dict" keys={} - for key in conf: # Reading every mapping and liking it to the appropriate Trigger + for key in conf: # Reading every mapping and linking it to the appropriate Trigger if "/" in key: # There is a condition to an action note,atype=key.split("/") if "-" in note: @@ -302,6 +302,8 @@ class BasicMidiTrigger(object): elif typ == "toggle": valt,valf=val.split("/") self.addstate(int(valt),int(valf)) + elif typ == "funct": + self.addspecfn(val) def addvalfn(self,fn): "Add a special function to calculate the value" @@ -311,6 +313,13 @@ class BasicMidiTrigger(object): except: print("[ERROR] Cant evaluate funtion {}".format(fn)) + def addspecfn(self,val): + "Add a funtion (defined in the mapping) with eventual arguments specified in the mapping" + try: + self.funct=mapping.__get_attribute__(val) + except: + print("[ERROR] Can't evaluate function {}".function(fn)) + def addstate(self,valtrue,valfalse): "The message will now send two state values intead" self.toggle=True diff --git a/mapping/keystrokes.py b/mapping/keystrokes.py new file mode 100644 index 0000000..408213e --- /dev/null +++ b/mapping/keystrokes.py @@ -0,0 +1,4 @@ +#!/bin/python3 + + +import pyautogui