Fix midi-note length when quantizing a swing rhythm
authorRobin Gareus <robin@gareus.org>
Wed, 23 Oct 2013 15:40:35 +0000 (17:40 +0200)
committerRobin Gareus <robin@gareus.org>
Wed, 23 Oct 2013 17:59:26 +0000 (19:59 +0200)
Note: 'swing' probably requires a 2nd iteration:
first quantize notes to the grid, then apply beat shift.

libs/ardour/quantize.cc

index 1caefe87a69156574991f60febdcbfd746773f7d..7da1edaaa18732695a64ab7d678f9e3f5ce917ac 100644 (file)
@@ -72,6 +72,9 @@ 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() - offset) / _start_grid) * _start_grid + offset;
@@ -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));
 
                        }