diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2019-10-14 19:00:32 -0600 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2019-11-02 16:32:18 -0600 |
commit | 22da779322e742775eb8d1e22bdf8c16f20c16b2 (patch) | |
tree | 61327a4f3df2ff393600f78b4573a35d833dbea1 /libs/ardour/midi_region.cc | |
parent | cc949232fe39c4c0a8a0775ab9fc9284df3fb39a (diff) |
introduce new all-in-RAM MIDI datastructure and use it for MIDI playback
Diffstat (limited to 'libs/ardour/midi_region.cc')
-rw-r--r-- | libs/ardour/midi_region.cc | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/libs/ardour/midi_region.cc b/libs/ardour/midi_region.cc index e48c5cf2b1..177555c0ba 100644 --- a/libs/ardour/midi_region.cc +++ b/libs/ardour/midi_region.cc @@ -481,6 +481,79 @@ MidiRegion::_read_at (const SourceList& /*srcs*/, return to_read; } + +int +MidiRegion::dump_to (Evoral::EventSink<samplepos_t>& dst, + uint32_t chan_n, + NoteMode mode, + MidiChannelFilter* filter) const +{ + sampleoffset_t internal_offset = 0; + + /* precondition: caller has verified that we cover the desired section */ + + assert(chan_n == 0); + + if (muted()) { + return 0; /* read nothing */ + } + + + /* dump pulls from zero to infinity ... */ + + if (_position) { + /* we are starting the read from before the start of the region */ + internal_offset = 0; + } else { + /* we are starting the read from after the start of the region */ + internal_offset = -_position; + } + + if (internal_offset >= _length) { + return 0; /* read nothing */ + } + + boost::shared_ptr<MidiSource> src = midi_source(chan_n); + + Glib::Threads::Mutex::Lock lm(src->mutex()); + + src->set_note_mode(lm, mode); + +#if 0 + cerr << "MR " << name () << " read @ " << position << " + " << to_read + << " dur was " << dur + << " len " << _length + << " l-io " << (_length - internal_offset) + << " _position = " << _position + << " _start = " << _start + << " intoffset = " << internal_offset + << " quarter_note = " << quarter_note() + << " start_beat = " << _start_beats + << endl; +#endif + + MidiCursor cursor; + + /* This call reads events from a source and writes them to `dst' timed in session samples */ + + src->midi_read ( + lm, // source lock + dst, // destination buffer + _position - _start, // start position of the source in session samples + _start + internal_offset, // where to start reading in the source + max_samplecnt, + 0, + cursor, + 0, + filter, + _filtered_parameters, + quarter_note(), + _start_beats); + + return 0; +} + + XMLNode& MidiRegion::state () { |