Missing file.
[ardour.git] / libs / ardour / beats_frames_converter.cc
index f3d4840f3478cf31bc8916d0deccf0f0d24b8d66..a960f1a221b34b654a78cb392e3575ab3dee4b77 100644 (file)
@@ -1,6 +1,6 @@
 /*
-    Copyright (C) 2009 Paul Davis 
-    Author: Dave Robillard
+    Copyright (C) 2009 Paul Davis
+    Author: David Robillard
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
     $Id: midiregion.h 733 2006-08-01 17:19:38Z drobilla $
 */
 
-#include "ardour/audioengine.h"
 #include "ardour/beats_frames_converter.h"
-#include "ardour/session.h"
 #include "ardour/tempo.h"
 
 namespace ARDOUR {
 
-sframes_t
-BeatsFramesConverter::to(double beats) const
+framecnt_t
+BeatsFramesConverter::to (double beats) const
 {
-       // FIXME: assumes tempo never changes after origin
-       const Tempo& tempo = _session.tempo_map().tempo_at(_origin);
-       const double frames_per_beat = tempo.frames_per_beat(
-                       _session.engine().frame_rate(),
-                       _session.tempo_map().meter_at(_origin));
-
-       return lrint(beats * frames_per_beat);
+       assert (beats >= 0);
+       
+       return _tempo_map.framepos_plus_bbt (_origin_b, Timecode::BBT_Time(beats)) - _origin_b;
 }
 
 double
-BeatsFramesConverter::from(sframes_t frames) const
+BeatsFramesConverter::from (framecnt_t frames) const
 {
-       // FIXME: assumes tempo never changes after origin
-       const Tempo& tempo = _session.tempo_map().tempo_at(_origin);
-       const double frames_per_beat = tempo.frames_per_beat(
-                       _session.engine().frame_rate(),
-                       _session.tempo_map().meter_at(_origin));
-
-       return frames / frames_per_beat;
+       return _tempo_map.framewalk_to_beats (_origin_b, frames);
 }
 
 } /* namespace ARDOUR */