diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2008-10-20 19:44:43 +0000 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2008-10-20 19:44:43 +0000 |
commit | a02c4dadf19a4c131f86b3c7d66eccbeb63716e0 (patch) | |
tree | d6397040beb43d7e23a216da49234688720b636d /libs | |
parent | 80b6af8b6b82522ec9c86a66477dcdf460fa517e (diff) |
fix up some jerkiness/retrograde motion of playhead
git-svn-id: svn://localhost/ardour2/branches/2.0-ongoing@3988 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs')
-rw-r--r-- | libs/ardour/ardour/session.h | 5 | ||||
-rw-r--r-- | libs/ardour/session.cc | 38 | ||||
-rw-r--r-- | libs/ardour/session_state.cc | 2 |
3 files changed, 42 insertions, 3 deletions
diff --git a/libs/ardour/ardour/session.h b/libs/ardour/ardour/session.h index 38ed0a5b89..35b8c5489d 100644 --- a/libs/ardour/ardour/session.h +++ b/libs/ardour/ardour/session.h @@ -1752,6 +1752,11 @@ class Session : public PBD::StatefulDestructible void set_history_depth (uint32_t depth); static bool _disable_all_loaded_plugins; + + /* used in ::audible_frame() */ + + mutable float af_last_transport_speed; + mutable nframes64_t af_last_frame; }; } // namespace ARDOUR diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc index 4d3cd7b606..0a58a7da25 100644 --- a/libs/ardour/session.cc +++ b/libs/ardour/session.cc @@ -1408,11 +1408,13 @@ Session::audible_frame () const } if (_transport_speed == 0) { - return tf; + ret = tf; + goto block_retrograde; } if (tf < offset) { - return 0; + ret = 0; + goto block_retrograde; } ret = tf; @@ -1423,9 +1425,39 @@ Session::audible_frame () const /* take latency into account */ - ret -= offset; + if (_transport_speed > 0.0) { + /* forwards */ + ret -= offset; + } else { + /* backwards */ + ret += offset; + } + } + /* do not allow retrograde motion near startup or a direction change + caused by latency correction. we detect this by the asking if the present + and previously-noted transport speed (and thus direction) are the same. + */ + + block_retrograde: + if ((af_last_transport_speed >= 0.0) == (_transport_speed >= 0.0)) { + + if (_transport_speed > 0.0) { + if (ret < af_last_frame) { + ret = af_last_frame; + } + + } else if (_transport_speed < 0.0) { + if (ret > af_last_frame) { + ret = af_last_frame; + } + } + } + + af_last_frame = ret; + af_last_transport_speed = _transport_speed; + return ret; } diff --git a/libs/ardour/session_state.cc b/libs/ardour/session_state.cc index e1ed93918a..469914c971 100644 --- a/libs/ardour/session_state.cc +++ b/libs/ardour/session_state.cc @@ -228,6 +228,8 @@ Session::first_stage_init (string fullpath, string snapshot_name) _smpte_offset = 0; _smpte_offset_negative = true; last_smpte_valid = false; + af_last_transport_speed = 0.0; + af_last_frame = 0.0; sync_time_vars (); |