#include "ardour/quantize.h"
#include "ardour/midi_model.h"
-#include "i18n.h"
+#include "pbd/i18n.h"
using namespace std;
using namespace PBD;
* if the start grid is 1.0, the beat at 0 isn't swung,
* but the beat at 1.0 is. the beat at 2.0 isn't swung,
* but the beat at 3.0 is. and so on.
- *
+ *
* so the criterion for a position being swung is
* whether or not ((possible_grid_position / grid) % 2) != 0
*/
/* now correct for start-of-model offset */
pos += offset;
-
+
if (fabs (pos - swung_pos) > fabs (pos - swung_previous_grid_position)) {
pos = swung_previous_grid_position;
} else {
Command*
Quantize::operator () (boost::shared_ptr<MidiModel> model,
- Evoral::Beats position,
- std::vector<Evoral::Sequence<Evoral::Beats>::Notes>& seqs)
+ Temporal::Beats position,
+ std::vector<Evoral::Sequence<Temporal::Beats>::Notes>& seqs)
{
/* TODO: Rewrite this to be precise with fixed point? */
MidiModel::NoteDiffCommand* cmd = new MidiModel::NoteDiffCommand (model, "quantize");
- for (std::vector<Evoral::Sequence<Evoral::Beats>::Notes>::iterator s = seqs.begin(); s != seqs.end(); ++s) {
+ for (std::vector<Evoral::Sequence<Temporal::Beats>::Notes>::iterator s = seqs.begin(); s != seqs.end(); ++s) {
for (Evoral::Sequence<MidiModel::TimeType>::Notes::iterator i = (*s).begin(); i != (*s).end(); ++i) {
/* compute new start + end points WITHOUT the offset
* caused by the start of the model (see above).
- *
+ *
* these versions of new_start and new_end are
* guaranteed to precisely align with the quantize grid(s).
*/
-
+
double new_start = round (((*i)->time().to_double() - offset) / _start_grid) * _start_grid;
double new_end = round (((*i)->end_time().to_double() - offset) / _end_grid) * _end_grid;
new_start = swing_position (new_start, _start_grid, _swing, offset);
new_end = swing_position (new_end, _end_grid, _swing, offset);
-
+
} else {
/* now correct for start-of-model offset */
new_start += offset;
new_end += offset;
}
-
+
double delta = new_start - (*i)->time().to_double();
-
+
if (fabs (delta) >= _threshold) {
if (_snap_start) {
delta *= _strength;
delta = new_end - (*i)->end_time().to_double();
if (fabs (delta) >= _threshold) {
- Evoral::Beats new_dur(new_end - new_start);
+ Temporal::Beats new_dur(new_end - new_start);
if (!new_dur) {
- new_dur = Evoral::Beats(_end_grid);
+ new_dur = Temporal::Beats(_end_grid);
}
cmd->change ((*i), MidiModel::NoteDiffCommand::Length, new_dur);