remove MidiPlaylist::read() API

This commit is contained in:
Paul Davis 2019-10-26 19:54:10 -06:00
parent 7dfae40e3b
commit 6e0c5483b2
3 changed files with 3 additions and 121 deletions

View File

@ -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<samplepos_t>& buf,
samplepos_t start,
samplecnt_t cnt,
Evoral::Range<samplepos_t>* loop_range,
uint32_t chan_n = 0,
MidiChannelFilter* filter = NULL);
void render (MidiChannelFilter*);
RTMidiBuffer* rendered();

View File

@ -111,107 +111,6 @@ struct EventsSortByTimeAndType {
}
};
samplecnt_t
MidiPlaylist::read (Evoral::EventSink<samplepos_t>& dst,
samplepos_t start,
samplecnt_t dur,
Evoral::Range<samplepos_t>* loop_range,
unsigned chan_n,
MidiChannelFilter* filter)
{
typedef pair<MidiStateTracker*,samplepos_t> 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<Region> > regs;
std::vector< boost::shared_ptr<Region> > 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<samplepos_t> evlist;
Evoral::EventSink<samplepos_t>& 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<boost::shared_ptr<Region> >::iterator i = regs.begin(); i != regs.end(); ++i) {
boost::shared_ptr<MidiRegion> mr = boost::dynamic_pointer_cast<MidiRegion>(*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<samplepos_t> cmp;
evlist.sort (cmp);
/* Copy ordered events from event list to dst. */
for (Evoral::EventList<samplepos_t>::iterator e = evlist.begin(); e != evlist.end(); ++e) {
Evoral::Event<samplepos_t>* 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 ()
{

View File

@ -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;
}