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         int running_status;
00024 } midi_pack_t;
00025 
00026 static inline
00027 void midi_pack_reset(midi_pack_t *p)
00028 {
00029         p->running_status = 0;
00030 }
00031 
00032 static
00033 void midi_pack_event(midi_pack_t *p, jack_midi_event_t *e)
00034 {
00035         if (e->buffer[0] >= 0x80 && e->buffer[0] < 0xF0) { // Voice Message
00036                 if (e->buffer[0] == p->running_status) {
00037                         e->buffer++;
00038                         e->size--;
00039                 } else
00040                         p->running_status = e->buffer[0];
00041         } else if (e->buffer[0] < 0xF8) { // not System Realtime
00042                 p->running_status = 0;
00043         }
00044 }
00045 
00046 #endif /* __jack_midi_pack_h__ */

Generated on Thu Feb 14 11:16:02 2008 for Jackdmp by  doxygen 1.5.1