fix midi quantization - part two
authorRobin Gareus <robin@gareus.org>
Wed, 23 Oct 2013 00:12:50 +0000 (02:12 +0200)
committerRobin Gareus <robin@gareus.org>
Wed, 23 Oct 2013 00:12:50 +0000 (02:12 +0200)
include position offset in rounding

libs/ardour/quantize.cc

index a4543d773c75dd035fb3059171673561e837cb75..1caefe87a69156574991f60febdcbfd746773f7d 100644 (file)
@@ -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;
@@ -74,8 +74,8 @@ Quantize::operator () (boost::shared_ptr<MidiModel> model,
 
                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) {