X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fardour%2Fmidi_region.cc;h=e29fb1e65979c77f6407f323fd857fb2c077ea1b;hb=44fd104ada0fbd8b76d34150e941d85d6de6f81b;hp=b0b7e4575fcdd535771e8d9608f9c5c0f607ddc6;hpb=9f63ab9931e6478472853bdda58da47ea29ac125;p=ardour.git diff --git a/libs/ardour/midi_region.cc b/libs/ardour/midi_region.cc index b0b7e4575f..e29fb1e659 100644 --- a/libs/ardour/midi_region.cc +++ b/libs/ardour/midi_region.cc @@ -131,7 +131,8 @@ MidiRegion::master_read_at (MidiRingBuffer& out, nframes_t position, nframes_t d nframes_t MidiRegion::_read_at (const SourceList& srcs, MidiRingBuffer& dst, nframes_t position, nframes_t dur, uint32_t chan_n, NoteMode mode) const { - // cerr << _name << "._read_at(" << position << ") - " << _position << endl; + /*cerr << "MidiRegion " << _name << "._read_at(" << position << ") - " + << position << " duration: " << dur << endl;*/ nframes_t internal_offset = 0; nframes_t src_offset = 0; @@ -171,7 +172,29 @@ MidiRegion::_read_at (const SourceList& srcs, MidiRingBuffer& dst, nframes_t pos boost::shared_ptr src = midi_source(chan_n); src->set_note_mode(mode); - if (src->midi_read (dst, _start + internal_offset, to_read, _position) != to_read) { + nframes_t output_buffer_position = 0; + nframes_t negative_output_buffer_position = 0; + if (_position >= _start) { + // handle resizing of beginnings of regions correctly + output_buffer_position = _position - _start; + } else { + // when _start is greater than _position, we have to subtract + // _start from the note times in the midi source + negative_output_buffer_position = _start; + } + + if (src->midi_read ( + // the destination buffer + dst, + // where to start reading in the region + _start + internal_offset, + // how many bytes + to_read, + // the offset in the output buffer + output_buffer_position, + // what to substract from note times written in the output buffer + negative_output_buffer_position + ) != to_read) { return 0; /* "read nothing" */ } @@ -310,6 +333,12 @@ MidiRegion::separate_by_channel (Session& session, vector& v) const return -1; } +int +MidiRegion::exportme (ARDOUR::Session&, ARDOUR::ExportSpecification&) +{ + return -1; +} + boost::shared_ptr MidiRegion::midi_source (uint32_t n) const {