diff --git a/libs/ardour/ardour/midi_playlist.h b/libs/ardour/ardour/midi_playlist.h index e41d1fbdfa..6ba7bea592 100644 --- a/libs/ardour/ardour/midi_playlist.h +++ b/libs/ardour/ardour/midi_playlist.h @@ -71,25 +71,6 @@ public: ~MidiPlaylist (); - /** Read a range from the playlist into an event sink. - * - * @param buf Destination for events. - * @param start First sample of read range. - * @param cnt Number of samples in read range. - * @param loop_range If non-null, all event times will be mapped into this loop range. - * @param chan_n Must be 0 (this is the audio-style "channel", where each - * channel is backed by a separate region, not MIDI channels, which all - * exist in the same region and are not handled here). - * @param filter Channel filter to apply or NULL to disable filter - * @return The number of samples read (time, not an event count). - */ - samplecnt_t read (Evoral::EventSink& buf, - samplepos_t start, - samplecnt_t cnt, - Evoral::Range* loop_range, - uint32_t chan_n = 0, - MidiChannelFilter* filter = NULL); - void render (MidiChannelFilter*); RTMidiBuffer* rendered(); diff --git a/libs/ardour/midi_playlist.cc b/libs/ardour/midi_playlist.cc index 21dec88ad4..3b24232626 100644 --- a/libs/ardour/midi_playlist.cc +++ b/libs/ardour/midi_playlist.cc @@ -111,107 +111,6 @@ struct EventsSortByTimeAndType { } }; -samplecnt_t -MidiPlaylist::read (Evoral::EventSink& dst, - samplepos_t start, - samplecnt_t dur, - Evoral::Range* loop_range, - unsigned chan_n, - MidiChannelFilter* filter) -{ - typedef pair TrackerInfo; - - Playlist::RegionReadLock rl (this); - - DEBUG_TRACE (DEBUG::MidiPlaylistIO, string_compose ("---- MidiPlaylist::read %1 .. %2 ----\n", start, start + dur)); - - /* Find relevant regions that overlap [start..end] */ - const samplepos_t end = start + dur - 1; - std::vector< boost::shared_ptr > regs; - std::vector< boost::shared_ptr > ended; - for (RegionList::iterator i = regions.begin(); i != regions.end(); ++i) { - - /* check for the case of solo_selection */ - bool force_transparent = ( _session.solo_selection_active() && SoloSelectedActive() && !SoloSelectedListIncludes( (const Region*) &(**i) ) ); - if ( force_transparent ) - continue; - - switch ((*i)->coverage (start, end)) { - case Evoral::OverlapStart: - case Evoral::OverlapInternal: - regs.push_back (*i); - break; - - case Evoral::OverlapExternal: - /* this region is entirely contained in the read range */ - regs.push_back (*i); - ended.push_back (*i); - break; - - case Evoral::OverlapEnd: - /* this region ends within the read range */ - regs.push_back (*i); - ended.push_back (*i); - break; - - default: - /* we don't care */ - break; - } - } - - /* If we are reading from a single region, we can read directly into dst. Otherwise, - we read into a temporarily list, sort it, then write that to dst. */ - const bool direct_read = regs.size() == 1 && - (ended.empty() || (ended.size() == 1 && ended.front() == regs.front())); - - Evoral::EventList evlist; - Evoral::EventSink& tgt = direct_read ? dst : evlist; - - DEBUG_TRACE (DEBUG::MidiPlaylistIO, - string_compose ("\t%1 regions to read, direct: %2\n", regs.size(), direct_read)); - - for (vector >::iterator i = regs.begin(); i != regs.end(); ++i) { - boost::shared_ptr mr = boost::dynamic_pointer_cast(*i); - if (!mr) { - continue; - } - - MidiCursor cursor; // XXX remove me - - /* Read from region into target. */ - DEBUG_TRACE (DEBUG::MidiPlaylistIO, string_compose ("read from %1 at %2 for %3 LR %4 .. %5\n", - mr->name(), start, dur, - (loop_range ? loop_range->from : -1), - (loop_range ? loop_range->to : -1))); - mr->read_at (tgt, start, dur, loop_range, cursor, chan_n, _note_mode, 0, filter); - - if (find (ended.begin(), ended.end(), *i) != ended.end()) { - /* Region ended within the read range, so resolve any active notes - (either stuck notes in the data, or notes that end after the end - of the region). */ - DEBUG_TRACE (DEBUG::MidiPlaylistIO, string_compose ("\t%1 ended, resolve notes and delete\n", mr->name())); - } - } - - if (!direct_read && !evlist.empty()) { - /* We've read from multiple regions, sort the event list by time. */ - EventsSortByTimeAndType cmp; - evlist.sort (cmp); - - /* Copy ordered events from event list to dst. */ - for (Evoral::EventList::iterator e = evlist.begin(); e != evlist.end(); ++e) { - Evoral::Event* ev (*e); - dst.write (ev->time(), ev->event_type(), ev->size(), ev->buffer()); - delete ev; - } - } - - DEBUG_TRACE (DEBUG::MidiPlaylistIO, "---- End MidiPlaylist::read ----\n"); - _read_end = start + dur; - return dur; -} - void MidiPlaylist::reset_note_trackers () { diff --git a/libs/ardour/midi_track.cc b/libs/ardour/midi_track.cc index 53a3ed3366..be28de4655 100644 --- a/libs/ardour/midi_track.cc +++ b/libs/ardour/midi_track.cc @@ -497,7 +497,9 @@ MidiTrack::export_stuff (BufferSet& buffers, mpl->reset_note_trackers (); // TODO once at start and end ? buffers.get_midi(0).clear(); - if (mpl->read(buffers.get_midi(0), start, nframes, 0) != nframes) { + MidiStateTracker ignored; + + if (mpl->rendered()->read(buffers.get_midi(0), start, nframes, ignored, 0) != nframes) { return -1; }