Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
  • 3 commits
  • 2 files changed
  • 0 comments
  • 2 contributors
Nov 02, 2011
Werner Almesberger input.c: synchronize with MIDI status and ignore real-time messages
This patch synchronizes the first (status) byte of each message and
it also ignores real-time messages which can appear _inside_ the
data of other messages.

I didn't make provisions for doing anything clever about SysEx,
because we don't handle them anyway.
77634db
Sébastien Bourdeauducq input: remove MIDI timeout 0d995f0
Sébastien Bourdeauducq New X2 patch from Werner 5606d55
41  patches/Interactive/Werner - X2 (MIDI).fnp
... ...
@@ -0,0 +1,41 @@
  1
+fDecay=0.9950000
  2
+fVideoEchoZoom=2.000000
  3
+fVideoEchoAlpha=0.000000
  4
+nVideoEchoOrientation=0
  5
+nWaveMode=2
  6
+bAdditiveWaves=0
  7
+bWaveDots=0
  8
+bMaximizeWaveColor=1
  9
+bTexWrap=1
  10
+mv_a=0
  11
+nMotionVectorsX=12
  12
+nMotionVectorsY=9
  13
+fWaveAlpha=3.000000
  14
+fWaveScale=3.020000
  15
+fWarpAnimSpeed=1.000000
  16
+fWarpScale=2.853000
  17
+zoom=1.031000
  18
+rot=0.000000
  19
+cx=0.500000
  20
+cy=0.500000
  21
+dx=0.000000
  22
+dy=0.000000
  23
+warp=0.309000
  24
+sx=1.000000
  25
+sy=1.000000
  26
+wave_r=0.600000
  27
+wave_g=0.600000
  28
+wave_b=0.600000
  29
+wave_x=0.500000
  30
+wave_y=0.500000
  31
+per_frame=wave_scale=midi4*20;
  32
+per_frame=t=time*midi8*5;
  33
+per_frame=wave_r = midi5*( 0.60*sin(0.933*t) + 0.40*sin(1.045*t) );
  34
+per_frame=wave_g = midi6*( 0.60*sin(0.900*t) + 0.40*sin(0.956*t) );
  35
+per_frame=wave_b = midi7*( 0.60*sin(0.910*t) + 0.40*sin(0.920*t) );
  36
+per_frame=zoom = zoom + 0.023*( 0.60*sin(0.339*time) + 0.40*sin(0.276*time) );
  37
+per_frame=rot = rot + 0.030*( 0.60*sin(0.381*time) + 0.40*sin(0.579*time) );
  38
+per_frame=rot=midi1*2;
  39
+per_frame=wave_x=0.5+midi3/5;
  40
+per_frame=zoom=0.9+midi2/5;
  41
+per_vertex=rot = rot + (rad-0.4)*1.7*max(0,min((bass_att-1.1)*1.5,5));
25  src/input.c
@@ -253,29 +253,28 @@ static int handle_midi_msg(mtk_event *e, unsigned char *msg)
253 253
 	}
254 254
 }
255 255
 
256  
-#define MIDI_TIMEOUT 20
257  
-
258  
-static int midi_p;
259  
-static rtems_interval midi_last;
  256
+static unsigned char *midi_p = NULL;
260 257
 static unsigned char midi_msg[3];
261 258
 
262 259
 static int handle_midi_event(mtk_event *e, unsigned char *msg)
263 260
 {
264  
-	rtems_interval t;
265 261
 	int r;
266 262
 
267  
-	t = rtems_clock_get_ticks_since_boot();
268  
-	if(t > (midi_last + MIDI_TIMEOUT))
269  
-		midi_p = 0;
270  
-	midi_last = t;
  263
+	if((*msg & 0xf8) == 0xf8)
  264
+		return 0; /* ignore system real-time */
  265
+
  266
+	if(*msg & 0x80)
  267
+		midi_p = midi_msg; /* status byte */
  268
+
  269
+	if(!midi_p)
  270
+		return 0; /* ignore extra or unsynchronized data */
271 271
 
272  
-	midi_msg[midi_p] = msg[0];
273  
-	midi_p++;
  272
+	*midi_p++ = *msg;
274 273
 
275  
-	if(midi_p == 3) {
  274
+	if(midi_p == midi_msg+3) {
276 275
 		/* received a complete MIDI message */
277 276
 		r = handle_midi_msg(e, midi_msg);
278  
-		midi_p = 0;
  277
+		midi_p = NULL;
279 278
 		return r;
280 279
 	}
281 280
 	

No commit comments for this range

Something went wrong with that request. Please try again.