fix BeatFramesConverter so that it at least works even if its not optimally named...
[ardour.git] / libs / ardour / beats_frames_converter.cc
index 180b3e563a22ea82be76fe8411e5f8623462c2b0..69610aecd3a550af1fee2f85ca0e754da4728e83 100644 (file)
 namespace ARDOUR {
 
 framecnt_t
-BeatsFramesConverter::to(double beats) const
+BeatsFramesConverter::to (double beats) const
 {
-       // FIXME: assumes tempo never changes after origin
-       const Tempo& tempo = _tempo_map.tempo_at (_origin_b);
-       const double frames_per_beat = tempo.frames_per_beat(
-                       _tempo_map.frame_rate(),
-                       _tempo_map.meter_at (_origin_b));
-
-       return llrint (beats * frames_per_beat);
+        return _tempo_map.framepos_plus_bbt (_origin_b, Timecode::BBT_Time(beats)) - _origin_b;
 }
 
 double
 BeatsFramesConverter::from (framecnt_t frames) const
 {
-       // FIXME: assumes tempo never changes after origin
-       const Tempo& tempo = _tempo_map.tempo_at (_origin_b);
-       const double frames_per_beat = tempo.frames_per_beat(
-                       _tempo_map.frame_rate(),
-                       _tempo_map.meter_at (_origin_b));
-
-       return frames / frames_per_beat;
+        return _tempo_map.framewalk_to_beats (_origin_b, frames);
 }
 
 } /* namespace ARDOUR */