aboutsummaryrefslogtreecommitdiffstats
path: root/solo-tool-project/src/solo_tool/handlers.py
diff options
context:
space:
mode:
authorEddy Pedroni <epedroni@pm.me>2025-02-23 13:01:15 +0100
committerEddy Pedroni <epedroni@pm.me>2025-02-23 13:01:15 +0100
commit54c368d4c0613f215ebce4c01334f8794ce014d7 (patch)
treea76d5d09c458177963e8b8c6e13db6624649b7b8 /solo-tool-project/src/solo_tool/handlers.py
parentfd05e8a3a53afae850f539a348e209c4770ec430 (diff)
MIDI interface fix, CLI tested and working
Diffstat (limited to 'solo-tool-project/src/solo_tool/handlers.py')
-rw-r--r--solo-tool-project/src/solo_tool/handlers.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/solo-tool-project/src/solo_tool/handlers.py b/solo-tool-project/src/solo_tool/handlers.py
index 13e982b..0a4ee21 100644
--- a/solo-tool-project/src/solo_tool/handlers.py
+++ b/solo-tool-project/src/solo_tool/handlers.py
@@ -19,3 +19,17 @@ def positionToKeyPoint(st: SoloTool) -> Callable[[], None]:
def f():
st.keyPoint = st.position
return f
+
+def changeKeyPoint(st: SoloTool, delta: int) -> Callable[[], None]:
+ from bisect import bisect_right, bisect_left
+ def f():
+ if delta > 0:
+ pivot = bisect_right(st.keyPoints, st.keyPoint) - 1
+ elif delta < 0:
+ pivot = bisect_left(st.keyPoints, st.keyPoint) - 1
+ else:
+ return
+ new = max(min(pivot + delta, len(st.keyPoints) - 1), 0)
+ st.keyPoint = st.keyPoints[new]
+ return f
+