summaryrefslogtreecommitdiff
path: root/libs/ardour/midi_buffer.cc
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2015-11-29 01:27:18 +0100
committerRobin Gareus <robin@gareus.org>2015-11-29 01:27:18 +0100
commit7a5cea45e1a586b7db7a2d96a366f8e1272d07c1 (patch)
tree10985cf3f49c5149a49b60162f5bc599e3fbb07f /libs/ardour/midi_buffer.cc
parentc4f8a69526b5f9b4412c013b9c582690e1cb2f79 (diff)
fix seamless midi-looping - fixes #5438
well, now... - Midi-Ports have a midi-buffer. - Midi-Tracks have a midi-buffer. - Midi-tracks have a diskstream. - Midi-diskstream has a midi-ring-buffer. - Midi-tracks have a delivery - The delivery can get a reference to the actual backend-ports - The delivery calls the Midi-Port's flush() buffer to send out queued events at the end of a cycle all clear ? :) - when splitting the process-cycle: only the Ports are informed. all other objects see a "normal" short process cycle starting at "0". The offset needs to be applied early on, so that internally routed buffers push the event at the correct time when combining the buffer with immediate and async events. Luckily Port::port_offset() is a static member, available to all, objects, which allows to bridge the conceptual gap between the diskstream and the delivery. There's a snag: When there's a note-on directly at the beginning of the loop it coincides with the panic message sent when looping. The panic comes before note events, so it *should* be good. Also the final note-offs (state tracker end of loop/region) are sent 1 sample too early (smells like an off-by-one), and are hence dropped. (no matter we send a panic right after it). It should really be at the same time, just before the panic.
Diffstat (limited to 'libs/ardour/midi_buffer.cc')
-rw-r--r--libs/ardour/midi_buffer.cc14
1 files changed, 10 insertions, 4 deletions
diff --git a/libs/ardour/midi_buffer.cc b/libs/ardour/midi_buffer.cc
index 71f3e5334c..3a03a03f9e 100644
--- a/libs/ardour/midi_buffer.cc
+++ b/libs/ardour/midi_buffer.cc
@@ -26,6 +26,7 @@
#include "ardour/debug.h"
#include "ardour/midi_buffer.h"
+#include "ardour/port.h"
using namespace std;
using namespace ARDOUR;
@@ -35,6 +36,7 @@ using namespace PBD;
MidiBuffer::MidiBuffer(size_t capacity)
: Buffer (DataType::MIDI)
, _data (0)
+ , _size (0)
{
if (capacity) {
resize (capacity);
@@ -85,7 +87,7 @@ MidiBuffer::copy(const MidiBuffer& copy)
* Note that offset and nframes refer to sample time, NOT buffer offsets or event counts.
*/
void
-MidiBuffer::read_from (const Buffer& src, framecnt_t nframes, framecnt_t dst_offset, framecnt_t src_offset)
+MidiBuffer::read_from (const Buffer& src, framecnt_t nframes, framecnt_t dst_offset, framecnt_t /* src_offset*/)
{
assert (src.type() == DataType::MIDI);
assert (&src != this);
@@ -99,15 +101,19 @@ MidiBuffer::read_from (const Buffer& src, framecnt_t nframes, framecnt_t dst_off
assert (_size == 0);
}
- /* XXX use dst_offset somehow */
+ framecnt_t offset = Port::port_offset();
for (MidiBuffer::const_iterator i = msrc.begin(); i != msrc.end(); ++i) {
const Evoral::MIDIEvent<TimeType> ev(*i, false);
- if (ev.time() >= src_offset && ev.time() < (nframes+src_offset)) {
+ if (ev.time() >= offset && ev.time() < (nframes + offset)) {
push_back (ev);
} else {
cerr << "MIDI event @ " << ev.time() << " skipped, not within range "
- << src_offset << " .. " << (nframes + src_offset) << endl;
+ << offset << " .. " << (nframes + offset) << ":";
+ for (size_t xx = 0; xx < ev.size(); ++xx) {
+ cerr << ' ' << hex << (int) ev.buffer()[xx];
+ }
+ cerr << dec << endl;
}
}