summaryrefslogtreecommitdiff
path: root/libs/ardour/quantize.cc
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2013-12-03 11:51:25 -0500
committerPaul Davis <paul@linuxaudiosystems.com>2013-12-03 11:51:25 -0500
commit8648a8a13b04549362f14a0738947d997ef1abc7 (patch)
tree702652b49789b13d647c4c93df985f65361a4118 /libs/ardour/quantize.cc
parentc428ec14b923928690492cab0428f8fad45f7658 (diff)
parentae6b0b9f1ab02ab949eaf741b98e69bdab487e92 (diff)
fix up wscript/build issues in exportvis after merge with master
Diffstat (limited to 'libs/ardour/quantize.cc')
-rw-r--r--libs/ardour/quantize.cc11
1 files changed, 8 insertions, 3 deletions
diff --git a/libs/ardour/quantize.cc b/libs/ardour/quantize.cc
index a4543d773c..7da1edaaa1 100644
--- a/libs/ardour/quantize.cc
+++ b/libs/ardour/quantize.cc
@@ -62,7 +62,7 @@ Quantize::operator () (boost::shared_ptr<MidiModel> model,
to quantize relative to actual session beats (etc.) rather than from the
start of the model.
*/
- const double round_pos = ceil(position / _start_grid) * _start_grid;
+ const double round_pos = round(position / _start_grid) * _start_grid;
const double offset = round_pos - position;
bool even;
@@ -72,10 +72,13 @@ Quantize::operator () (boost::shared_ptr<MidiModel> model,
even = false;
+ /* TODO 'swing' probably requires a 2nd iteration:
+ * first quantize notes to the grid, then apply beat shift
+ */
for (Evoral::Sequence<MidiModel::TimeType>::Notes::iterator i = (*s).begin(); i != (*s).end(); ++i) {
- double new_start = round ((*i)->time() / _start_grid) * _start_grid + offset;
- double new_end = round ((*i)->end_time() / _end_grid) * _end_grid + offset;
+ double new_start = round (((*i)->time() - offset) / _start_grid) * _start_grid + offset;
+ double new_end = round (((*i)->end_time() - offset) / _end_grid) * _end_grid + offset;
if (_swing > 0.0 && !even) {
@@ -86,6 +89,7 @@ Quantize::operator () (boost::shared_ptr<MidiModel> model,
*/
new_start = new_start + (2.0/3.0 * _swing * (next_grid - new_start));
+ new_end = new_end + (2.0/3.0 * _swing * (next_grid - new_start));
} else if (_swing < 0.0 && !even) {
@@ -96,6 +100,7 @@ Quantize::operator () (boost::shared_ptr<MidiModel> model,
*/
new_start = new_start - (2.0/3.0 * _swing * (new_start - prev_grid));
+ new_end = new_end - (2.0/3.0 * _swing * (new_start - prev_grid));
}