From 539c8361de35364effe804e2db184790226b340a Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Mon, 7 Sep 2009 16:53:53 +0000 Subject: use diff commands for quantize, with infrastructure changes as required git-svn-id: svn://localhost/ardour2/branches/3.0@5639 d708f5d6-7413-0410-9779-e7cbd77b26cf --- libs/ardour/quantize.cc | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'libs/ardour/quantize.cc') diff --git a/libs/ardour/quantize.cc b/libs/ardour/quantize.cc index becb3bd491..7aedb98a4d 100644 --- a/libs/ardour/quantize.cc +++ b/libs/ardour/quantize.cc @@ -24,12 +24,14 @@ #include "ardour/quantize.h" #include "ardour/session.h" #include "ardour/smf_source.h" +#include "ardour/midi_model.h" #include "ardour/midi_region.h" #include "ardour/tempo.h" #include "i18n.h" using namespace std; +using namespace PBD; using namespace ARDOUR; /** Quantize notes @@ -57,18 +59,17 @@ Quantize::~Quantize () { } -int -Quantize::operator () (std::vector::Notes>& seqs) +Command* +Quantize::operator () (boost::shared_ptr model, std::vector::Notes>& seqs) { bool even; + MidiModel::DiffCommand* cmd = new MidiModel::DiffCommand (model, "quantize"); - for (std::vector::Notes>::iterator s = seqs.begin(); - s != seqs.end(); ++s) { + for (std::vector::Notes>::iterator s = seqs.begin(); s != seqs.end(); ++s) { even = false; - for (Evoral::Sequence::Notes::iterator i = (*s).begin(); - i != (*s).end(); ++i) { + for (Evoral::Sequence::Notes::iterator i = (*s).begin(); i != (*s).end(); ++i) { double new_start = round ((*i)->time() / _start_grid) * _start_grid; double new_end = round ((*i)->end_time() / _end_grid) * _end_grid; @@ -101,7 +102,8 @@ Quantize::operator () (std::vector::Notes> if (fabs (delta) >= _threshold) { if (_snap_start) { delta *= _strength; - (*i)->set_time ((*i)->time() + delta); + cmd->change ((*i), MidiModel::DiffCommand::StartTime, + (*i)->time() + delta); } } @@ -115,7 +117,7 @@ Quantize::operator () (std::vector::Notes> new_dur = _end_grid; } - (*i)->set_length (new_dur); + cmd->change ((*i), MidiModel::DiffCommand::Length, new_dur); } } @@ -123,5 +125,5 @@ Quantize::operator () (std::vector::Notes> } } - return 0; + return cmd; } -- cgit v1.2.3