mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-17 04:06:26 +01:00
adjust to use timestamped MTC messages
git-svn-id: svn://localhost/ardour2/branches/3.0@6255 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
b825b86862
commit
9e9cb3bf31
3 changed files with 26 additions and 19 deletions
|
|
@ -245,8 +245,8 @@ class MTC_Slave : public Slave, public sigc::trackable {
|
|||
bool have_first_accumulated_speed;
|
||||
|
||||
void reset ();
|
||||
void update_mtc_qtr (MIDI::Parser&, int);
|
||||
void update_mtc_time (const MIDI::byte *, bool);
|
||||
void update_mtc_qtr (MIDI::Parser&, int, nframes_t);
|
||||
void update_mtc_time (const MIDI::byte *, bool, nframes_t);
|
||||
void update_mtc_status (MIDI::Parser::MTC_Status);
|
||||
void read_current (SafeTime *) const;
|
||||
double compute_apparent_speed (nframes64_t);
|
||||
|
|
|
|||
|
|
@ -74,10 +74,8 @@ MTC_Slave::rebind (MIDI::Port& p)
|
|||
}
|
||||
|
||||
void
|
||||
MTC_Slave::update_mtc_qtr (Parser& /*p*/, int which_qtr)
|
||||
MTC_Slave::update_mtc_qtr (Parser& /*p*/, int which_qtr, nframes_t now)
|
||||
{
|
||||
nframes64_t now = session.engine().frame_time();
|
||||
|
||||
DEBUG_TRACE (DEBUG::MTC, string_compose ("qtr frame %1 at %2, valid-for-time? %3\n", which_qtr, now, qtr_frame_messages_valid_for_time));
|
||||
|
||||
if (qtr_frame_messages_valid_for_time) {
|
||||
|
|
@ -109,9 +107,12 @@ MTC_Slave::update_mtc_qtr (Parser& /*p*/, int which_qtr)
|
|||
}
|
||||
|
||||
void
|
||||
MTC_Slave::update_mtc_time (const byte *msg, bool was_full)
|
||||
MTC_Slave::update_mtc_time (const byte *msg, bool was_full, nframes_t now)
|
||||
{
|
||||
nframes64_t now = session.engine().frame_time();
|
||||
/* "now" can be zero if this is called from a context where we do not have or do not want
|
||||
to use a timestamp indicating when this MTC time was received.
|
||||
*/
|
||||
|
||||
Timecode::Time timecode;
|
||||
TimecodeFormat tc_format;
|
||||
bool reset_tc = true;
|
||||
|
|
@ -201,17 +202,21 @@ MTC_Slave::update_mtc_time (const byte *msg, bool was_full)
|
|||
*/
|
||||
|
||||
mtc_frame += (long) (1.75 * session.frames_per_timecode_frame()) + session.worst_output_latency();
|
||||
|
||||
double speed = compute_apparent_speed (now);
|
||||
|
||||
current.guard1++;
|
||||
current.position = mtc_frame;
|
||||
current.timestamp = now;
|
||||
current.speed = speed;
|
||||
current.guard2++;
|
||||
|
||||
if (now) {
|
||||
double speed = compute_apparent_speed (now);
|
||||
|
||||
current.guard1++;
|
||||
current.position = mtc_frame;
|
||||
current.timestamp = now;
|
||||
current.speed = speed;
|
||||
current.guard2++;
|
||||
}
|
||||
}
|
||||
|
||||
last_inbound_frame = now;
|
||||
if (now) {
|
||||
last_inbound_frame = now;
|
||||
}
|
||||
}
|
||||
|
||||
double
|
||||
|
|
@ -262,7 +267,7 @@ MTC_Slave::handle_locate (const MIDI::byte* mmc_tc)
|
|||
mtc[1] = mmc_tc[2];
|
||||
mtc[0] = mmc_tc[3];
|
||||
|
||||
update_mtc_time (mtc, true);
|
||||
update_mtc_time (mtc, true, 0);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
|||
|
|
@ -569,9 +569,11 @@ Session::follow_slave (nframes_t nframes)
|
|||
}
|
||||
#endif
|
||||
if (fabs(delta) > 2048) {
|
||||
nframes64_t jump_to = slave_transport_frame + lrintf (_current_frame_rate/5.0f);
|
||||
/* too far off, so locate and keep rolling */
|
||||
DEBUG_TRACE (DEBUG::Slave, string_compose ("slave delta %1 is too big, locate to %2\n", delta, slave_transport_frame));
|
||||
request_locate (slave_transport_frame, true);
|
||||
DEBUG_TRACE (DEBUG::Slave, string_compose ("slave delta %1 is too big, locate to %2\n",
|
||||
delta, jump_to));
|
||||
request_locate (jump_to, true);
|
||||
return false;
|
||||
} else {
|
||||
float adjusted_speed = slave_speed + (delta / float(_current_frame_rate));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue