Move file suffixes out of the Session class and into filename_extensions.h/cc
[ardour.git] / libs / ardour / ardour / midi_util.h
1 /*
2     Copyright (C) 2006 Paul Davis
3         Written by Dave Robillard, 2006
4
5     This program is free software; you can redistribute it and/or modify
6     it under the terms of the GNU General Public License as published by
7     the Free Software Foundation; either version 2 of the License, or
8     (at your option) any later version.
9
10     This program is distributed in the hope that it will be useful,
11     but WITHOUT ANY WARRANTY; without even the implied warranty of
12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13     GNU General Public License for more details.
14
15     You should have received a copy of the GNU General Public License
16     along with this program; if not, write to the Free Software
17     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18
19 */
20
21 #ifndef __ardour_midi_util_h__ 
22 #define __ardour_midi_util_h__
23
24 #include <ardour/midi_events.h>
25
26 namespace ARDOUR {
27
28 /** Return the size of the given event NOT including the status byte,
29  * or -1 if unknown (eg sysex)
30  */
31 int
32 midi_event_size(unsigned char status)
33 {
34         if (status >= 0x80 && status <= 0xE0) {
35                 status &= 0xF0; // mask off the channel
36         }
37
38         switch (status) {
39                 case MIDI_CMD_NOTE_OFF:
40                 case MIDI_CMD_NOTE_ON:
41                 case MIDI_CMD_NOTE_PRESSURE:
42                 case MIDI_CMD_CONTROL:
43                 case MIDI_CMD_BENDER:
44                 case MIDI_CMD_COMMON_SONG_POS:
45                         return 2;
46
47                 case MIDI_CMD_PGM_CHANGE:
48                 case MIDI_CMD_CHANNEL_PRESSURE:
49                 case MIDI_CMD_COMMON_MTC_QUARTER:
50                 case MIDI_CMD_COMMON_SONG_SELECT:
51                         return 1;
52
53                 case MIDI_CMD_COMMON_TUNE_REQUEST:
54                 case MIDI_CMD_COMMON_SYSEX_END:
55                 case MIDI_CMD_COMMON_CLOCK:
56                 case MIDI_CMD_COMMON_START:
57                 case MIDI_CMD_COMMON_CONTINUE:
58                 case MIDI_CMD_COMMON_STOP:
59                 case MIDI_CMD_COMMON_SENSING:
60                 case MIDI_CMD_COMMON_RESET:
61                         return 0;
62                 
63                 case MIDI_CMD_COMMON_SYSEX:
64                         return -1;
65         }
66
67         return -1;
68 }
69
70 } // namespace ARDOUR
71
72 #endif /* __ardour_midi_util_h__ */