globally change all use of "frame" to refer to audio into "sample".
[ardour.git] / libs / ardour / test / midi_clock_slave_test.cc
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   samplepos_t position = 0;
14
15   MIDI::Parser* parser = 0;
16
17   TestSlaveSessionProxy *sess = (TestSlaveSessionProxy *) session;
18   samplecnt_t period_size = 4096;
19   sess->set_period_size (period_size);
20
21   bandwidth = 1.0 / 60.0;
22
23   samplepos_t start_time = 1000000;
24   start (*parser, start_time);
25
26   update_midi_clock (*parser, start_time);
27
28   for (samplecnt_t i = 1; i<= 100 * period_size; i++) {
29     // simulate jitter
30     samplecnt_t input_delta = samplecnt_t (one_ppqn_in_samples + 0.1 * (double(g_random_int()) / double (RAND_MAX)) * one_ppqn_in_samples);
31
32     if (i % input_delta == 0) {
33       update_midi_clock (*parser, start_time + i);
34     }
35
36     if (i % period_size == 0) {
37       sess->next_period ();
38       speed_and_position (speed, position);
39       sess->request_transport_speed (speed);
40     }
41   }
42
43 }
44
45