mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-16 19:56:31 +01:00
Quantize notes to session tempo time, not relative to start of region (fix issue #4069).
git-svn-id: svn://localhost/ardour2/branches/3.0@9640 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
a0d09e81d4
commit
fd33fa896f
4 changed files with 23 additions and 8 deletions
|
|
@ -4331,7 +4331,10 @@ Editor::apply_midi_note_edit_op_to_region (MidiOperator& op, MidiRegionView& mrv
|
||||||
vector<Evoral::Sequence<Evoral::MusicalTime>::Notes> v;
|
vector<Evoral::Sequence<Evoral::MusicalTime>::Notes> v;
|
||||||
v.push_back (selected);
|
v.push_back (selected);
|
||||||
|
|
||||||
return op (mrv.midi_region()->model(), v);
|
framepos_t pos_frames = mrv.midi_region()->position();
|
||||||
|
double pos_beats = _session->tempo_map().framewalk_to_beats(0, pos_frames);
|
||||||
|
|
||||||
|
return op (mrv.midi_region()->model(), pos_beats, v);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,9 @@ class MidiOperator {
|
||||||
MidiOperator () {}
|
MidiOperator () {}
|
||||||
virtual ~MidiOperator() {}
|
virtual ~MidiOperator() {}
|
||||||
|
|
||||||
virtual Command* operator() (boost::shared_ptr<ARDOUR::MidiModel>, std::vector<Evoral::Sequence<Evoral::MusicalTime>::Notes>&) = 0;
|
virtual Command* operator() (boost::shared_ptr<ARDOUR::MidiModel>,
|
||||||
|
double,
|
||||||
|
std::vector<Evoral::Sequence<Evoral::MusicalTime>::Notes>&) = 0;
|
||||||
virtual std::string name() const = 0;
|
virtual std::string name() const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,9 @@ public:
|
||||||
float strength, float swing, float threshold);
|
float strength, float swing, float threshold);
|
||||||
~Quantize ();
|
~Quantize ();
|
||||||
|
|
||||||
Command* operator() (boost::shared_ptr<ARDOUR::MidiModel>, std::vector<Evoral::Sequence<Evoral::MusicalTime>::Notes>&);
|
Command* operator() (boost::shared_ptr<ARDOUR::MidiModel>,
|
||||||
|
double position,
|
||||||
|
std::vector<Evoral::Sequence<Evoral::MusicalTime>::Notes>&);
|
||||||
std::string name() const { return std::string ("quantize"); }
|
std::string name() const { return std::string ("quantize"); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
||||||
|
|
@ -60,8 +60,17 @@ Quantize::~Quantize ()
|
||||||
}
|
}
|
||||||
|
|
||||||
Command*
|
Command*
|
||||||
Quantize::operator () (boost::shared_ptr<MidiModel> model, std::vector<Evoral::Sequence<Evoral::MusicalTime>::Notes>& seqs)
|
Quantize::operator () (boost::shared_ptr<MidiModel> model,
|
||||||
|
double position,
|
||||||
|
std::vector<Evoral::Sequence<Evoral::MusicalTime>::Notes>& seqs)
|
||||||
{
|
{
|
||||||
|
/* 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.
|
||||||
|
*/
|
||||||
|
const double round_pos = ceil(position / _start_grid) * _start_grid;
|
||||||
|
const double offset = round_pos - position;
|
||||||
|
|
||||||
bool even;
|
bool even;
|
||||||
MidiModel::NoteDiffCommand* cmd = new MidiModel::NoteDiffCommand (model, "quantize");
|
MidiModel::NoteDiffCommand* cmd = new MidiModel::NoteDiffCommand (model, "quantize");
|
||||||
|
|
||||||
|
|
@ -71,9 +80,8 @@ Quantize::operator () (boost::shared_ptr<MidiModel> model, std::vector<Evoral::S
|
||||||
|
|
||||||
for (Evoral::Sequence<MidiModel::TimeType>::Notes::iterator i = (*s).begin(); i != (*s).end(); ++i) {
|
for (Evoral::Sequence<MidiModel::TimeType>::Notes::iterator i = (*s).begin(); i != (*s).end(); ++i) {
|
||||||
|
|
||||||
double new_start = round ((*i)->time() / _start_grid) * _start_grid;
|
double new_start = round ((*i)->time() / _start_grid) * _start_grid + offset;
|
||||||
double new_end = round ((*i)->end_time() / _end_grid) * _end_grid;
|
double new_end = round ((*i)->end_time() / _end_grid) * _end_grid + offset;
|
||||||
double delta;
|
|
||||||
|
|
||||||
if (_swing > 0.0 && !even) {
|
if (_swing > 0.0 && !even) {
|
||||||
|
|
||||||
|
|
@ -97,7 +105,7 @@ Quantize::operator () (boost::shared_ptr<MidiModel> model, std::vector<Evoral::S
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
delta = new_start - (*i)->time();
|
double delta = new_start - (*i)->time();
|
||||||
|
|
||||||
if (fabs (delta) >= _threshold) {
|
if (fabs (delta) >= _threshold) {
|
||||||
if (_snap_start) {
|
if (_snap_start) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue