Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: m-labs/flickernoise
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 74534ef
Choose a base ref
...
head repository: m-labs/flickernoise
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: d753464
Choose a head ref
  • 2 commits
  • 1 file changed
  • 2 contributors

Commits on Nov 2, 2011

  1. 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.
    wpwrak authored and Sebastien Bourdeauducq committed Nov 2, 2011
    Copy the full SHA
    248ea5a View commit details
  2. input: remove MIDI timeout

    Sebastien Bourdeauducq committed Nov 2, 2011
    Copy the full SHA
    d753464 View commit details
Showing with 12 additions and 13 deletions.
  1. +12 −13 src/input.c
25 changes: 12 additions & 13 deletions src/input.c
Original file line number Diff line number Diff line change
@@ -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;
}