X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fardour%2Fardour%2Fbeats_frames_converter.h;h=4b7169bfe7edc7b5cbe36300d49696e80e0d079b;hb=e9a8ccc7e2826d8fe91eff34ee8a0683a7f7aac6;hp=79972cb4c50a8522433b1b354bc261cab83ce0e3;hpb=3963d2b0b224e79fdf8e852e39fc3a765fa1431b;p=ardour.git diff --git a/libs/ardour/ardour/beats_frames_converter.h b/libs/ardour/ardour/beats_frames_converter.h index 79972cb4c5..4b7169bfe7 100644 --- a/libs/ardour/ardour/beats_frames_converter.h +++ b/libs/ardour/ardour/beats_frames_converter.h @@ -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 @@ -19,32 +19,55 @@ $Id: midiregion.h 733 2006-08-01 17:19:38Z drobilla $ */ -#include -#include +#include "evoral/Beats.hpp" +#include "evoral/TimeConverter.hpp" + +#include "ardour/libardour_visibility.h" +#include "ardour/types.h" #ifndef __ardour_beats_frames_converter_h__ #define __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 { +public: + BeatsFramesConverter (TempoMap& tempo_map, framepos_t origin) + : Evoral::TimeConverter (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 { +/** 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 { public: - BeatsFramesConverter(Session& session, nframes_t origin) - : _session(session) - , _origin(origin) + DoubleBeatsFramesConverter (TempoMap& tempo_map, framepos_t origin) + : Evoral::TimeConverter (origin) + , _tempo_map(tempo_map) {} - - nframes_t to(double beats) const; - double from(nframes_t frames) const; - nframes_t origin() const { return _origin; } - void set_origin(nframes_t origin) { _origin = origin; } + framepos_t to (double beats) const; + double from (framepos_t frames) const; private: - Session& _session; - nframes_t _origin; + TempoMap& _tempo_map; }; } /* namespace ARDOUR */