using namespace sigc;
using namespace MIDI;
+#undef DEBUG_MTC
+
bool
Parser::possible_mtc (byte *sysex_buf, size_t msglen)
{
mtc (*this, &sysex_buf[1], msglen - 1);
mtc_time (fake_mtc_time, true, _timestamp);
+#ifdef DEBUG_MTC
+ cerr << "New full-MTC message marks state stopped" << endl;
+#endif
mtc_status (MTC_Stopped);
return true;
void
Parser::reset_mtc_state ()
{
+#ifdef DEBUG_MTC
+ cerr << "MTC state reset" << endl;
+#endif
+ /* MUST REMAIN RT-SAFE */
+
_mtc_forward = false;
_mtc_running = MTC_Stopped;
_mtc_locked = false;
/* third quarter frame */
- // cerr << "second seen qframe = " << (int) which_quarter_frame << endl;
-
+#ifdef DEBUG_MTC
+ cerr << "second seen qframe = " << (int) which_quarter_frame << endl;
+#endif
if (last_qtr_frame < which_quarter_frame) {
_mtc_running = MTC_Forward;
} else if (last_qtr_frame > which_quarter_frame) {
_mtc_running = MTC_Backward;
}
-
+#ifdef DEBUG_MTC
+ cerr << "Send MTC status as " << _mtc_running << endl;
+#endif
mtc_status (_mtc_running);
}
true, just ignore this in terms of it being an error.
*/
- if (1) { /* mtc_skipped () */
+ boost::optional<bool> res = mtc_skipped ();
+
+ if (res.get_value_or (false)) {
/* no error, reset next expected frame */
return;
}
- /* go back to waiting for the first frame */
-
- expected_mtc_quarter_frame_code = 0;
- memset (_qtr_mtc_time, 0, sizeof (_qtr_mtc_time));
+ /* skip counts as an error ... go back to waiting for the first frame */
- _mtc_running = MTC_Stopped;
- _mtc_locked = false;
+#ifdef DEBUG_MTC
+ cerr << "Skipped MTC qtr frame, return to stopped state" << endl;
+#endif
+ reset_mtc_state ();
mtc_status (MTC_Stopped);
return;
/* time code is looking good */
#ifdef DEBUG_MTC
- cerr << "for quarter frame " << which_quarter_frame << " byte = " << hex << (int) msg[1] << dec << endl;
+ // cerr << "for quarter frame " << which_quarter_frame << " byte = " << hex << (int) msg[1] << dec << endl;
#endif
switch (which_quarter_frame) {
}
+#ifdef DEBUG_MTC
+ cerr << "Emit MTC Qtr\n";
+#endif
+
mtc_qtr (*this, which_quarter_frame, _timestamp); /* EMIT_SIGNAL */
// mtc (*this, &msg[1], msglen - 1);