aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2021-05-06 20:56:32 +0200
committerThomas White <taw@physics.org>2021-05-06 21:06:19 +0200
commit7611fe55164efb00f3b83a4f137c5b7ea9bf6bd5 (patch)
tree2a0caacea8bc11208aeea78c2644927106ebf8a6
parent40d564b7427f4e58b53962aeb1fea8d431bcca6f (diff)
Slow down MIDI transmisisons
My control surface (A&H Xone:K2) seems to respond badly to being blasted with note on/off events to turn its LEDs on and off: some of the LEDs end up in the wrong state. The effect is reproducible using a small test program using the ALSA API from C, which excludes multi-threading problems in Starlet and buffer overruns in the ALSA device. The controller simply doesn't cope well with large numbers of events arriving in quick succession. Adding a very small delay seems to completely fix the problem without causing any noticable flicker.
-rw-r--r--guile/starlet/midi-control/base.scm3
1 files changed, 2 insertions, 1 deletions
diff --git a/guile/starlet/midi-control/base.scm b/guile/starlet/midi-control/base.scm
index 9585766..cbd113e 100644
--- a/guile/starlet/midi-control/base.scm
+++ b/guile/starlet/midi-control/base.scm
@@ -218,7 +218,8 @@
(let again ()
(let ((bytes-to-send (atomic-box-swap! send-queue '())))
(for-each (lambda (a)
- (put-u8 midi-port a))
+ (put-u8 midi-port a)
+ (usleep 1))
bytes-to-send)
(usleep 1000)
(again))))