* removed rolling speed average from MIDIClockSlave, ardour seems to keep time now
authorHans Baier <hansfbaier@googlemail.com>
Wed, 6 Aug 2008 22:57:45 +0000 (22:57 +0000)
committerHans Baier <hansfbaier@googlemail.com>
Wed, 6 Aug 2008 22:57:45 +0000 (22:57 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@3663 d708f5d6-7413-0410-9779-e7cbd77b26cf

libs/ardour/ardour/slave.h
libs/ardour/midi_clock_slave.cc

index 0656ed305de997b2d9cb01e72ca16e3502c63da3..6efab3ff954a6623ef088e10e990cdcd0a0f7259 100644 (file)
@@ -134,11 +134,6 @@ class MIDIClock_Slave : public Slave, public sigc::trackable {
        nframes_t   first_midi_clock_frame;
        nframes_t   first_midi_clock_time;
 
-       static const int32_t accumulator_size = 128;
-       float   accumulator[accumulator_size];
-       int32_t accumulator_index;
-       bool    have_first_accumulated_speed;
-
        void reset ();
        void start (MIDI::Parser& parser);
        void stop (MIDI::Parser& parser);
index 569f14eeb54fd7914205635ce5bb4fe52a6e4bc9..f7810f36d05609613fbddfd413036f332870e325 100644 (file)
@@ -131,7 +131,13 @@ MIDIClock_Slave::stop (Parser& parser)
        std::cerr << "MIDIClock_Slave got stop message" << endl;
 
        midi_clock_speed = 0.0f;
+       midi_clock_frame = 0;
        _started = false;
+
+       current.guard1++;
+       current.position = midi_clock_frame;
+       current.timestamp = 0;
+       current.guard2++;
 }
 
 void
@@ -168,6 +174,11 @@ MIDIClock_Slave::speed_and_position (float& speed, nframes_t& pos)
 {
        //std::cerr << "MIDIClock_Slave speed and position() called" << endl;
 
+       if(_started == false) {
+               speed = 0.0;
+               pos = 0;
+       }
+       
        nframes_t now = session.engine().frame_time();
        nframes_t frame_rate = session.frame_rate();
        nframes_t elapsed;
@@ -198,27 +209,7 @@ MIDIClock_Slave::speed_and_position (float& speed, nframes_t& pos)
 
        cerr << "speed_and_position: speed_now: " << speed_now ;
        
-       accumulator[accumulator_index++] = speed_now;
-
-       if (accumulator_index >= accumulator_size) {
-               have_first_accumulated_speed = true;
-               accumulator_index = 0;
-       }
-
-       if (have_first_accumulated_speed) {
-               float total = 0;
-
-               for (int32_t i = 0; i < accumulator_size; ++i) {
-                       total += accumulator[i];
-               }
-
-               midi_clock_speed = total / accumulator_size;
-
-       } else {
-
-               midi_clock_speed = speed_now;
-
-       }
+       midi_clock_speed = speed_now;
 
        if (midi_clock_speed == 0.0f) {