MIDClock_Slave: Introduce a 3% deadzone around speed 1.0 to lock in the speed
[ardour.git] / libs / ardour / test / midi_clock_slave_test.cpp
1 #include <sigc++/sigc++.h>
2 #include "midi_clock_slave_test.h"
3
4 using namespace std;
5 using namespace ARDOUR;
6
7 CPPUNIT_TEST_SUITE_REGISTRATION( MIDIClock_SlaveTest );
8
9 void
10 MIDIClock_SlaveTest::testStepResponse ()
11 {
12   double      speed    = 1.0;
13   nframes64_t position = 0;
14
15   MIDI::Parser* parser = 0;
16
17   TestSlaveSessionProxy *sess = (TestSlaveSessionProxy *) session;
18   nframes64_t period_size = 4096;
19   sess->set_period_size (period_size);
20
21   bandwidth = 1.0 / 60.0;
22
23   nframes64_t start_time = 1000000;
24   start (*parser, start_time);
25
26   update_midi_clock (*parser, start_time);      
27  
28   for (nframes64_t i = 1; i<= 100 * period_size; i++) {
29     if (i % nframes64_t(one_ppqn_in_frames) == 0) {
30       update_midi_clock (*parser, start_time + i);      
31     }
32
33     if (i % period_size == 0) {
34       sess->next_period ();
35       speed_and_position (speed, position);
36       sess->request_transport_speed (speed);
37     }
38   }
39
40 }
41
42