X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fardour%2Fmidi_stretch.cc;h=9cd1321a121e23fb36555b2c5d7ccb44e5262edd;hb=9e0d03020ff47773f7d1c0414de1c74e6c9e0dac;hp=6fd67d05d272cfdaf7083ca533fdf1b6d75199cd;hpb=e0aaed6d65f160c328cb8b56d7c6552ee15d65e2;p=ardour.git diff --git a/libs/ardour/midi_stretch.cc b/libs/ardour/midi_stretch.cc index 6fd67d05d2..9cd1321a12 100644 --- a/libs/ardour/midi_stretch.cc +++ b/libs/ardour/midi_stretch.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2008 Paul Davis + Copyright (C) 2008 Paul Davis Author: Dave Robillard This program is free software; you can redistribute it and/or modify @@ -54,9 +54,9 @@ MidiStretch::run (boost::shared_ptr r) /* the name doesn't need to be super-precise, but allow for 2 fractional digits just to disambiguate close but not identical stretches. */ - + snprintf (suffix, sizeof (suffix), "@%d", (int) floor (_request.time_fraction * 100.0f)); - + string new_name = region->name(); string::size_type at = new_name.find ('@'); @@ -67,15 +67,15 @@ MidiStretch::run (boost::shared_ptr r) } new_name += suffix; - + /* create new sources */ - + if (make_new_sources (region, nsrcs, suffix)) return -1; // FIXME: how to make a whole file region if it isn't? //assert(region->whole_file()); - + boost::shared_ptr src = region->midi_source(0); src->load_model(); @@ -84,13 +84,14 @@ MidiStretch::run (boost::shared_ptr r) boost::shared_ptr new_src = boost::dynamic_pointer_cast(nsrcs[0]); assert(new_src); + new_src->load_model(true, true); boost::shared_ptr new_model = new_src->model(); new_model->start_write(); - + for (Evoral::Sequence::const_iterator i = old_model->begin(); i != old_model->end(); ++i) { const double new_time = i->time() * _request.time_fraction; - + // FIXME: double copy Evoral::Event ev(*i, true); ev.time() = new_time; @@ -99,9 +100,9 @@ MidiStretch::run (boost::shared_ptr r) new_model->end_write(); new_model->set_edited(true); - + const int ret = finish (region, nsrcs, new_name); - + results[0]->set_length((nframes_t) floor (r->length() * _request.time_fraction), NULL); return ret;