Tempo ramps - clean up TempoSection, fix thinko in position function.
authornick_m <mainsbridge@gmail.com>
Mon, 28 Dec 2015 14:46:34 +0000 (01:46 +1100)
committernick_m <mainsbridge@gmail.com>
Fri, 27 May 2016 13:38:10 +0000 (23:38 +1000)
libs/ardour/ardour/tempo.h
libs/ardour/tempo.cc

index 341198f1fe6d8ea4d2c7380516f4e85b54c68b67..c5cb66522325dc53867578206787ab22c88dfd2b 100644 (file)
@@ -105,9 +105,9 @@ class LIBARDOUR_API MetricSection {
                : _beat (0), _frame (frame), _movable (true), _position_lock_style (MusicTime) {}
 
        virtual ~MetricSection() {}
-       const double start () const { return _beat; }
 
-       const double& beat() const { return _beat; }
+       const double start () const { return _beat; }
+       const double& beat () const { return _beat; }
        void set_beat (double beat) { _beat = beat;}
 
        framepos_t frame() const { return _frame; }
@@ -123,6 +123,7 @@ class LIBARDOUR_API MetricSection {
           XML state information.
        */
        virtual XMLNode& get_state() const = 0;
+
        PositionLockStyle position_lock_style () const { return _position_lock_style; }
        void set_position_lock_style (PositionLockStyle ps) { _position_lock_style = ps; }
 
@@ -205,10 +206,8 @@ class LIBARDOUR_API TempoSection : public MetricSection, public Tempo {
         *  time relative to section start.
         */
        double c_func (double end_tpm, double end_time) const;
-       double a_func (double begin_tpm, double end_tpm, double end_time) const;
+       double a_func (double end_tpm, double c_func) const;
 
-       double tempo_at_time (double time, double end_bpm, double end_time) const;
-       double time_at_tempo (double tempo, double end_bpm, double end_time) const;
        double tick_tempo_at_time (double time, double end_tpm, double end_time) const;
        double time_at_tick_tempo (double tick_tempo, double end_tpm, double end_time) const;
 
index 5dcbf3761cb5e40e877bded222d92c4cf5e03ab0..6112fb7c545376405d645bb97948a968d1dba2e8 100644 (file)
@@ -182,6 +182,8 @@ TempoSection::set_type (Type type)
        _type = type;
 }
 
+/** returns the tempo at the zero-based (relative to tempo section) frame.
+*/
 double
 TempoSection::tempo_at_frame (framepos_t frame, double end_bpm, framepos_t end_frame, framecnt_t frame_rate) const
 {
@@ -193,6 +195,9 @@ TempoSection::tempo_at_frame (framepos_t frame, double end_bpm, framepos_t end_f
        return tick_tempo_at_time (frame_to_minute (frame, frame_rate), end_bpm *  BBT_Time::ticks_per_beat, frame_to_minute (end_frame, frame_rate)) / BBT_Time::ticks_per_beat;
 }
 
+/** returns the zero-based frame (relative to tempo section)
+   where the tempo occurs.
+*/
 framepos_t
 TempoSection::frame_at_tempo (double tempo, double end_bpm, framepos_t end_frame, framecnt_t frame_rate) const
 {
@@ -203,6 +208,10 @@ TempoSection::frame_at_tempo (double tempo, double end_bpm, framepos_t end_frame
        return minute_to_frame (time_at_tick_tempo (tempo *  BBT_Time::ticks_per_beat,  end_bpm *  BBT_Time::ticks_per_beat, frame_to_minute (end_frame, frame_rate)), frame_rate);
 }
 
+/** returns the zero-based tick (relative to tempo section)
+   where the zero-based frame (relative to tempo section)
+   lies.
+*/
 double
 TempoSection::tick_at_frame (framepos_t frame, double end_bpm, framepos_t end_frame, framecnt_t frame_rate) const
 {
@@ -213,6 +222,10 @@ TempoSection::tick_at_frame (framepos_t frame, double end_bpm, framepos_t end_fr
        return tick_at_time (frame_to_minute (frame, frame_rate), end_bpm *  BBT_Time::ticks_per_beat, frame_to_minute (end_frame, frame_rate));
 }
 
+/** returns the zero-based frame (relative to tempo section)
+   where the zero-based tick (relative to tempo section)
+   falls.
+*/
 framepos_t
 TempoSection::frame_at_tick (double tick, double end_bpm, framepos_t end_frame, framecnt_t frame_rate) const
 {
@@ -223,12 +236,23 @@ TempoSection::frame_at_tick (double tick, double end_bpm, framepos_t end_frame,
        return minute_to_frame (time_at_tick (tick, end_bpm *  BBT_Time::ticks_per_beat, frame_to_minute (end_frame, frame_rate)), frame_rate);
 }
 
-double TempoSection::beat_at_frame (framepos_t frame, double end_bpm, framepos_t end_frame, framecnt_t frame_rate) const
+/** returns the zero-based beat (relative to tempo section)
+   where the zero-based frame (relative to tempo section)
+   lies.
+*/
+double
+TempoSection::beat_at_frame (framepos_t frame, double end_bpm, framepos_t end_frame, framecnt_t frame_rate) const
 {
        return tick_at_frame (frame, end_bpm, end_frame, frame_rate) / BBT_Time::ticks_per_beat;
 }
 
-framepos_t TempoSection::frame_at_beat (double beat, double end_bpm, framepos_t end_frame, framecnt_t frame_rate) const
+/** returns the zero-based frame (relative to tempo section start frame)
+   where the zero-based beat (relative to tempo section start)
+   falls.
+*/
+
+framepos_t
+TempoSection::frame_at_beat (double beat, double end_bpm, framepos_t end_frame, framecnt_t frame_rate) const
 {
        return frame_at_tick (beat * BBT_Time::ticks_per_beat, end_bpm, end_frame, frame_rate);
 }
@@ -245,12 +269,14 @@ TempoSection::frame_to_minute (framecnt_t frame, framecnt_t frame_rate) const
        return (frame / (double) frame_rate) / 60.0;
 }
 
-/* constant for exp */
+/* position function */
 double
-TempoSection::a_func (double begin_tpm, double end_tpm, double end_time) const
+TempoSection::a_func (double end_tpm, double c_func) const
 {
-       return log (end_tpm / ticks_per_minute()) /  c_func (end_tpm, end_time);
+       return log (end_tpm / ticks_per_minute()) /  c_func;
 }
+
+/*function constant*/
 double
 TempoSection::c_func (double end_tpm, double end_time) const
 {
@@ -271,20 +297,6 @@ TempoSection::time_at_tick_tempo (double tick_tempo, double end_tpm, double end_
        return log (tick_tempo / ticks_per_minute()) / c_func (end_tpm, end_time);
 }
 
-/* tempo in bpm at time in minutes */
-double
-TempoSection::tempo_at_time (double time, double end_bpm, double end_time) const
-{
-       return tick_tempo_at_time (time, end_bpm *  BBT_Time::ticks_per_beat, end_time) / BBT_Time::ticks_per_beat;
-}
-
-/* time in minutes at tempo in bpm */
-double
-TempoSection::time_at_tempo (double tempo, double end_bpm, double end_time) const
-{
-       return time_at_tick_tempo (tempo * BBT_Time::ticks_per_beat, end_bpm * BBT_Time::ticks_per_beat, end_time);
-}
-
 /* tick at time in minutes */
 double
 TempoSection::tick_at_time (double time, double end_tpm, double end_time) const