X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fardour%2Fmidi_stretch.cc;h=71ffcc21e111319f34f747a5c09b9eeeecd5579d;hb=d9de72215b85fb480bca948069d2c583aa342544;hp=7a4164427a24ba0f7e7a0a530acc9cb41c1ef04c;hpb=0bc8832e208154a0f172d34182ed6b0bc8bba52f;p=ardour.git diff --git a/libs/ardour/midi_stretch.cc b/libs/ardour/midi_stretch.cc index 7a4164427a..71ffcc21e1 100644 --- a/libs/ardour/midi_stretch.cc +++ b/libs/ardour/midi_stretch.cc @@ -24,7 +24,6 @@ #include "ardour/midi_region.h" #include "ardour/midi_source.h" #include "ardour/midi_stretch.h" -#include "ardour/session.h" #include "ardour/types.h" #include "i18n.h" @@ -33,7 +32,7 @@ using namespace std; using namespace ARDOUR; using namespace PBD; -MidiStretch::MidiStretch (Session& s, TimeFXRequest& req) +MidiStretch::MidiStretch (Session& s, const TimeFXRequest& req) : Filter (s) , _request (req) { @@ -50,8 +49,9 @@ MidiStretch::run (boost::shared_ptr r, Progress*) char suffix[32]; boost::shared_ptr region = boost::dynamic_pointer_cast(r); - if (!region) + if (!region) { return -1; + } /* the name doesn't need to be super-precise, but allow for 2 fractional digits just to disambiguate close but not identical stretches. @@ -75,29 +75,32 @@ MidiStretch::run (boost::shared_ptr r, Progress*) 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(); + { + Source::Lock lock(src->mutex()); + src->load_model(lock); + } boost::shared_ptr old_model = src->model(); boost::shared_ptr new_src = boost::dynamic_pointer_cast(nsrcs[0]); - assert(new_src); + if (!new_src) { + error << _("MIDI stretch created non-MIDI source") << endmsg; + return -1; + } - Glib::Mutex::Lock sl (new_src->mutex ()); + Glib::Threads::Mutex::Lock sl (new_src->mutex ()); - new_src->load_model(false, true); + new_src->load_model(sl, true); boost::shared_ptr new_model = new_src->model(); new_model->start_write(); /* Note: pass true into force_discrete for the begin() iterator so that the model doesn't * do interpolation of controller data when we stretch. */ - for (Evoral::Sequence::const_iterator i = old_model->begin (0, true); + for (Evoral::Sequence::const_iterator i = old_model->begin (MidiModel::TimeType(), true); i != old_model->end(); ++i) { - const double new_time = i->time() * _request.time_fraction; + const MidiModel::TimeType new_time = i->time() * (double)_request.time_fraction; // FIXME: double copy Evoral::Event ev(*i, true); @@ -105,7 +108,7 @@ MidiStretch::run (boost::shared_ptr r, Progress*) new_model->append(ev, Evoral::next_event_id()); } - new_model->end_write (Evoral::Sequence::DeleteStuckNotes); + new_model->end_write (Evoral::Sequence::DeleteStuckNotes); new_model->set_edited (true); new_src->copy_interpolation_from (src);