summaryrefslogtreecommitdiff
path: root/libs/ardour/ardour/midi_buffer.h
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2007-06-29 04:40:41 +0000
committerDavid Robillard <d@drobilla.net>2007-06-29 04:40:41 +0000
commit44867662a3d020e042714d1c5e948b8c3afea941 (patch)
treeb27cfbb56379e3e33ef571bdb1673cf54f4a52f3 /libs/ardour/ardour/midi_buffer.h
parent24ccaac67e9d416b3f3c564a441934313f3e9a21 (diff)
Separate MidiBuffer and AudioBuffer into separate headers (trims the dependency tree, and too large to be in one anyway).
git-svn-id: svn://localhost/ardour2/trunk@2081 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour/ardour/midi_buffer.h')
-rw-r--r--libs/ardour/ardour/midi_buffer.h64
1 files changed, 64 insertions, 0 deletions
diff --git a/libs/ardour/ardour/midi_buffer.h b/libs/ardour/ardour/midi_buffer.h
new file mode 100644
index 0000000000..7e69cc9014
--- /dev/null
+++ b/libs/ardour/ardour/midi_buffer.h
@@ -0,0 +1,64 @@
+/*
+ Copyright (C) 2006 Paul Davis
+ Author: Dave Robillard
+
+ This program is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by the Free
+ Software Foundation; either version 2 of the License, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with this program; if not, write to the Free Software Foundation, Inc.,
+ 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#ifndef __ardour_midi_buffer_h__
+#define __ardour_midi_buffer_h__
+
+#include <ardour/buffer.h>
+
+namespace ARDOUR {
+
+
+/** Buffer containing 8-bit unsigned char (MIDI) data. */
+class MidiBuffer : public Buffer
+{
+public:
+ MidiBuffer(size_t capacity);
+
+ ~MidiBuffer();
+
+ void silence(nframes_t dur, nframes_t offset=0);
+
+ void read_from(const Buffer& src, nframes_t nframes, nframes_t offset);
+
+ bool push_back(const ARDOUR::MidiEvent& event);
+ bool push_back(const jack_midi_event_t& event);
+ Byte* reserve(double time, size_t size);
+
+ const MidiEvent& operator[](size_t i) const { assert(i < _size); return _events[i]; }
+ MidiEvent& operator[](size_t i) { assert(i < _size); return _events[i]; }
+
+ static size_t max_event_size() { return MAX_EVENT_SIZE; }
+
+private:
+ // FIXME: Jack needs to tell us this
+ static const size_t MAX_EVENT_SIZE = 4; // bytes
+
+ /* We use _size as "number of events", so the size of _data is
+ * (_size * MAX_EVENT_SIZE)
+ */
+
+ MidiEvent* _events; ///< Event structs that point to offsets in _data
+ Byte* _data; ///< MIDI, straight up. No time stamps.
+};
+
+
+} // namespace ARDOUR
+
+#endif // __ardour_midi_buffer_h__