2 * Copyright (C) 2014,2017 Robin Gareus <robin@gareus.org>
3 * Copyright (C) 2010 Devin Anderson
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
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.
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 #ifndef _ardour_raw_midi_parser_h_
21 #define _ardour_raw_midi_parser_h_
23 #include "ardour/libardour_visibility.h"
24 #include "ardour/types.h"
28 class LIBARDOUR_API RawMidiParser
35 _unbuffered_bytes = 0;
41 uint8_t const * midi_buffer () const { return _parser_buffer; }
42 size_t buffer_size () const { return _event_size; }
45 * @return true if message is complete, false if more data is needed
47 bool process_byte (const uint8_t byte);
51 void record_byte (uint8_t byte) {
52 if (_total_bytes < sizeof (_parser_buffer)) {
53 _parser_buffer[_total_bytes] = byte;
60 void prepare_byte_event (const uint8_t byte) {
61 _parser_buffer[0] = byte;
65 bool prepare_buffered_event () {
66 const bool result = _unbuffered_bytes == 0;
68 _event_size = _total_bytes;
71 _unbuffered_bytes = 0;
72 if (_status_byte >= 0xf0) {
80 size_t _unbuffered_bytes;
82 size_t _expected_bytes;
84 uint8_t _parser_buffer[1024];
89 #endif /* _ardour_raw_midi_parser_h_ */