mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-16 11:46:25 +01:00
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
2 changed files with 13 additions and 18 deletions
|
|
@ -194,14 +194,13 @@ MidiRegion::_read_at (const SourceList& /*srcs*/,
|
||||||
negative_output_buffer_position = _start;
|
negative_output_buffer_position = _start;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
/*cerr << "MR read @ " << position << " * " << to_read
|
||||||
cerr << "\t\tsource read from " << _position << " - " << _start << " (" << _position - _start << ") "
|
<< " _position = " << _position
|
||||||
<< " start in source " << _start << " + " << internal_offset << " (" << _start + internal_offset << ") "
|
<< " _start = " << _start
|
||||||
<< " dur = " << to_read
|
<< " offset = " << output_buffer_position
|
||||||
<< " offset = " << output_buffer_position
|
<< " negoffset = " << negative_output_buffer_position
|
||||||
<< " negoffset = " << negative_output_buffer_position
|
<< " intoffset = " << internal_offset
|
||||||
<< endl;
|
<< endl;*/
|
||||||
#endif
|
|
||||||
|
|
||||||
if (src->midi_read (
|
if (src->midi_read (
|
||||||
dst, // destination buffer
|
dst, // destination buffer
|
||||||
|
|
|
||||||
|
|
@ -139,7 +139,6 @@ MidiSource::midi_read (MidiRingBuffer<nframes_t>& dst, sframes_t source_start,
|
||||||
BeatsFramesConverter converter(_session, source_start);
|
BeatsFramesConverter converter(_session, source_start);
|
||||||
|
|
||||||
if (_model) {
|
if (_model) {
|
||||||
//cerr << "READ @ " << start << " * " << cnt << " (source @ " << source_start << " {" << endl;
|
|
||||||
#define BEATS_TO_FRAMES(t) (converter.to(t) + stamp_offset - negative_stamp_offset)
|
#define BEATS_TO_FRAMES(t) (converter.to(t) + stamp_offset - negative_stamp_offset)
|
||||||
|
|
||||||
Evoral::Sequence<double>::const_iterator& i = _model_iter;
|
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 the cached iterator is invalid, search for the first event past start
|
||||||
if (_last_read_end == 0 || start != _last_read_end || !_model_iter_valid) {
|
if (_last_read_end == 0 || start != _last_read_end || !_model_iter_valid) {
|
||||||
for (i = _model->begin(); i != _model->end(); ++i) {
|
for (i = _model->begin(); i != _model->end(); ++i) {
|
||||||
if (BEATS_TO_FRAMES(i->time()) >= start) {
|
if (converter.to(i->time()) >= start) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -156,13 +155,12 @@ MidiSource::midi_read (MidiRingBuffer<nframes_t>& dst, sframes_t source_start,
|
||||||
|
|
||||||
_last_read_end = start + cnt;
|
_last_read_end = start + cnt;
|
||||||
|
|
||||||
// Read events up to source_start + start + cnt
|
// Read events up to end
|
||||||
for (; i != _model->end(); ++i) {
|
for (; i != _model->end(); ++i) {
|
||||||
const sframes_t time_frames = BEATS_TO_FRAMES(i->time());
|
const sframes_t time_frames = converter.to(i->time());
|
||||||
//cerr << "Read? " << time_frames << " < " << source_start + start + cnt << endl;
|
if (time_frames < start + cnt) {
|
||||||
if (time_frames < source_start + start + cnt) {
|
dst.write(time_frames + stamp_offset - negative_stamp_offset,
|
||||||
//cerr << "Read @ " << time_frames << endl;
|
i->event_type(), i->size(), i->buffer());
|
||||||
dst.write(time_frames, i->event_type(), i->size(), i->buffer());
|
|
||||||
if (tracker) {
|
if (tracker) {
|
||||||
Evoral::MIDIEvent<Evoral::MusicalTime>& ev (*(Evoral::MIDIEvent<Evoral::MusicalTime>*) (&(*i)));
|
Evoral::MIDIEvent<Evoral::MusicalTime>& ev (*(Evoral::MIDIEvent<Evoral::MusicalTime>*) (&(*i)));
|
||||||
if (ev.is_note_on()) {
|
if (ev.is_note_on()) {
|
||||||
|
|
@ -172,11 +170,9 @@ MidiSource::midi_read (MidiRingBuffer<nframes_t>& dst, sframes_t source_start,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
//cerr << "End" << endl;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//cerr << "}" << endl;
|
|
||||||
return cnt;
|
return cnt;
|
||||||
} else {
|
} else {
|
||||||
return read_unlocked (dst, source_start, start, cnt, stamp_offset, negative_stamp_offset, tracker);
|
return read_unlocked (dst, source_start, start, cnt, stamp_offset, negative_stamp_offset, tracker);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue