From 9b086e18b501751e44df2f5ee3c8deea31370ce6 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Wed, 23 Oct 2013 02:12:50 +0200 Subject: fix midi quantization - part two include position offset in rounding --- libs/ardour/quantize.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'libs/ardour/quantize.cc') diff --git a/libs/ardour/quantize.cc b/libs/ardour/quantize.cc index a4543d773c..1caefe87a6 100644 --- a/libs/ardour/quantize.cc +++ b/libs/ardour/quantize.cc @@ -62,7 +62,7 @@ Quantize::operator () (boost::shared_ptr 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; @@ -74,8 +74,8 @@ Quantize::operator () (boost::shared_ptr model, for (Evoral::Sequence::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) { -- cgit v1.2.3 From 20c20b7ddfbbc5bf9888f39f41d6c243534cc94f Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Wed, 23 Oct 2013 17:40:35 +0200 Subject: Fix midi-note length when quantizing a swing rhythm Note: 'swing' probably requires a 2nd iteration: first quantize notes to the grid, then apply beat shift. --- libs/ardour/quantize.cc | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'libs/ardour/quantize.cc') diff --git a/libs/ardour/quantize.cc b/libs/ardour/quantize.cc index 1caefe87a6..7da1edaaa1 100644 --- a/libs/ardour/quantize.cc +++ b/libs/ardour/quantize.cc @@ -72,6 +72,9 @@ Quantize::operator () (boost::shared_ptr model, even = false; + /* TODO 'swing' probably requires a 2nd iteration: + * first quantize notes to the grid, then apply beat shift + */ for (Evoral::Sequence::Notes::iterator i = (*s).begin(); i != (*s).end(); ++i) { double new_start = round (((*i)->time() - offset) / _start_grid) * _start_grid + offset; @@ -86,6 +89,7 @@ Quantize::operator () (boost::shared_ptr 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 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)); } -- cgit v1.2.3