13
0

MIDIClock_SlaveTest: first working testcase

git-svn-id: svn://localhost/ardour2/branches/3.0@6589 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Hans Baier 2010-01-29 05:18:22 +00:00
parent 8ee52628fc
commit fc4c321173
2 changed files with 34 additions and 9 deletions

View File

@ -9,9 +9,33 @@ CPPUNIT_TEST_SUITE_REGISTRATION( MIDIClock_SlaveTest );
void
MIDIClock_SlaveTest::testStepResponse ()
{
double speed = 1.0;
nframes64_t position = 0;
MIDI::Parser* parser = 0;
TestSlaveSessionProxy *sess = (TestSlaveSessionProxy *) session;
nframes64_t period_size = 1024;
sess->set_period_size (period_size);
nframes64_t start_time = 1000000;
start (*parser, start_time);
update_midi_clock (*parser, start_time);
for (nframes64_t i = 1; i<= 100 * period_size; i++) {
if (i % nframes64_t(one_ppqn_in_frames) == 0) {
update_midi_clock (*parser, start_time + i);
}
if (i % period_size == 0) {
sess->next_period ();
speed_and_position (speed, position);
sess->request_transport_speed (speed);
}
}
//CPPUNIT_ASSERT_EQUAL ((uint32_t)(NUM_SAMPLES * linear.speed()), result);
}

View File

@ -33,34 +33,35 @@ class TestSlaveSessionProxy : public ISlaveSessionProxy {
double transport_speed;
nframes64_t _transport_frame;
nframes64_t _frame_time;
TempoMap _tempo_map;
TempoMap *_tempo_map;
Tempo tempo;
Meter meter;
BBT_Time zero;
public:
TestSlaveSessionProxy() :
transport_speed (1.0),
_transport_frame (0),
_frame_time (1000000),
_tempo_map (FRAME_RATE),
_tempo_map (0),
tempo (120),
meter (4.0, 4.0)
{
_tempo_map.add_tempo (tempo, zero);
_tempo_map.add_meter (meter, zero);
_tempo_map = new TempoMap (FRAME_RATE);
_tempo_map->add_tempo (tempo, BBT_Time(1, 1, 0));
_tempo_map->add_meter (meter, BBT_Time(1, 1, 0));
}
// Controlling the mock object
void set_period_size (nframes64_t a_size) { _period_size = a_size; }
void set_period_size (nframes64_t a_size) { _period_size = a_size; }
nframes64_t period_size () const { return _period_size; }
void next_period () {
_transport_frame += _period_size;
_transport_frame += double(_period_size) * double(transport_speed);
_frame_time += _period_size;
}
// Implementation
TempoMap& tempo_map () { return _tempo_map; }
TempoMap& tempo_map () const { return *_tempo_map; }
nframes_t frame_rate () const { return FRAME_RATE; }
nframes64_t audible_frame () const { return _transport_frame; }
nframes64_t transport_frame () const { return _transport_frame; }