summaryrefslogtreecommitdiff
path: root/libs/ardour/ardour/beats_frames_converter.h
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2014-11-22 04:05:42 -0500
committerDavid Robillard <d@drobilla.net>2014-11-22 04:05:42 -0500
commitc1cfa12d6e5136d2e3e5501e83ff74c5009a9e60 (patch)
tree56d2811bc8b9d6f2a5accfa8e497ddd5976c7c7a /libs/ardour/ardour/beats_frames_converter.h
parentcae74309a583c29dd6cc2081425c2e7b673ea13e (diff)
Wrap MusicalTime in a class.
This lets us get a more explicit handle on time conversions, and is the main step towards using actual beat:tick time and getting away from floating point precision problems.
Diffstat (limited to 'libs/ardour/ardour/beats_frames_converter.h')
-rw-r--r--libs/ardour/ardour/beats_frames_converter.h28
1 files changed, 25 insertions, 3 deletions
diff --git a/libs/ardour/ardour/beats_frames_converter.h b/libs/ardour/ardour/beats_frames_converter.h
index 2e170d278a..ada09b1179 100644
--- a/libs/ardour/ardour/beats_frames_converter.h
+++ b/libs/ardour/ardour/beats_frames_converter.h
@@ -20,6 +20,8 @@
*/
#include "evoral/TimeConverter.hpp"
+#include "evoral/types.hpp"
+
#include "ardour/libardour_visibility.h"
#include "ardour/types.h"
@@ -34,15 +36,35 @@ class TempoMap;
* 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<double,framepos_t> {
+class LIBARDOUR_API BeatsFramesConverter
+ : public Evoral::TimeConverter<Evoral::MusicalTime,framepos_t> {
public:
BeatsFramesConverter (TempoMap& tempo_map, framepos_t origin)
+ : Evoral::TimeConverter<Evoral::MusicalTime, framepos_t> (origin)
+ , _tempo_map(tempo_map)
+ {}
+
+ framepos_t to (Evoral::MusicalTime beats) const;
+ Evoral::MusicalTime 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:
+ DoubleBeatsFramesConverter (TempoMap& tempo_map, framepos_t origin)
: Evoral::TimeConverter<double, framepos_t> (origin)
, _tempo_map(tempo_map)
{}
- framepos_t to (double beats) const;
- double from (framepos_t frames) const;
+ framepos_t to (double beats) const;
+ double from (framepos_t frames) const;
private:
TempoMap& _tempo_map;