Jack2 1.9.6

midi_pack.h

00001 /*
00002  * Copyright (c) 2006,2007 Dmitry S. Baikov
00003  *
00004  *  This program is free software; you can redistribute it and/or modify
00005  *  it under the terms of the GNU General Public License as published by
00006  *  the Free Software Foundation; either version 2 of the License, or
00007  *  (at your option) any later version.
00008  *
00009  *  This program is distributed in the hope that it will be useful,
00010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  *  GNU General Public License for more details.
00013  *
00014  *  You should have received a copy of the GNU General Public License
00015  *  along with this program; if not, write to the Free Software
00016  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00017  */
00018 
00019 #ifndef __jack_midi_pack_h__
00020 #define __jack_midi_pack_h__
00021 
00022 typedef struct
00023 {
00024     int running_status;
00025 }
00026 midi_pack_t;
00027 
00028 static inline
00029 void midi_pack_reset(midi_pack_t *p)
00030 {
00031     p->running_status = 0;
00032 }
00033 
00034 static
00035 void midi_pack_event(midi_pack_t *p, jack_midi_event_t *e)
00036 {
00037     if (e->buffer[0] >= 0x80 && e->buffer[0] < 0xF0) { // Voice Message
00038         if (e->buffer[0] == p->running_status) {
00039             e->buffer++;
00040             e->size--;
00041         } else
00042             p->running_status = e->buffer[0];
00043     } else if (e->buffer[0] < 0xF8) { // not System Realtime
00044         p->running_status = 0;
00045     }
00046 }
00047 
00048 #endif /* __jack_midi_pack_h__ */