possible fix for MTC slaving

git-svn-id: svn://localhost/ardour2/trunk@1498 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Paul Davis 2007-02-23 13:40:09 +00:00
parent dfa996f8be
commit 3ecf8cd008
4 changed files with 42 additions and 4 deletions

View file

@ -146,6 +146,8 @@ static const char* authors[] = {
N_("Robert Jordens"),
N_("Brian Ahr"),
N_("Nimal Ratnayake"),
N_("Mike Taht"),
N_("John Anderson"),
0
};

View file

@ -70,6 +70,7 @@ class MTC_Slave : public Slave, public sigc::trackable {
Session& session;
MIDI::Port* port;
std::vector<sigc::connection> connections;
bool can_notify_on_unknown_rate;
struct SafeTime {

View file

@ -41,6 +41,8 @@ using namespace PBD;
MTC_Slave::MTC_Slave (Session& s, MIDI::Port& p)
: session (s)
{
can_notify_on_unknown_rate = true;
rebind (p);
reset ();
}
@ -93,8 +95,39 @@ MTC_Slave::update_mtc_time (const byte *msg, bool was_full)
smpte.minutes = msg[2];
smpte.seconds = msg[1];
smpte.frames = msg[0];
session.smpte_to_sample( smpte, mtc_frame, true, false );
switch (msg[4]) {
case MTC_24_FPS:
smpte.rate = 24;
smpte.drop = false;
can_notify_on_unknown_rate = true;
break;
case MTC_25_FPS:
smpte.rate = 25;
smpte.drop = false;
can_notify_on_unknown_rate = true;
break;
case MTC_30_FPS_DROP:
smpte.rate = 30;
smpte.drop = true;
can_notify_on_unknown_rate = true;
break;
case MTC_30_FPS:
smpte.rate = 30;
smpte.drop = false;
can_notify_on_unknown_rate = true;
break;
default:
/* throttle error messages about unknown MTC rates */
if (can_notify_on_unknown_rate) {
error << _("Unknown rate/drop value in incoming MTC stream, session values used instead") << endmsg;
can_notify_on_unknown_rate = false;
}
smpte.rate = session.smpte_frames_per_second();
smpte.drop = session.smpte_drop_frames();
}
session.smpte_to_sample (smpte, mtc_frame, true, false);
if (was_full) {

View file

@ -36,7 +36,7 @@ using namespace MIDI;
bool
Parser::possible_mtc (byte *sysex_buf, size_t msglen)
{
byte fake_mtc_time[4];
byte fake_mtc_time[5];
if (msglen != 10 || sysex_buf[0] != 0xf0 || sysex_buf[1] != 0x7f || sysex_buf[3] != 0x01 || sysex_buf[4] != 0x01) {
return false;
@ -50,7 +50,9 @@ Parser::possible_mtc (byte *sysex_buf, size_t msglen)
fake_mtc_time[3] = (sysex_buf[5] & 0x1f); // hours
_mtc_fps = MTC_FPS ((sysex_buf[5] & 0x60) >> 5); // fps
fake_mtc_time[4] = (byte) _mtc_fps;
/* wait for first quarter frame, which could indicate forwards
or backwards ...
*/