summaryrefslogtreecommitdiff
path: root/libs/ardour/buffer.cc
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2007-06-09 02:07:59 +0000
committerDavid Robillard <d@drobilla.net>2007-06-09 02:07:59 +0000
commit7ff7f4013dfbbf18d08e397230ad2486fa7ff58f (patch)
tree4740e59efb0749e522c0ae55464e2a5140ebeaa7 /libs/ardour/buffer.cc
parent0605f98fdce1ad456e3da6f6ae391ad394b3edfb (diff)
Use double MIDI timestamps (towards tempo based time, and more-than-sample-accurate LV2 MIDI plugin application).
Eliminate double iteration over MIDIRingBuffer read to translate timestamps. git-svn-id: svn://localhost/ardour2/trunk@1981 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour/buffer.cc')
-rw-r--r--libs/ardour/buffer.cc31
1 files changed, 30 insertions, 1 deletions
diff --git a/libs/ardour/buffer.cc b/libs/ardour/buffer.cc
index 0328122940..2ab70cc96b 100644
--- a/libs/ardour/buffer.cc
+++ b/libs/ardour/buffer.cc
@@ -153,6 +153,35 @@ MidiBuffer::push_back(const MidiEvent& ev)
}
+/** Push an event into the buffer.
+ *
+ * Note that the raw MIDI pointed to by ev will be COPIED and unmodified.
+ * That is, the caller still owns it, if it needs freeing it's Not My Problem(TM).
+ * Realtime safe.
+ * @return false if operation failed (not enough room)
+ */
+bool
+MidiBuffer::push_back(const jack_midi_event_t& ev)
+{
+ if (_size == _capacity)
+ return false;
+
+ Byte* const write_loc = _data + (_size * MAX_EVENT_SIZE);
+
+ memcpy(write_loc, ev.buffer, ev.size);
+ _events[_size].time = (double)ev.time;
+ _events[_size].size = ev.size;
+ _events[_size].buffer = write_loc;
+ ++_size;
+
+ //cerr << "MidiBuffer: pushed, size = " << _size << endl;
+
+ _silent = false;
+
+ return true;
+}
+
+
/** Reserve space for a new event in the buffer.
*
* This call is for copying MIDI directly into the buffer, the data location
@@ -161,7 +190,7 @@ MidiBuffer::push_back(const MidiEvent& ev)
* location, or the buffer will be corrupted and very nasty things will happen.
*/
Byte*
-MidiBuffer::reserve(nframes_t time, size_t size)
+MidiBuffer::reserve(double time, size_t size)
{
assert(size < MAX_EVENT_SIZE);