summaryrefslogtreecommitdiff
path: root/libs/ardour/midi_buffer.cc
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2019-11-04 12:57:19 -0700
committerPaul Davis <paul@linuxaudiosystems.com>2019-11-04 12:57:19 -0700
commit62c4e88a9d8f4a7b019243fe9a10830b1da0150c (patch)
tree59f4809ddcc999d09898348cea9ca79e2fd20a54 /libs/ardour/midi_buffer.cc
parent47672fceec568949d8dcf3f2be516a644ff4ccbd (diff)
avoid use of Port::port_offset() everywhere except Port::flush_buffers() and Port::get_buffer()
Split cycles are run as if they are an entire self-contained cycle, starting at zero and running for "nframes". We adjust the timing and position of data only when retrieving and writing it to Port buffers.
Diffstat (limited to 'libs/ardour/midi_buffer.cc')
-rw-r--r--libs/ardour/midi_buffer.cc21
1 files changed, 8 insertions, 13 deletions
diff --git a/libs/ardour/midi_buffer.cc b/libs/ardour/midi_buffer.cc
index 0a36c84e49..f447ef59f8 100644
--- a/libs/ardour/midi_buffer.cc
+++ b/libs/ardour/midi_buffer.cc
@@ -96,11 +96,6 @@ MidiBuffer::copy(MidiBuffer const * const copy)
}
-/** Read events from @a src starting at time @a offset into the START of this buffer, for
- * time duration @a nframes. Relative time, where 0 = start of buffer.
- *
- * Note that offset and nframes refer to sample time, NOT buffer offsets or event counts.
- */
void
MidiBuffer::read_from (const Buffer& src, samplecnt_t nframes, sampleoffset_t dst_offset, sampleoffset_t /* src_offset*/)
{
@@ -110,11 +105,10 @@ MidiBuffer::read_from (const Buffer& src, samplecnt_t nframes, sampleoffset_t ds
const MidiBuffer& msrc = (const MidiBuffer&) src;
assert (_capacity >= msrc.size());
+ assert (dst_offset == 0); /* there is no known scenario in Nov 2019 where this should be false */
- if (dst_offset == 0) {
- clear ();
- assert (_size == 0);
- }
+ clear ();
+ assert (_size == 0);
for (MidiBuffer::const_iterator i = msrc.begin(); i != msrc.end(); ++i) {
const Evoral::Event<TimeType> ev(*i, false);
@@ -129,9 +123,10 @@ MidiBuffer::read_from (const Buffer& src, samplecnt_t nframes, sampleoffset_t ds
Check it is within range of this (split) cycle, then shift.
*/
if (ev.time() >= 0 && ev.time() < nframes) {
- push_back (ev.time() + dst_offset, ev.size(), ev.buffer());
+ push_back (ev.time(), ev.size(), ev.buffer());
} else {
- cerr << "\t!!!! MIDI event @ " << ev.time() << " skipped, not within range 0 .. " << nframes << ": ";
+ cerr << "\t!!!! MIDI event @ " << ev.time() << " skipped, not within range 0 .. " << nframes << endl;
+ PBD::stacktrace (cerr, 30);
}
} else {
/* Negative offset: shifting events from global/port
@@ -143,12 +138,12 @@ MidiBuffer::read_from (const Buffer& src, samplecnt_t nframes, sampleoffset_t ds
Shift first, then check it is within range of this
(split) cycle.
*/
- const samplepos_t evtime = ev.time() + dst_offset;
+ const samplepos_t evtime = ev.time();
if (evtime >= 0 && evtime < nframes) {
push_back (evtime, ev.size(), ev.buffer());
} else {
- cerr << "\t!!!! MIDI event @ " << evtime << " (based on " << ev.time() << " + " << dst_offset << ") skipped, not within range 0 .. " << nframes << ": ";
+ cerr << "\t!!!! MIDI event @ " << evtime << " (based on " << ev.time() << ") skipped, not within range 0 .. " << nframes << ": ";
}
}
}