summaryrefslogtreecommitdiff
path: root/libs/ardour/midi_playlist.cc
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2016-11-08 20:34:45 -0500
committerDavid Robillard <d@drobilla.net>2016-11-08 20:34:45 -0500
commitc61373212a87e519276d4c011994e2d37c77ee16 (patch)
tree216e0fcd47e24cd8db0511a074d2d203cb18fa5e /libs/ardour/midi_playlist.cc
parent72297c0ca31400767177bbcb9310721c481a7dd8 (diff)
Support multiple readers for MIDI source/model
Fixes the multiple reader issue #6541 properly without resorting to a linear search kludge. All the read state has been pulled out into a MidiCursor which the caller is required to pass. The playlist keeps cursors for all the regions it is reading, any number of cursors are allowed at a time. MidiCursor should probably be made a smarter and more fool-proof object (and/or possibly merged with some of the other tracker/fixer stuff) but for now I wanted to keep it simple.
Diffstat (limited to 'libs/ardour/midi_playlist.cc')
-rw-r--r--libs/ardour/midi_playlist.cc20
1 files changed, 17 insertions, 3 deletions
diff --git a/libs/ardour/midi_playlist.cc b/libs/ardour/midi_playlist.cc
index b845758f47..4c200f60b5 100644
--- a/libs/ardour/midi_playlist.cc
+++ b/libs/ardour/midi_playlist.cc
@@ -195,7 +195,7 @@ MidiPlaylist::read (Evoral::EventSink<framepos_t>& dst,
mr->name(), start, dur,
(loop_range ? loop_range->from : -1),
(loop_range ? loop_range->to : -1)));
- mr->read_at (tgt, start, dur, loop_range, chan_n, _note_mode, &tracker->tracker, filter);
+ mr->read_at (tgt, start, dur, loop_range, tracker->cursor, chan_n, _note_mode, &tracker->tracker, filter);
DEBUG_TRACE (DEBUG::MidiPlaylistIO,
string_compose ("\tPost-read: %1 active notes\n", tracker->tracker.on()));
@@ -208,6 +208,7 @@ MidiPlaylist::read (Evoral::EventSink<framepos_t>& dst,
mr->name(), ((new_tracker) ? "new" : "old")));
tracker->tracker.resolve_notes (tgt, loop_range ? loop_range->squish ((*i)->last_frame()) : (*i)->last_frame());
+ tracker->cursor.invalidate (false);
if (!new_tracker) {
_note_trackers.erase (t);
}
@@ -261,7 +262,7 @@ MidiPlaylist::region_edited(boost::shared_ptr<Region> region,
/* Queue any necessary edit compensation events. */
t->second->fixer.prepare(
_session.tempo_map(), cmd, mr->position() - mr->start(),
- _read_end, mr->midi_source()->model()->active_notes());
+ _read_end, t->second->cursor.active_notes);
}
void
@@ -292,6 +293,15 @@ MidiPlaylist::remove_dependents (boost::shared_ptr<Region> region)
_note_trackers.erase(region.get());
}
+void
+MidiPlaylist::region_going_away (boost::weak_ptr<Region> region)
+{
+ boost::shared_ptr<Region> r = region.lock();
+ if (r) {
+ remove_dependents(r);
+ }
+}
+
int
MidiPlaylist::set_state (const XMLNode& node, int version)
{
@@ -357,8 +367,12 @@ MidiPlaylist::destroy_region (boost::shared_ptr<Region> region)
i = tmp;
}
- }
+ NoteTrackers::iterator t = _note_trackers.find(region.get());
+ if (t != _note_trackers.end()) {
+ _note_trackers.erase(t);
+ }
+ }
if (changed) {
/* overload this, it normally means "removed", not destroyed */