summaryrefslogtreecommitdiff
path: root/libs/ardour/quantize.cc
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2009-09-07 16:53:53 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2009-09-07 16:53:53 +0000
commit539c8361de35364effe804e2db184790226b340a (patch)
tree279f579faa714c666251b928ded743354f9b4610 /libs/ardour/quantize.cc
parent79dc191d6bcd61a81765ce2563a9c325b97c4ed8 (diff)
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
Diffstat (limited to 'libs/ardour/quantize.cc')
-rw-r--r--libs/ardour/quantize.cc20
1 files changed, 11 insertions, 9 deletions
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<Evoral::Sequence<Evoral::MusicalTime>::Notes>& seqs)
+Command*
+Quantize::operator () (boost::shared_ptr<MidiModel> model, std::vector<Evoral::Sequence<Evoral::MusicalTime>::Notes>& seqs)
{
bool even;
+ MidiModel::DiffCommand* cmd = new MidiModel::DiffCommand (model, "quantize");
- for (std::vector<Evoral::Sequence<Evoral::MusicalTime>::Notes>::iterator s = seqs.begin();
- s != seqs.end(); ++s) {
+ for (std::vector<Evoral::Sequence<Evoral::MusicalTime>::Notes>::iterator s = seqs.begin(); s != seqs.end(); ++s) {
even = false;
- for (Evoral::Sequence<MidiModel::TimeType>::Notes::iterator i = (*s).begin();
- i != (*s).end(); ++i) {
+ for (Evoral::Sequence<MidiModel::TimeType>::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<Evoral::Sequence<Evoral::MusicalTime>::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<Evoral::Sequence<Evoral::MusicalTime>::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<Evoral::Sequence<Evoral::MusicalTime>::Notes>
}
}
- return 0;
+ return cmd;
}