summaryrefslogtreecommitdiff
path: root/libs/ardour/quantize.cc
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2009-02-16 02:51:16 +0000
committerDavid Robillard <d@drobilla.net>2009-02-16 02:51:16 +0000
commit3963d2b0b224e79fdf8e852e39fc3a765fa1431b (patch)
tree0c6c8a9d519d46437ffe9cb96f09ca337f33faff /libs/ardour/quantize.cc
parentbeb3eea62bf217d0a7b2a86a96d5c375329df10a (diff)
Move all beats <-> frames time conversion into a single object that can be passed around.
This has 3 main benefits: - All conversion code is in one place (less duplication, potential bugs) - The conversion method can be passed to things that are ignorant of the actual time units involved, information required, etc. (In the future it would be nice to have user selectable tempo/frame time) - It should be relatively simple now to support tempo changes part-way through a MIDI region (at least architecturally speaking) git-svn-id: svn://localhost/ardour2/branches/3.0@4594 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour/quantize.cc')
-rw-r--r--libs/ardour/quantize.cc13
1 files changed, 3 insertions, 10 deletions
diff --git a/libs/ardour/quantize.cc b/libs/ardour/quantize.cc
index e4a2809277..76eb924612 100644
--- a/libs/ardour/quantize.cc
+++ b/libs/ardour/quantize.cc
@@ -62,19 +62,12 @@ Quantize::run (boost::shared_ptr<Region> r)
boost::shared_ptr<MidiModel> model = src->model();
- // FIXME: Model really needs to be switched to beat time (double) ASAP
-
- const Tempo& t = session.tempo_map().tempo_at(r->start());
- const Meter& m = session.tempo_map().meter_at(r->start());
-
- double q_frames = _q * (m.frames_per_bar(t, session.frame_rate()) / (double)m.beats_per_bar());
-
for (Evoral::Sequence<MidiModel::TimeType>::Notes::iterator i = model->notes().begin();
i != model->notes().end(); ++i) {
- const double new_time = lrint((*i)->time() / q_frames) * q_frames;
- double new_dur = lrint((*i)->length() / q_frames) * q_frames;
+ const double new_time = lrint((*i)->time() / _q) * _q;
+ double new_dur = lrint((*i)->length() / _q) * _q;
if (new_dur == 0.0)
- new_dur = q_frames;
+ new_dur = _q;
(*i)->set_time(new_time);
(*i)->set_length(new_dur);