diff options
author | Robin Gareus <robin@gareus.org> | 2019-09-05 14:52:08 +0200 |
---|---|---|
committer | Robin Gareus <robin@gareus.org> | 2019-09-05 14:52:08 +0200 |
commit | 01c5aa34c69cebf2816f5ea42bccbdd9b80145d0 (patch) | |
tree | fef1d32787a6749d7d1bcbeda65359ee1571f1cb /libs/ardour/test/midi_clock_test.cc | |
parent | 5dfb729155e19960e99ca973947bdbb680e6630f (diff) |
Update MClk unit-test - new transportmaster API
Diffstat (limited to 'libs/ardour/test/midi_clock_test.cc')
-rw-r--r-- | libs/ardour/test/midi_clock_test.cc | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/libs/ardour/test/midi_clock_test.cc b/libs/ardour/test/midi_clock_test.cc new file mode 100644 index 0000000000..fdccf56ab5 --- /dev/null +++ b/libs/ardour/test/midi_clock_test.cc @@ -0,0 +1,49 @@ +#include <sigc++/sigc++.h> +#include "midi_clock_test.h" + +using namespace std; +using namespace ARDOUR; + +CPPUNIT_TEST_SUITE_REGISTRATION(MIDIClock_Test); + +void +MclkTestMaster::testStepResponse () +{ + double speed = 1.0; + samplepos_t position = 0; + MIDI::Parser* parser = 0; + + samplecnt_t period_size = 4096; + samplepos_t start_time = 1000000; + + start (*parser, start_time); + + update_midi_clock (*parser, start_time); + + for (samplecnt_t i = 1; i <= 100 * period_size; i++) { + /* simulate jitter */ + samplecnt_t input_delta = samplecnt_t (one_ppqn_in_samples + 0.1 * (double(g_random_int()) / double (RAND_MAX)) * one_ppqn_in_samples); + + if (i % input_delta == 0) { + update_midi_clock (*parser, start_time + i); + } + + if (i % period_size == 0) { + samplepos_t most_recent; + samplepos_t when; + speed_and_position (speed, position, most_recent, when, start_time + i); + // TODO CPPUNIT_ASSERT_EQUAL ?! + } + } +} + +void MIDIClock_Test::run_test () +{ + /* Note: A running engine is required to construct + * ARDOUR::MIDIClock_TransportMaster + */ + MclkTestMaster* m = new MclkTestMaster; + m->set_session (_session); + m->testStepResponse (); + delete m; +} |