Make source length a dynamic thing.

Update MIDI region length (actually and visually) when position changes.


git-svn-id: svn://localhost/ardour2/branches/3.0@4644 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
David Robillard 2009-02-20 00:30:42 +00:00
parent bed0d89337
commit c9582da233
28 changed files with 144 additions and 74 deletions

View file

@ -182,16 +182,17 @@ SMFSource::write_unlocked (MidiRingBuffer<nframes_t>& src, sframes_t position, n
_model->start_write();
}
Evoral::MIDIEvent<nframes_t> ev(0, 0.0, 4, NULL, true);
Evoral::MIDIEvent<nframes_t> ev;
while (true) {
bool ret = src.peek_time(&time);
if (!ret || time - position > _length + dur) {
if (!ret || time > _last_write_end + dur) {
break;
}
ret = src.read_prefix(&time, &type, &size);
if (!ret) {
cerr << "ERROR: Unable to read event prefix, corrupt MIDI ring buffer" << endl;
break;
}
@ -227,10 +228,7 @@ SMFSource::write_unlocked (MidiRingBuffer<nframes_t>& src, sframes_t position, n
Evoral::SMF::flush();
free(buf);
const sframes_t oldlen = _length;
update_length(oldlen, dur);
ViewDataRangeReady(position + oldlen, dur); /* EMIT SIGNAL */
ViewDataRangeReady(position + _last_write_end, dur); /* EMIT SIGNAL */
return dur;
}
@ -254,6 +252,8 @@ SMFSource::append_event_unlocked_beats (const Evoral::Event<double>& ev)
return;
}
_length_beats = max(_length_beats, ev.time());
const double delta_time_beats = ev.time() - _last_ev_time_beats;
const uint32_t delta_time_ticks = (uint32_t)lrint(delta_time_beats * (double)ppqn());
@ -287,6 +287,8 @@ SMFSource::append_event_unlocked_frames (const Evoral::Event<nframes_t>& ev, sfr
BeatsFramesConverter converter(_session, position);
_length_beats = max(_length_beats, converter.from(ev.time()));
const sframes_t delta_time_frames = ev.time() - _last_ev_time_frames;
const double delta_time_beats = converter.from(delta_time_frames);
const uint32_t delta_time_ticks = (uint32_t)(lrint(delta_time_beats * (double)ppqn()));
@ -405,6 +407,8 @@ SMFSource::load_model (bool lock, bool force_reload)
scratch_size = ev.size();
}
ev.size() = scratch_size; // ensure read_event only allocates if necessary
_length_beats = max(_length_beats, ev.time());
}
set_default_controls_interpolation();