ardour
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
ARDOUR::MIDIClock_Slave Class Reference

#include <slave.h>

Inheritance diagram for ARDOUR::MIDIClock_Slave:
ARDOUR::Slave ARDOUR::MIDIClock_SlaveTest

Public Member Functions

 MIDIClock_Slave (Session &, MidiPort &, int ppqn=24)
 
 MIDIClock_Slave (ISlaveSessionProxy *session_proxy=0, int ppqn=24)
 Constructor for unit tests. More...
 
 ~MIDIClock_Slave ()
 
void rebind (MidiPort &)
 
bool speed_and_position (double &, framepos_t &)
 
bool locked () const
 
bool ok () const
 
bool starting () const
 
framecnt_t resolution () const
 
bool requires_seekahead () const
 
bool give_slave_full_control_over_transport_speed () const
 
void set_bandwidth (double a_bandwith)
 
std::string approximate_current_delta () const
 
- Public Member Functions inherited from ARDOUR::Slave
 Slave ()
 
virtual ~Slave ()
 
virtual framecnt_t seekahead_distance () const
 
virtual bool is_always_synced () const
 

Protected Member Functions

void reset ()
 
void start (MIDI::Parser &parser, framepos_t timestamp)
 
void contineu (MIDI::Parser &parser, framepos_t timestamp)
 
void stop (MIDI::Parser &parser, framepos_t timestamp)
 
void position (MIDI::Parser &parser, MIDI::byte *message, size_t size)
 
void calculate_one_ppqn_in_frames_at (framepos_t time)
 
framepos_t calculate_song_position (uint16_t song_position_in_sixteenth_notes)
 
void calculate_filter_coefficients ()
 
void update_midi_clock (MIDI::Parser &parser, framepos_t timestamp)
 
void read_current (SafeTime *) const
 
bool stop_if_no_more_clock_events (framepos_t &pos, framepos_t now)
 

Protected Attributes

ISlaveSessionProxysession
 
PBD::ScopedConnectionList port_connections
 
int ppqn
 pulses per quarter note for one MIDI clock frame (default 24) More...
 
double one_ppqn_in_frames
 the duration of one ppqn in frame time More...
 
framepos_t first_timestamp
 the timestamp of the first MIDI clock message More...
 
framepos_t last_timestamp
 the time stamp and should-be transport position of the last inbound MIDI clock message More...
 
double should_be_position
 
long midi_clock_count
 
double t0
 time at the beginning of the MIDI clock frame More...
 
double t1
 calculated end of the MIDI clock frame More...
 
double e
 loop error = real value - expected value More...
 
double e2
 second order loop error More...
 
double bandwidth
 DLL filter bandwidth. More...
 
double b
 DLL filter coefficients. More...
 
double c
 
double omega
 
frameoffset_t current_delta
 
bool _started
 whether transport should be rolling More...
 
bool _starting
 

Detailed Description

Definition at line 408 of file slave.h.

Constructor & Destructor Documentation

MIDIClock_Slave::MIDIClock_Slave ( Session s,
MidiPort p,
int  ppqn = 24 
)

Definition at line 45 of file midi_clock_slave.cc.

MIDIClock_Slave::MIDIClock_Slave ( ISlaveSessionProxy session_proxy = 0,
int  ppqn = 24 
)

Constructor for unit tests.

Definition at line 54 of file midi_clock_slave.cc.

MIDIClock_Slave::~MIDIClock_Slave ( )

Definition at line 62 of file midi_clock_slave.cc.

Member Function Documentation

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

Reimplemented from ARDOUR::Slave.

Definition at line 368 of file midi_clock_slave.cc.

void MIDIClock_Slave::calculate_filter_coefficients ( )
protected

Definition at line 109 of file midi_clock_slave.cc.

void MIDIClock_Slave::calculate_one_ppqn_in_frames_at ( framepos_t  time)
protected

Definition at line 83 of file midi_clock_slave.cc.

ARDOUR::framepos_t MIDIClock_Slave::calculate_song_position ( uint16_t  song_position_in_sixteenth_notes)
protected

Definition at line 96 of file midi_clock_slave.cc.

void MIDIClock_Slave::contineu ( MIDI::Parser &  parser,
framepos_t  timestamp 
)
protected

Definition at line 221 of file midi_clock_slave.cc.

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

Reimplemented from ARDOUR::Slave.

Definition at line 425 of file slave.h.

bool MIDIClock_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 288 of file midi_clock_slave.cc.

bool MIDIClock_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 294 of file midi_clock_slave.cc.

void MIDIClock_Slave::position ( MIDI::Parser &  parser,
MIDI::byte *  message,
size_t  size 
)
protected

Definition at line 263 of file midi_clock_slave.cc.

void ARDOUR::MIDIClock_Slave::read_current ( SafeTime ) const
protected
void MIDIClock_Slave::rebind ( MidiPort port)

Definition at line 68 of file midi_clock_slave.cc.

bool ARDOUR::MIDIClock_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 424 of file slave.h.

void MIDIClock_Slave::reset ( )
protected

Definition at line 206 of file midi_clock_slave.cc.

ARDOUR::framecnt_t MIDIClock_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 361 of file midi_clock_slave.cc.

void ARDOUR::MIDIClock_Slave::set_bandwidth ( double  a_bandwith)
inline

Definition at line 427 of file slave.h.

bool MIDIClock_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)

Implements ARDOUR::Slave.

Definition at line 323 of file midi_clock_slave.cc.

void MIDIClock_Slave::start ( MIDI::Parser &  parser,
framepos_t  timestamp 
)
protected

Definition at line 191 of file midi_clock_slave.cc.

bool MIDIClock_Slave::starting ( ) const
virtual

reports to ARDOUR whether the slave is in the process of starting to roll

Returns
- when returning false, transport will not move until this method returns true

Reimplemented from ARDOUR::Slave.

Definition at line 300 of file midi_clock_slave.cc.

void MIDIClock_Slave::stop ( MIDI::Parser &  parser,
framepos_t  timestamp 
)
protected

Definition at line 233 of file midi_clock_slave.cc.

bool MIDIClock_Slave::stop_if_no_more_clock_events ( framepos_t pos,
framepos_t  now 
)
protected

Definition at line 306 of file midi_clock_slave.cc.

void MIDIClock_Slave::update_midi_clock ( MIDI::Parser &  parser,
framepos_t  timestamp 
)
protected

Definition at line 118 of file midi_clock_slave.cc.

Member Data Documentation

bool ARDOUR::MIDIClock_Slave::_started
protected

whether transport should be rolling

Definition at line 487 of file slave.h.

bool ARDOUR::MIDIClock_Slave::_starting
protected

is true if the MIDI Start message has just been received until the first MIDI Clock Event

Definition at line 491 of file slave.h.

double ARDOUR::MIDIClock_Slave::b
protected

DLL filter coefficients.

Definition at line 469 of file slave.h.

double ARDOUR::MIDIClock_Slave::bandwidth
protected

DLL filter bandwidth.

Definition at line 466 of file slave.h.

double ARDOUR::MIDIClock_Slave::c
protected

Definition at line 469 of file slave.h.

frameoffset_t ARDOUR::MIDIClock_Slave::current_delta
protected

Definition at line 471 of file slave.h.

double ARDOUR::MIDIClock_Slave::e
protected

loop error = real value - expected value

Definition at line 460 of file slave.h.

double ARDOUR::MIDIClock_Slave::e2
protected

second order loop error

Definition at line 463 of file slave.h.

framepos_t ARDOUR::MIDIClock_Slave::first_timestamp
protected

the timestamp of the first MIDI clock message

Definition at line 441 of file slave.h.

framepos_t ARDOUR::MIDIClock_Slave::last_timestamp
protected

the time stamp and should-be transport position of the last inbound MIDI clock message

Definition at line 444 of file slave.h.

long ARDOUR::MIDIClock_Slave::midi_clock_count
protected

the number of midi clock messages received (zero-based) since start

Definition at line 449 of file slave.h.

double ARDOUR::MIDIClock_Slave::omega
protected

Definition at line 469 of file slave.h.

double ARDOUR::MIDIClock_Slave::one_ppqn_in_frames
protected

the duration of one ppqn in frame time

Definition at line 438 of file slave.h.

PBD::ScopedConnectionList ARDOUR::MIDIClock_Slave::port_connections
protected

Definition at line 432 of file slave.h.

int ARDOUR::MIDIClock_Slave::ppqn
protected

pulses per quarter note for one MIDI clock frame (default 24)

Definition at line 435 of file slave.h.

ISlaveSessionProxy* ARDOUR::MIDIClock_Slave::session
protected

Definition at line 431 of file slave.h.

double ARDOUR::MIDIClock_Slave::should_be_position
protected

Definition at line 445 of file slave.h.

double ARDOUR::MIDIClock_Slave::t0
protected

time at the beginning of the MIDI clock frame

Definition at line 454 of file slave.h.

double ARDOUR::MIDIClock_Slave::t1
protected

calculated end of the MIDI clock frame

Definition at line 457 of file slave.h.


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