ardour
Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
ARDOUR::MTC_Slave Class Reference

#include <slave.h>

Inheritance diagram for ARDOUR::MTC_Slave:
ARDOUR::TimecodeSlave ARDOUR::Slave

Public Member Functions

 MTC_Slave (Session &, MidiPort &)
 
 ~MTC_Slave ()
 
void rebind (MidiPort &)
 
bool speed_and_position (double &, framepos_t &)
 
bool locked () const
 
bool ok () const
 
void handle_locate (const MIDI::byte *)
 
framecnt_t resolution () const
 
bool requires_seekahead () const
 
framecnt_t seekahead_distance () const
 
bool give_slave_full_control_over_transport_speed () const
 
Timecode::TimecodeFormat apparent_timecode_format () const
 
std::string approximate_current_position () const
 
std::string approximate_current_delta () const
 
- Public Member Functions inherited from ARDOUR::TimecodeSlave
 TimecodeSlave ()
 
- Public Member Functions inherited from ARDOUR::Slave
 Slave ()
 
virtual ~Slave ()
 
virtual bool starting () const
 
virtual bool is_always_synced () const
 

Private Member Functions

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)
 

Private Attributes

Sessionsession
 
MidiPortport
 
PBD::ScopedConnectionList port_connections
 
PBD::ScopedConnection config_connection
 
bool can_notify_on_unknown_rate
 
SafeTime current
 
framepos_t mtc_frame
 
double mtc_frame_dll
 
framepos_t last_inbound_frame
 
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
 
double t0
 time at the beginning of the MTC quater frame More...
 
double t1
 calculated end of the MTC quater frame More...
 
double e2
 second order loop error More...
 
double b
 
double c
 
double omega
 DLL filter coefficients. More...
 
int engine_dll_initstate
 
double te0
 time at the beginning of the engine process More...
 
double te1
 calculated sync time More...
 
double ee2
 second order loop error More...
 
double be
 
double ce
 
double oe
 DLL filter coefficients. More...
 

Static Private Attributes

static const int frame_tolerance = 2
 

Additional Inherited Members

- Public Attributes inherited from ARDOUR::TimecodeSlave
framepos_t timecode_offset
 
bool timecode_negative_offset
 

Detailed Description

Definition at line 255 of file slave.h.

Constructor & Destructor Documentation

MTC_Slave::MTC_Slave ( Session s,
MidiPort p 
)

Definition at line 54 of file mtc_slave.cc.

MTC_Slave::~MTC_Slave ( )

Definition at line 83 of file mtc_slave.cc.

Member Function Documentation

Timecode::TimecodeFormat MTC_Slave::apparent_timecode_format ( ) const
virtual

Implements ARDOUR::TimecodeSlave.

Definition at line 690 of file mtc_slave.cc.

std::string MTC_Slave::approximate_current_delta ( ) const
virtual
Returns
- current time-delta between engine and sync-source

Reimplemented from ARDOUR::Slave.

Definition at line 711 of file mtc_slave.cc.

std::string MTC_Slave::approximate_current_position ( ) const
virtual

Implements ARDOUR::TimecodeSlave.

Definition at line 696 of file mtc_slave.cc.

bool MTC_Slave::give_slave_full_control_over_transport_speed ( ) const
virtual
Returns
- whether ARDOUR should use the slave speed without any adjustments

Reimplemented from ARDOUR::Slave.

Definition at line 133 of file mtc_slave.cc.

void MTC_Slave::handle_locate ( const MIDI::byte *  mmc_tc)

Definition at line 219 of file mtc_slave.cc.

void MTC_Slave::init_engine_dll ( framepos_t  pos,
framepos_t  inc 
)
private

Definition at line 562 of file mtc_slave.cc.

void MTC_Slave::init_mtc_dll ( framepos_t  tme,
double  qtr 
)
private

Definition at line 251 of file mtc_slave.cc.

bool MTC_Slave::locked ( ) const
virtual

reports to ARDOUR whether the Slave is currently synced to its external time source.

Returns
- when returning false, the transport will stop rolling

Implements ARDOUR::Slave.

Definition at line 159 of file mtc_slave.cc.

void MTC_Slave::maybe_reset ( )
private

Definition at line 182 of file mtc_slave.cc.

bool MTC_Slave::ok ( ) const
virtual

reports to ARDOUR whether the slave is in a sane state

Returns
- when returning false, the transport will be stopped and the slave disconnected from ARDOUR.

Implements ARDOUR::Slave.

Definition at line 166 of file mtc_slave.cc.

bool MTC_Slave::outside_window ( framepos_t  pos) const
private

Definition at line 152 of file mtc_slave.cc.

void MTC_Slave::parameter_changed ( std::string const &  p)
private

Definition at line 123 of file mtc_slave.cc.

void MTC_Slave::parse_timecode_offset ( )
private

Definition at line 113 of file mtc_slave.cc.

void MTC_Slave::queue_reset ( bool  with_pos)
private

Definition at line 172 of file mtc_slave.cc.

void MTC_Slave::read_current ( SafeTime st) const
private

Definition at line 234 of file mtc_slave.cc.

void MTC_Slave::rebind ( MidiPort p)

Definition at line 104 of file mtc_slave.cc.

bool ARDOUR::MTC_Slave::requires_seekahead ( ) const
inlinevirtual
Returns
- when returning true, ARDOUR will wait for seekahead_distance() before transport starts rolling

Implements ARDOUR::Slave.

Definition at line 268 of file slave.h.

void MTC_Slave::reset ( bool  with_pos)
private

Definition at line 194 of file mtc_slave.cc.

void MTC_Slave::reset_window ( framepos_t  root)
private

Definition at line 526 of file mtc_slave.cc.

ARDOUR::framecnt_t MTC_Slave::resolution ( ) const
virtual
Returns
- the timing resolution of the Slave - If the distance of ARDOURs transport to the slave becomes greater than the resolution, sound will stop

Implements ARDOUR::Slave.

Definition at line 140 of file mtc_slave.cc.

ARDOUR::framecnt_t MTC_Slave::seekahead_distance ( ) const
virtual
Returns
the number of frames that this slave wants to seek ahead. Relevant only if requires_seekahead() returns true.

Reimplemented from ARDOUR::Slave.

Definition at line 146 of file mtc_slave.cc.

bool MTC_Slave::speed_and_position ( double &  speed,
framepos_t position 
)
virtual

This is the most important function to implement: Each process cycle, Session::follow_slave will call this method. and after the method call they should

Session::follow_slave will then try to follow the given position using a delay locked loop (DLL), starting with the first given transport speed. If the values of speed and position contradict each other, ARDOUR will always follow the position and disregard the speed. Although, a correct speed is important so that ARDOUR can sync to the master time source quickly.

For background information on delay locked loops, see http://www.kokkinizita.net/papers/usingdll.pdf

The method has the following precondition:

  • Slave::ok() should return true, otherwise playback will stop immediately and the method will not be called
  • when the references speed and position are passed into the Slave they are uninitialized

After the method call the following postconditions should be met:

  • The first position value on transport start should be 0, otherwise ARDOUR will try to locate to the new position rather than move to it
  • the references speed and position should be assigned to the Slaves current requested transport speed and transport position.
  • Slave::resolution() should be greater than the maximum distance of ARDOURs transport position to the slaves requested transport position.
  • Slave::locked() should return true, otherwise Session::no_roll will be called
  • Slave::starting() should be false, otherwise the transport will not move until it becomes true *
Parameters
speed- The transport speed requested
position- The transport position requested
Returns
- The return value is currently ignored (see Session::follow_slave)

< MTC speed from MTC-quarter-frame DLL

Implements ARDOUR::Slave.

Definition at line 584 of file mtc_slave.cc.

void MTC_Slave::update_mtc_qtr ( MIDI::Parser &  ,
int  ,
framepos_t   
)
private

Definition at line 265 of file mtc_slave.cc.

void MTC_Slave::update_mtc_status ( MIDI::MTC_Status  status)
private

Definition at line 487 of file mtc_slave.cc.

void MTC_Slave::update_mtc_time ( const MIDI::byte *  msg,
bool  was_full,
framepos_t  now 
)
private

Definition at line 304 of file mtc_slave.cc.

Member Data Documentation

Timecode::TimecodeFormat ARDOUR::MTC_Slave::a3e_timecode
private

Definition at line 305 of file slave.h.

double ARDOUR::MTC_Slave::b
private

Definition at line 314 of file slave.h.

double ARDOUR::MTC_Slave::be
private

Definition at line 321 of file slave.h.

int ARDOUR::MTC_Slave::busy_guard1
private

Definition at line 299 of file slave.h.

int ARDOUR::MTC_Slave::busy_guard2
private

Definition at line 300 of file slave.h.

double ARDOUR::MTC_Slave::c
private

Definition at line 314 of file slave.h.

bool ARDOUR::MTC_Slave::can_notify_on_unknown_rate
private

Definition at line 281 of file slave.h.

double ARDOUR::MTC_Slave::ce
private

Definition at line 321 of file slave.h.

PBD::ScopedConnection ARDOUR::MTC_Slave::config_connection
private

Definition at line 280 of file slave.h.

SafeTime ARDOUR::MTC_Slave::current
private

Definition at line 285 of file slave.h.

frameoffset_t ARDOUR::MTC_Slave::current_delta
private

Definition at line 308 of file slave.h.

bool ARDOUR::MTC_Slave::did_reset_tc_format
private

Definition at line 293 of file slave.h.

double ARDOUR::MTC_Slave::e2
private

second order loop error

Definition at line 313 of file slave.h.

double ARDOUR::MTC_Slave::ee2
private

second order loop error

Definition at line 320 of file slave.h.

int ARDOUR::MTC_Slave::engine_dll_initstate
private

Definition at line 317 of file slave.h.

framepos_t ARDOUR::MTC_Slave::first_mtc_timestamp
private

Definition at line 292 of file slave.h.

const int MTC_Slave::frame_tolerance = 2
staticprivate

Definition at line 283 of file slave.h.

framepos_t ARDOUR::MTC_Slave::last_inbound_frame
private

Definition at line 288 of file slave.h.

MIDI::byte ARDOUR::MTC_Slave::last_mtc_fps_byte
private

Definition at line 289 of file slave.h.

framepos_t ARDOUR::MTC_Slave::mtc_frame
private

Definition at line 286 of file slave.h.

double ARDOUR::MTC_Slave::mtc_frame_dll
private

Definition at line 287 of file slave.h.

Timecode::TimecodeFormat ARDOUR::MTC_Slave::mtc_timecode
private

Definition at line 304 of file slave.h.

double ARDOUR::MTC_Slave::oe
private

DLL filter coefficients.

Definition at line 321 of file slave.h.

double ARDOUR::MTC_Slave::omega
private

DLL filter coefficients.

Definition at line 314 of file slave.h.

MidiPort* ARDOUR::MTC_Slave::port
private

Definition at line 278 of file slave.h.

PBD::ScopedConnectionList ARDOUR::MTC_Slave::port_connections
private

Definition at line 279 of file slave.h.

bool ARDOUR::MTC_Slave::printed_timecode_warning
private

Definition at line 307 of file slave.h.

double ARDOUR::MTC_Slave::quarter_frame_duration
private

Definition at line 303 of file slave.h.

Glib::Threads::Mutex ARDOUR::MTC_Slave::reset_lock
private

Definition at line 295 of file slave.h.

uint32_t ARDOUR::MTC_Slave::reset_pending
private

Definition at line 296 of file slave.h.

bool ARDOUR::MTC_Slave::reset_position
private

Definition at line 297 of file slave.h.

Timecode::TimecodeFormat ARDOUR::MTC_Slave::saved_tc_format
private

Definition at line 294 of file slave.h.

Session& ARDOUR::MTC_Slave::session
private

Definition at line 277 of file slave.h.

double ARDOUR::MTC_Slave::speedup_due_to_tc_mismatch
private

Definition at line 302 of file slave.h.

double ARDOUR::MTC_Slave::t0
private

time at the beginning of the MTC quater frame

Definition at line 311 of file slave.h.

double ARDOUR::MTC_Slave::t1
private

calculated end of the MTC quater frame

Definition at line 312 of file slave.h.

double ARDOUR::MTC_Slave::te0
private

time at the beginning of the engine process

Definition at line 318 of file slave.h.

double ARDOUR::MTC_Slave::te1
private

calculated sync time

Definition at line 319 of file slave.h.

Timecode::Time ARDOUR::MTC_Slave::timecode
private

Definition at line 306 of file slave.h.

int ARDOUR::MTC_Slave::transport_direction
private

Definition at line 298 of file slave.h.

framepos_t ARDOUR::MTC_Slave::window_begin
private

Definition at line 290 of file slave.h.

framepos_t ARDOUR::MTC_Slave::window_end
private

Definition at line 291 of file slave.h.


The documentation for this class was generated from the following files: