diff options
author | David Robillard <d@drobilla.net> | 2014-11-22 04:05:42 -0500 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2014-11-22 04:05:42 -0500 |
commit | c1cfa12d6e5136d2e3e5501e83ff74c5009a9e60 (patch) | |
tree | 56d2811bc8b9d6f2a5accfa8e497ddd5976c7c7a /libs/ardour/quantize.cc | |
parent | cae74309a583c29dd6cc2081425c2e7b673ea13e (diff) |
Wrap MusicalTime in a class.
This lets us get a more explicit handle on time conversions, and is the main
step towards using actual beat:tick time and getting away from floating point
precision problems.
Diffstat (limited to 'libs/ardour/quantize.cc')
-rw-r--r-- | libs/ardour/quantize.cc | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/libs/ardour/quantize.cc b/libs/ardour/quantize.cc index 7da1edaaa1..13b1cf3b36 100644 --- a/libs/ardour/quantize.cc +++ b/libs/ardour/quantize.cc @@ -58,6 +58,8 @@ Quantize::operator () (boost::shared_ptr<MidiModel> model, double position, std::vector<Evoral::Sequence<Evoral::MusicalTime>::Notes>& seqs) { + /* TODO: Rewrite this to be precise with fixed point? */ + /* Calculate offset from start of model to next closest quantize step, to quantize relative to actual session beats (etc.) rather than from the start of the model. @@ -77,8 +79,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() - offset) / _start_grid) * _start_grid + offset; - double new_end = round (((*i)->end_time() - offset) / _end_grid) * _end_grid + offset; + double new_start = round (((*i)->time().to_double() - offset) / _start_grid) * _start_grid + offset; + double new_end = round (((*i)->end_time().to_double() - offset) / _end_grid) * _end_grid + offset; if (_swing > 0.0 && !even) { @@ -104,18 +106,18 @@ Quantize::operator () (boost::shared_ptr<MidiModel> model, } - double delta = new_start - (*i)->time(); + double delta = new_start - (*i)->time().to_double(); if (fabs (delta) >= _threshold) { if (_snap_start) { delta *= _strength; cmd->change ((*i), MidiModel::NoteDiffCommand::StartTime, - (*i)->time() + delta); + (*i)->time().to_double() + delta); } } if (_snap_end) { - delta = new_end - (*i)->end_time(); + delta = new_end - (*i)->end_time().to_double(); if (fabs (delta) >= _threshold) { double new_dur = new_end - new_start; |