fix up MTC message delivered internally when locate is noticed (removes stupid messag...
authorPaul Davis <paul@linuxaudiosystems.com>
Thu, 4 Dec 2008 20:26:35 +0000 (20:26 +0000)
committerPaul Davis <paul@linuxaudiosystems.com>
Thu, 4 Dec 2008 20:26:35 +0000 (20:26 +0000)
git-svn-id: svn://localhost/ardour2/branches/2.0-ongoing@4287 d708f5d6-7413-0410-9779-e7cbd77b26cf

libs/ardour/ardour/session.h
libs/ardour/ardour/slave.h
libs/ardour/mtc_slave.cc
libs/ardour/session_process.cc
libs/midi++2/mtc.cc

index ac0c052fa19a8a30813215f35627b3b16ac03e41..a2089b43587e632926d418f0b87ee6962f221625 100644 (file)
@@ -398,6 +398,10 @@ class Session : public PBD::StatefulDestructible
        double frames_per_smpte_frame() const { return _frames_per_smpte_frame; }
        nframes_t smpte_frames_per_hour() const { return _smpte_frames_per_hour; }
 
+       MIDI::byte get_mtc_smpte_bits() const { 
+               return mtc_smpte_bits;   /* encoding of SMTPE type for MTC */
+       }
+
        float smpte_frames_per_second() const;
        bool smpte_drop_frames() const;
 
index 509f8fa9d2fce8c44988243e3395133a37492a79..b07c4d27bbc968b85973d27bcfbd60641ebbf7c1 100644 (file)
@@ -91,6 +91,7 @@ class MTC_Slave : public Slave, public sigc::trackable {
        SafeTime         current;
        nframes_t   mtc_frame;               /* current time */
        nframes_t   last_inbound_frame;      /* when we got it; audio clocked */
+       MIDI::byte  last_mtc_fps_byte;
 
        float            mtc_speed;
        nframes_t   first_mtc_frame;
index 3b4aaae8873efe4c7a5136860f8c4e821b461122..db7e1d5c84a025cdcc03aec98a5e0fac9120cebd 100644 (file)
@@ -16,7 +16,7 @@
     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
 */
-
+#include <iostream>
 #include <errno.h>
 #include <poll.h>
 #include <sys/types.h>
@@ -43,6 +43,8 @@ MTC_Slave::MTC_Slave (Session& s, MIDI::Port& p)
 {
        can_notify_on_unknown_rate = true;
 
+       last_mtc_fps_byte = session.get_mtc_smpte_bits ();
+
        rebind (p);
        reset ();
 }
@@ -96,6 +98,8 @@ MTC_Slave::update_mtc_time (const byte *msg, bool was_full)
        smpte.seconds = msg[1];
        smpte.frames = msg[0];
 
+       last_mtc_fps_byte = msg[4];
+       
        switch (msg[4]) {
        case MTC_24_FPS:
                smpte.rate = 24;
@@ -120,7 +124,9 @@ MTC_Slave::update_mtc_time (const byte *msg, bool was_full)
        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;
+                       error << string_compose (_("Unknown rate/drop value %1 in incoming MTC stream, session values used instead"),
+                                                (int) msg[4]) 
+                             << endmsg;
                        can_notify_on_unknown_rate = false;
                }
                smpte.rate = session.smpte_frames_per_second();
@@ -170,8 +176,9 @@ MTC_Slave::update_mtc_time (const byte *msg, bool was_full)
 void
 MTC_Slave::handle_locate (const MIDI::byte* mmc_tc)
 {
-       MIDI::byte mtc[4];
+       MIDI::byte mtc[5];
        
+       mtc[4] = last_mtc_fps_byte;
        mtc[3] = mmc_tc[0] & 0xf; /* hrs only */
        mtc[2] = mmc_tc[1];
        mtc[1] = mmc_tc[2];
index 3e3a4ee3d74077b7e58a50e66c7a6d4483caaeda..5891be2083df15c8d23ad8c06768cbb7cbee7df4 100644 (file)
@@ -446,7 +446,7 @@ Session::follow_slave (nframes_t nframes, nframes_t offset)
        _slave->speed_and_position (slave_speed, slave_transport_frame);
 
        if (!_slave->locked()) {
-               cerr << "Slave not locked, not rolling\n";
+               // cerr << "Slave not locked, not rolling\n";
                goto noroll;
        }
 
@@ -643,12 +643,14 @@ Session::follow_slave (nframes_t nframes, nframes_t offset)
                        float adjusted_speed = slave_speed +
                                (delta / (adjust_seconds * _current_frame_rate));
                        
-                       // cerr << "adjust using " << delta
-                       // << " towards " << adjusted_speed
-                       // << " ratio = " << adjusted_speed / slave_speed
-                       // << " current = " << _transport_speed
-                       // << " slave @ " << slave_speed
-                       // << endl;
+#if 0
+                       cerr << "adjust using " << delta
+                            << " towards " << adjusted_speed
+                            << " ratio = " << adjusted_speed / slave_speed
+                            << " current = " << _transport_speed
+                            << " slave @ " << slave_speed
+                            << endl;
+#endif
                        
                        request_transport_speed (adjusted_speed);
                        
index 46f71dc23dbc80ca942cccf1f1c4134d9cdf2088..9d62c7354c44d1687c32a6fc874f156be9e028af 100644 (file)
@@ -50,7 +50,6 @@ 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
@@ -292,6 +291,7 @@ Parser::process_mtc_quarter_frame (byte *msg)
                                if (!_mtc_locked) {
                                        _mtc_locked = true;
                                }
+
                                mtc_time (_mtc_time, false);
                        }
                        expected_mtc_quarter_frame_code = 0;