From 7611fe55164efb00f3b83a4f137c5b7ea9bf6bd5 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Thu, 6 May 2021 20:56:32 +0200 Subject: 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. --- guile/starlet/midi-control/base.scm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'guile/starlet') 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)))) -- cgit v1.2.3