/*
- 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 "evoral/Beats.hpp"
#include "evoral/TimeConverter.hpp"
+
+#include "ardour/libardour_visibility.h"
#include "ardour/types.h"
#ifndef __ardour_beats_frames_converter_h__
namespace ARDOUR {
-class Session;
+class TempoMap;
+
+/** 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;
+};
-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 DoubleBeatsFramesConverter
+ : public Evoral::TimeConverter<double,framepos_t> {
public:
- BeatsFramesConverter(Session& session, sframes_t origin)
- : _session(session)
- , _origin(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;
- sframes_t origin() const { return _origin; }
- void set_origin(sframes_t origin) { _origin = origin; }
+ framepos_t to (double beats) const;
+ double from (framepos_t frames) const;
private:
- Session& _session;
- sframes_t _origin;
+ TempoMap& _tempo_map;
};
} /* namespace ARDOUR */