fix portengin get_ports() flags API
[ardour.git] / libs / backends / wavesaudio / waves_midi_event.h
1 /*
2     Copyright (C) 2013 Waves Audio Ltd.
3
4     This program is free software; you can redistribute it and/or modify
5     it under the terms of the GNU General Public License as published by
6     the Free Software Foundation; either version 2 of the License, or
7     (at your option) any later version.
8
9     This program is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12     GNU General Public License for more details.
13
14     You should have received a copy of the GNU General Public License
15     along with this program; if not, write to the Free Software
16     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 */
19
20 #ifndef __libardour_waves_midi_event_h__
21 #define __libardour_waves_midi_event_h__
22
23 #include <stdlib.h>
24 #include <portmidi/portmidi.h>
25 #include "ardour/types.h"
26
27 namespace ARDOUR {
28
29 class WavesMidiEvent
30 {
31 public:
32     enum State {
33         INCOMPLETE,
34         BROKEN,
35         COMPLETE
36     };
37
38     WavesMidiEvent (PmTimestamp timestamp);
39     WavesMidiEvent (PmTimestamp timestamp, const uint8_t* data, size_t datalen);
40     WavesMidiEvent (const WavesMidiEvent& source);
41     ~WavesMidiEvent ();
42     
43     WavesMidiEvent *append_data (const PmEvent &midi_event);
44
45     inline State state () const { return _state; };
46     inline size_t size () const { return _size; };
47     inline PmTimestamp timestamp () const { return _timestamp; };
48     inline void set_timestamp (PmTimestamp time_stamp) { _timestamp = time_stamp; };
49     inline const unsigned char* const_data () const { return _data; };
50     inline unsigned char* data () { return _data; };
51     inline bool operator< (const WavesMidiEvent &other) const { return timestamp () < other.timestamp (); };
52     inline bool sysex () const { return _data && (*_data == SYSEX); };
53
54 private:
55
56     enum
57     {
58         SYSEX = 0xF0,
59         EOX = 0xF7,
60         REAL_TIME_FIRST = 0xF8,
61         STATUS_FIRST = 0x80
62     };
63
64     size_t _size;
65     PmTimestamp _timestamp;
66     uint8_t *_data;
67     State _state;
68
69     static size_t _midi_message_size (PmMessage midi_message);
70 };
71
72
73 } // namespace
74
75 #endif /* __libardour_waves_midi_event_h__ */