Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: m-labs/flickernoise
base: 74534ef
...
head fork: m-labs/flickernoise
compare: d753464
Checking mergeability… Don't worry, you can still create the pull request.
  • 2 commits
  • 1 file changed
  • 0 commit comments
  • 2 contributors
Commits on Nov 02, 2011
@wpwrak wpwrak 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.
248ea5a
@sbourdeauducq sbourdeauducq input: remove MIDI timeout d753464
Showing with 12 additions and 13 deletions.
  1. +12 −13 src/input.c
View
25 src/input.c
@@ -253,29 +253,28 @@ static int handle_midi_msg(mtk_event *e, unsigned char *msg)
}
}
-#define MIDI_TIMEOUT 20
-
-static int midi_p;
-static rtems_interval midi_last;
+static unsigned char *midi_p = NULL;
static unsigned char midi_msg[3];
static int handle_midi_event(mtk_event *e, unsigned char *msg)
{
- rtems_interval t;
int r;
- t = rtems_clock_get_ticks_since_boot();
- if(t > (midi_last + MIDI_TIMEOUT))
- midi_p = 0;
- midi_last = t;
+ if((*msg & 0xf8) == 0xf8)
+ return 0; /* ignore system real-time */
+
+ if(*msg & 0x80)
+ midi_p = midi_msg; /* status byte */
+
+ if(!midi_p)
+ return 0; /* ignore extra or unsynchronized data */
- midi_msg[midi_p] = msg[0];
- midi_p++;
+ *midi_p++ = *msg;
- if(midi_p == 3) {
+ if(midi_p == midi_msg+3) {
/* received a complete MIDI message */
r = handle_midi_msg(e, midi_msg);
- midi_p = 0;
+ midi_p = NULL;
return r;
}

No commit comments for this range

Something went wrong with that request. Please try again.