1 /***************************************************************************
2  *                                                                         *
3  *   Copyright (C) 2005, 2006, 2014 Christian Schoenebeck                  *
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., 59 Temple Place, Suite 330, Boston,                 *
18  *   MA  02111-1307  USA                                                   *
19  ***************************************************************************/
20 
21 #ifndef __LS_MIDI_H__
22 #define __LS_MIDI_H__
23 
24 #include <string.h>
25 
26 namespace LinuxSampler {
27 
28     /////////////////////////////////////////////////////////////////
29     // global type definitions
30 
31     /**
32      * MIDI channels
33      */
34     enum midi_chan_t {
35         midi_chan_1   = 0,
36         midi_chan_2   = 1,
37         midi_chan_3   = 2,
38         midi_chan_4   = 3,
39         midi_chan_5   = 4,
40         midi_chan_6   = 5,
41         midi_chan_7   = 6,
42         midi_chan_8   = 7,
43         midi_chan_9   = 8,
44         midi_chan_10  = 9,
45         midi_chan_11  = 10,
46         midi_chan_12  = 11,
47         midi_chan_13  = 12,
48         midi_chan_14  = 13,
49         midi_chan_15  = 14,
50         midi_chan_16  = 15,
51         midi_chan_all = 16
52     };
53 
54     /**
55      * MIDI program index
56      */
57     struct midi_prog_index_t {
58         uint8_t midi_bank_msb; ///< coarse MIDI bank index
59         uint8_t midi_bank_lsb; ///< fine MIDI bank index
60         uint8_t midi_prog;     ///< MIDI program index
61 
62         bool operator< (const midi_prog_index_t& other) const {
63             return memcmp(this, &other, sizeof(midi_prog_index_t)) < 0;
64         }
65     };
66 
isValidMidiChan(const midi_chan_t & ch)67     inline bool isValidMidiChan(const midi_chan_t& ch) {
68         return ch >= 0 && ch <= midi_chan_all;
69     }
70 
71 } // namsepace LinuxSampler
72 
73 #endif // __LS_MIDI_H__
74