+ static const int frame_tolerance;
+
+ SafeTime current;
+ framepos_t mtc_frame; /* current time */
+ double mtc_frame_dll;
+ framepos_t last_inbound_frame; /* when we got it; audio clocked */
+ MIDI::byte last_mtc_fps_byte;
+ framepos_t window_begin;
+ framepos_t window_end;
+ framepos_t first_mtc_timestamp;
+ bool did_reset_tc_format;
+ Timecode::TimecodeFormat saved_tc_format;
+ Glib::Threads::Mutex reset_lock;
+ uint32_t reset_pending;
+ bool reset_position;
+ int transport_direction;
+ int busy_guard1;
+ int busy_guard2;
+
+ double speedup_due_to_tc_mismatch;
+ double quarter_frame_duration;
+ Timecode::TimecodeFormat mtc_timecode;
+ Timecode::TimecodeFormat a3e_timecode;
+ Timecode::Time timecode;
+ bool printed_timecode_warning;
+ frameoffset_t current_delta;
+
+ /* DLL - chase MTC */
+ double t0; ///< time at the beginning of the MTC quater frame
+ double t1; ///< calculated end of the MTC quater frame
+ double e2; ///< second order loop error
+ double b, c, omega; ///< DLL filter coefficients
+
+ /* DLL - sync engine */
+ int engine_dll_initstate;
+ double te0; ///< time at the beginning of the engine process
+ double te1; ///< calculated sync time
+ double ee2; ///< second order loop error
+ double be, ce, oe; ///< DLL filter coefficients
+
+ void reset (bool with_pos);
+ void queue_reset (bool with_pos);
+ void maybe_reset ();
+
+ void update_mtc_qtr (MIDI::Parser&, int, framepos_t);
+ void update_mtc_time (const MIDI::byte *, bool, framepos_t);
+ void update_mtc_status (MIDI::MTC_Status);
+ void read_current (SafeTime *) const;
+ void reset_window (framepos_t);
+ bool outside_window (framepos_t) const;
+ void init_mtc_dll(framepos_t, double);
+ void init_engine_dll (framepos_t, framepos_t);
+ void parse_timecode_offset();
+ void parameter_changed(std::string const & p);
+};
+
+class LIBARDOUR_API LTC_Slave : public TimecodeSlave {
+public:
+ LTC_Slave (Session&);
+ ~LTC_Slave ();
+
+ bool speed_and_position (double&, framepos_t&);
+
+ bool locked() const;
+ bool ok() const;
+
+ framecnt_t resolution () const;
+ bool requires_seekahead () const { return false; }
+ framecnt_t seekahead_distance () const { return 0; }
+ bool give_slave_full_control_over_transport_speed() const { return true; }
+
+ Timecode::TimecodeFormat apparent_timecode_format() const;
+ std::string approximate_current_position() const;
+ std::string approximate_current_delta() const;
+
+ private:
+ void parse_ltc(const pframes_t, const Sample* const, const framecnt_t);
+ void process_ltc(framepos_t const);
+ void init_engine_dll (framepos_t, int32_t);
+ bool detect_discontinuity(LTCFrameExt *, int, bool);
+ bool detect_ltc_fps(int, bool);
+ bool equal_ltc_frame_time(LTCFrame *a, LTCFrame *b);
+ void reset();
+ void resync_xrun();
+ void resync_latency();
+ void parse_timecode_offset();
+ void parameter_changed(std::string const & p);
+
+ Session& session;
+ bool did_reset_tc_format;
+ Timecode::TimecodeFormat saved_tc_format;
+
+ LTCDecoder * decoder;
+ double frames_per_ltc_frame;
+ Timecode::Time timecode;
+ LTCFrameExt prev_frame;
+ bool fps_detected;
+
+ framecnt_t monotonic_cnt;
+ framecnt_t last_timestamp;
+ framecnt_t last_ltc_frame;
+ double ltc_speed;
+ frameoffset_t current_delta;
+ int delayedlocked;
+
+ int ltc_detect_fps_cnt;
+ int ltc_detect_fps_max;
+ bool printed_timecode_warning;
+ bool sync_lock_broken;
+ Timecode::TimecodeFormat ltc_timecode;
+ Timecode::TimecodeFormat a3e_timecode;
+
+ PBD::ScopedConnectionList port_connections;
+ PBD::ScopedConnection config_connection;
+ LatencyRange ltc_slave_latency;
+
+ /* DLL - chase LTC */
+ int transport_direction;
+ int engine_dll_initstate;
+ double t0; ///< time at the beginning of the MTC quater frame
+ double t1; ///< calculated end of the MTC quater frame
+ double e2; ///< second order loop error
+ double b, c; ///< DLL filter coefficients
+};
+
+class LIBARDOUR_API MIDIClock_Slave : public Slave {
+ public:
+ MIDIClock_Slave (Session&, MidiPort&, int ppqn = 24);