first compiling, mostly working version of group controls changes
[ardour.git] / libs / ardour / ardour / beats_frames_converter.h
index b1e44adbef15f0204fa31b4a14e5314c79d82078..908dd1909e153b1086bf27edd7c49795f6082fe6 100644 (file)
@@ -1,6 +1,6 @@
 /*
     Copyright (C) 2009 Paul Davis
-    Author: Dave Robillard
+    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
@@ -20,6 +20,9 @@
 */
 
 #include "evoral/TimeConverter.hpp"
+#include "evoral/types.hpp"
+
+#include "ardour/libardour_visibility.h"
 #include "ardour/types.h"
 
 #ifndef __ardour_beats_frames_converter_h__
@@ -29,18 +32,42 @@ namespace ARDOUR {
 
 class TempoMap;
 
-class BeatsFramesConverter : public Evoral::TimeConverter<double,sframes_t> {
+/** Converter between beats and frames.  Takes distances in beats or frames
+ *  from some origin (supplied to the constructor in frames), and converts
+ *  them to the opposite unit, taking tempo changes into account.
+ */
+class LIBARDOUR_API BeatsFramesConverter
+       : public Evoral::TimeConverter<Evoral::Beats,framepos_t> {
+public:
+       BeatsFramesConverter (TempoMap& tempo_map, framepos_t origin)
+               : Evoral::TimeConverter<Evoral::Beats, framepos_t> (origin)
+               , _tempo_map(tempo_map)
+       {}
+
+       framepos_t    to (Evoral::Beats beats) const;
+       Evoral::Beats from (framepos_t frames) const;
+
+private:
+       TempoMap& _tempo_map;
+};
+
+/** Converter between beats and frames.  Takes distances in beats or frames
+ *  from some origin (supplied to the constructor in frames), and converts
+ *  them to the opposite unit, taking tempo changes into account.
+ */
+class LIBARDOUR_API DoubleBeatsFramesConverter
+       : public Evoral::TimeConverter<double,framepos_t> {
 public:
-       BeatsFramesConverter(const TempoMap& tempo_map, sframes_t origin)
-               : Evoral::TimeConverter<double, sframes_t> (origin)
+       DoubleBeatsFramesConverter (TempoMap& tempo_map, framepos_t origin)
+               : Evoral::TimeConverter<double, framepos_t> (origin)
                , _tempo_map(tempo_map)
        {}
 
-       sframes_t to(double beats)       const;
-       double    from(sframes_t frames) const;
+       framepos_t          to (double beats) const;
+       double from (framepos_t frames) const;
 
 private:
-       const TempoMap& _tempo_map;
+       TempoMap& _tempo_map;
 };
 
 } /* namespace ARDOUR */