diff --git a/libs/ardour/midi_stretch.cc b/libs/ardour/midi_stretch.cc index ed1367a951..21fbde7bf0 100644 --- a/libs/ardour/midi_stretch.cc +++ b/libs/ardour/midi_stretch.cc @@ -100,14 +100,18 @@ MidiStretch::run (boost::shared_ptr r, Progress*) /* Note: pass true into force_discrete for the begin() iterator so that the model doesn't * do interpolation of controller data when we stretch. */ + MidiModel::TimeType final_time; + for (Evoral::Sequence::const_iterator i = old_model->begin (MidiModel::TimeType(), true); i != old_model->end(); ++i) { - const MidiModel::TimeType new_time = i->time().operator* (_request.time_fraction); + const MidiModel::TimeType new_time = i->time() * _request.time_fraction; // FIXME: double copy Evoral::Event ev(*i, true); - ev.set_time(new_time); + ev.set_time (new_time); new_model->append(ev, Evoral::next_event_id()); + + final_time = max (final_time, new_time); } new_model->end_write (Evoral::Sequence::ResolveStuckNotes); @@ -117,10 +121,9 @@ MidiStretch::run (boost::shared_ptr r, Progress*) const int ret = finish (region, nsrcs, new_name); - /* non-musical */ -#warning NUTEMPO FIXME do we still need this? - results[0]->set_length (r->length().operator* ( _request.time_fraction)); + /* set length of new region to precisely match source length */ + + results[0]->set_length (region->length() * _request.time_fraction); return ret; } -