X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fardour%2Fmidi_stretch.cc;h=38cab08acec8bfdd1edb1c7a5537f5a170826c68;hb=848db8fbd56dbae1ad286b7791dba293462b5f43;hp=4dfab65fd44bdf802790302d5d14d7c951178125;hpb=a5efa9a500d2c1b592656e91e9ea7ef7d535dcb3;p=ardour.git diff --git a/libs/ardour/midi_stretch.cc b/libs/ardour/midi_stretch.cc index 4dfab65fd4..38cab08ace 100644 --- a/libs/ardour/midi_stretch.cc +++ b/libs/ardour/midi_stretch.cc @@ -20,10 +20,11 @@ #include "pbd/error.h" -#include "ardour/types.h" -#include "ardour/midi_stretch.h" -#include "ardour/session.h" +#include "ardour/midi_model.h" #include "ardour/midi_region.h" +#include "ardour/midi_source.h" +#include "ardour/midi_stretch.h" +#include "ardour/types.h" #include "i18n.h" @@ -31,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) { @@ -42,14 +43,15 @@ MidiStretch::~MidiStretch () } int -MidiStretch::run (boost::shared_ptr r, Progress* progress) +MidiStretch::run (boost::shared_ptr r, Progress*) { SourceList nsrcs; 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. @@ -73,18 +75,18 @@ MidiStretch::run (boost::shared_ptr r, Progress* 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(); 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); boost::shared_ptr new_model = new_src->model(); @@ -99,11 +101,11 @@ MidiStretch::run (boost::shared_ptr r, Progress* progress) // FIXME: double copy Evoral::Event ev(*i, true); - ev.time() = new_time; + ev.set_time(new_time); new_model->append(ev, Evoral::next_event_id()); } - new_model->end_write (); + new_model->end_write (Evoral::Sequence::DeleteStuckNotes); new_model->set_edited (true); new_src->copy_interpolation_from (src);