From aef72140273b3d98a4d86a42f0f3bcce6d5899ca Mon Sep 17 00:00:00 2001
From: cbdev <cb@cbcdn.com>
Date: Sun, 28 Jul 2019 23:19:54 +0200
Subject: Fix Lua timing on non-linux

---
 backends/lua.c       | 11 +++++++++--
 backends/osc.md      |  3 +++
 configs/midi-osc.cfg | 19 ++-----------------
 3 files changed, 14 insertions(+), 19 deletions(-)

diff --git a/backends/lua.c b/backends/lua.c
index 61e4e08..4a910a2 100644
--- a/backends/lua.c
+++ b/backends/lua.c
@@ -53,9 +53,16 @@ int init(){
 }
 
 static uint32_t lua_interval(){
-	//FIXME Return delta for next timer here
+	size_t n = 0;
+	uint64_t next_timer = 1000;
+
 	if(timer_interval){
-		return timer_interval;
+		for(n = 0; n < timers; n++){
+			if(timer[n].interval && timer[n].interval - timer[n].delta < next_timer){
+				next_timer = timer[n].interval - timer[n].delta;
+			}
+		}
+		return next_timer;
 	}
 	return 1000;
 }
diff --git a/backends/osc.md b/backends/osc.md
index b7ce527..1446e06 100644
--- a/backends/osc.md
+++ b/backends/osc.md
@@ -58,6 +58,9 @@ To configure a range of faders, an expression similar to the following line coul
 /1/fader* = f 0.0 1.0
 ```
 
+When matching channels against the patterns to use, the first matching pattern (in the order in which they have been configured) will be used
+as configuration for that channel.
+
 #### Channel specification
 
 A channel may be any valid OSC path, to which the instance root will be prepended if
diff --git a/configs/midi-osc.cfg b/configs/midi-osc.cfg
index 1b3ccd6..7753a24 100644
--- a/configs/midi-osc.cfg
+++ b/configs/midi-osc.cfg
@@ -13,23 +13,8 @@ dest = learn@8000
 root = /4
 
 ; Pre-declare the fader values so the range mapping is correct
-/fader1 = f 0.0 1.0
-/fader2 = f 0.0 1.0
-/fader3 = f 0.0 1.0
-/fader4 = f 0.0 1.0
-/fader5 = f 0.0 1.0
-/fader6 = f 0.0 1.0
-/fader7 = f 0.0 1.0
-/fader8 = f 0.0 1.0
-
-/multifader1/1 = f 0.0 1.0
-/multifader1/2 = f 0.0 1.0
-/multifader1/3 = f 0.0 1.0
-/multifader1/4 = f 0.0 1.0
-/multifader1/5 = f 0.0 1.0
-/multifader1/6 = f 0.0 1.0
-/multifader1/7 = f 0.0 1.0
-/multifader1/8 = f 0.0 1.0
+/fader* = f 0.0 1.0
+/multifader1/* = f 0.0 1.0
 
 [midi bcf]
 read = BCF
-- 
cgit v1.2.3