diff options
author | David Robillard <d@drobilla.net> | 2008-10-10 00:39:29 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2008-10-10 00:39:29 +0000 |
commit | 15cdf454ea5a1460b41cb462c35f1ffb853a0764 (patch) | |
tree | d2e2dfec11c3a661d30c18fb4a9d40c7dbcb2326 /libs/ardour/ardour/midi_ring_buffer.h | |
parent | c64e96b6a8f6782a5ad0bc41b7200ec94408aaa5 (diff) |
Apply MIDI looping patch from torbenh, with minor changes.
General idea: use internal events to mark loop boundaries in MIDI buffers so readers can make sense of timestamps.
git-svn-id: svn://localhost/ardour2/branches/3.0@3905 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour/ardour/midi_ring_buffer.h')
-rw-r--r-- | libs/ardour/ardour/midi_ring_buffer.h | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/libs/ardour/ardour/midi_ring_buffer.h b/libs/ardour/ardour/midi_ring_buffer.h index d1acb9b235..6e827d2852 100644 --- a/libs/ardour/ardour/midi_ring_buffer.h +++ b/libs/ardour/ardour/midi_ring_buffer.h @@ -23,6 +23,7 @@ #include <algorithm> #include <ardour/types.h> #include <ardour/buffer.h> +#include <ardour/event_type_map.h> #include <evoral/EventSink.hpp> #include <evoral/EventRingBuffer.hpp> @@ -148,6 +149,18 @@ MidiRingBuffer::read(MidiBuffer& dst, nframes_t start, nframes_t end, nframes_t continue; } + // This event marks a loop happening. this means that + // the next events timestamp will be non-monotonic. + if (ev_type == LoopEventType) { + ev_time -= start; + Evoral::MIDIEvent loopevent(LoopEventType, ev_time); + dst.push_back(loopevent); + + // We can safely return, without reading the data, because + // a LoopEvent does not have data. + return count + 1; + } + uint8_t status; success = full_peek(sizeof(uint8_t), &status); assert(success); // If this failed, buffer is corrupt, all hope is lost @@ -168,6 +181,7 @@ MidiRingBuffer::read(MidiBuffer& dst, nframes_t start, nframes_t end, nframes_t assert(ev_time >= start); ev_time -= start; + ev_time += offset; uint8_t* write_loc = dst.reserve(ev_time, ev_size); if (write_loc == NULL) { |