More correct looking MidiSource::midi_read.
Testing seems to show the old way and this both working equally well, which is a bit weird since the old way really doesn't seem to make any sense whatsoever. This way works as well as far as I can tell and actually makes sense, so hey, let's go with this one. git-svn-id: svn://localhost/ardour2/branches/3.0@5879 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
370752bf24
commit
38a7cbfc3c
|
@ -194,14 +194,13 @@ MidiRegion::_read_at (const SourceList& /*srcs*/,
|
|||
negative_output_buffer_position = _start;
|
||||
}
|
||||
|
||||
#if 0
|
||||
cerr << "\t\tsource read from " << _position << " - " << _start << " (" << _position - _start << ") "
|
||||
<< " start in source " << _start << " + " << internal_offset << " (" << _start + internal_offset << ") "
|
||||
<< " dur = " << to_read
|
||||
<< " offset = " << output_buffer_position
|
||||
<< " negoffset = " << negative_output_buffer_position
|
||||
<< endl;
|
||||
#endif
|
||||
/*cerr << "MR read @ " << position << " * " << to_read
|
||||
<< " _position = " << _position
|
||||
<< " _start = " << _start
|
||||
<< " offset = " << output_buffer_position
|
||||
<< " negoffset = " << negative_output_buffer_position
|
||||
<< " intoffset = " << internal_offset
|
||||
<< endl;*/
|
||||
|
||||
if (src->midi_read (
|
||||
dst, // destination buffer
|
||||
|
|
|
@ -139,7 +139,6 @@ MidiSource::midi_read (MidiRingBuffer<nframes_t>& dst, sframes_t source_start,
|
|||
BeatsFramesConverter converter(_session, source_start);
|
||||
|
||||
if (_model) {
|
||||
//cerr << "READ @ " << start << " * " << cnt << " (source @ " << source_start << " {" << endl;
|
||||
#define BEATS_TO_FRAMES(t) (converter.to(t) + stamp_offset - negative_stamp_offset)
|
||||
|
||||
Evoral::Sequence<double>::const_iterator& i = _model_iter;
|
||||
|
@ -147,7 +146,7 @@ MidiSource::midi_read (MidiRingBuffer<nframes_t>& dst, sframes_t source_start,
|
|||
// If the cached iterator is invalid, search for the first event past start
|
||||
if (_last_read_end == 0 || start != _last_read_end || !_model_iter_valid) {
|
||||
for (i = _model->begin(); i != _model->end(); ++i) {
|
||||
if (BEATS_TO_FRAMES(i->time()) >= start) {
|
||||
if (converter.to(i->time()) >= start) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -156,13 +155,12 @@ MidiSource::midi_read (MidiRingBuffer<nframes_t>& dst, sframes_t source_start,
|
|||
|
||||
_last_read_end = start + cnt;
|
||||
|
||||
// Read events up to source_start + start + cnt
|
||||
// Read events up to end
|
||||
for (; i != _model->end(); ++i) {
|
||||
const sframes_t time_frames = BEATS_TO_FRAMES(i->time());
|
||||
//cerr << "Read? " << time_frames << " < " << source_start + start + cnt << endl;
|
||||
if (time_frames < source_start + start + cnt) {
|
||||
//cerr << "Read @ " << time_frames << endl;
|
||||
dst.write(time_frames, i->event_type(), i->size(), i->buffer());
|
||||
const sframes_t time_frames = converter.to(i->time());
|
||||
if (time_frames < start + cnt) {
|
||||
dst.write(time_frames + stamp_offset - negative_stamp_offset,
|
||||
i->event_type(), i->size(), i->buffer());
|
||||
if (tracker) {
|
||||
Evoral::MIDIEvent<Evoral::MusicalTime>& ev (*(Evoral::MIDIEvent<Evoral::MusicalTime>*) (&(*i)));
|
||||
if (ev.is_note_on()) {
|
||||
|
@ -172,11 +170,9 @@ MidiSource::midi_read (MidiRingBuffer<nframes_t>& dst, sframes_t source_start,
|
|||
}
|
||||
}
|
||||
} else {
|
||||
//cerr << "End" << endl;
|
||||
break;
|
||||
}
|
||||
}
|
||||
//cerr << "}" << endl;
|
||||
return cnt;
|
||||
} else {
|
||||
return read_unlocked (dst, source_start, start, cnt, stamp_offset, negative_stamp_offset, tracker);
|
||||
|
|
Loading…
Reference in New Issue
Block a user