Update MClk unit-test - new transportmaster API
This commit is contained in:
parent
5dfb729155
commit
01c5aa34c6
|
@ -1,45 +0,0 @@
|
|||
#include <sigc++/sigc++.h>
|
||||
#include "midi_clock_slave_test.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace ARDOUR;
|
||||
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION( MIDIClock_SlaveTest );
|
||||
|
||||
void
|
||||
MIDIClock_SlaveTest::testStepResponse ()
|
||||
{
|
||||
double speed = 1.0;
|
||||
samplepos_t position = 0;
|
||||
|
||||
MIDI::Parser* parser = 0;
|
||||
|
||||
TestSlaveSessionProxy *sess = (TestSlaveSessionProxy *) session;
|
||||
samplecnt_t period_size = 4096;
|
||||
sess->set_period_size (period_size);
|
||||
|
||||
bandwidth = 1.0 / 60.0;
|
||||
|
||||
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) {
|
||||
sess->next_period ();
|
||||
speed_and_position (speed, position);
|
||||
sess->request_transport_speed (speed);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -1,100 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2010-2012 Carl Hetherington <carl@carlh.net>
|
||||
* Copyright (C) 2010 Hans Baier <hansfbaier@googlemail.com>
|
||||
* Copyright (C) 2015-2016 Robin Gareus <robin@gareus.org>
|
||||
* Copyright (C) 2015-2017 Nick Mainsbridge <mainsbridge@gmail.com>
|
||||
* Copyright (C) 2015-2018 Paul Davis <paul@linuxaudiosystems.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#include <cassert>
|
||||
#include <stdint.h>
|
||||
#include <cppunit/TestFixture.h>
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
|
||||
#include "ardour/tempo.h"
|
||||
#include "ardour/transport_master.h"
|
||||
|
||||
namespace ARDOUR {
|
||||
|
||||
class TestSlaveSessionProxy : public ISlaveSessionProxy {
|
||||
#define FRAME_RATE 44100
|
||||
samplecnt_t _period_size;
|
||||
|
||||
double transport_speed;
|
||||
samplepos_t _transport_sample;
|
||||
samplepos_t _sample_time;
|
||||
TempoMap *_tempo_map;
|
||||
|
||||
Tempo tempo;
|
||||
Meter meter;
|
||||
|
||||
public:
|
||||
TestSlaveSessionProxy() :
|
||||
transport_speed (1.0),
|
||||
_transport_sample (0),
|
||||
_sample_time (1000000),
|
||||
_tempo_map (0),
|
||||
tempo (120, 4.0),
|
||||
meter (4.0, 4.0)
|
||||
{
|
||||
_tempo_map = new TempoMap (FRAME_RATE);
|
||||
_tempo_map->add_tempo (tempo, 0.0, 0, AudioTime);
|
||||
_tempo_map->add_meter (meter, Timecode::BBT_Time(1, 1, 0), 0, AudioTime);
|
||||
}
|
||||
|
||||
// Controlling the mock object
|
||||
void set_period_size (samplecnt_t a_size) { _period_size = a_size; }
|
||||
samplecnt_t period_size () const { return _period_size; }
|
||||
void next_period () {
|
||||
_transport_sample += double(_period_size) * double(transport_speed);
|
||||
_sample_time += _period_size;
|
||||
}
|
||||
|
||||
// Implementation
|
||||
TempoMap& tempo_map () const { return *_tempo_map; }
|
||||
samplecnt_t sample_rate () const { return FRAME_RATE; }
|
||||
samplepos_t audible_sample () const { return _transport_sample; }
|
||||
samplepos_t transport_sample () const { return _transport_sample; }
|
||||
pframes_t samples_since_cycle_start () const { return 0; }
|
||||
samplepos_t sample_time () const { return _sample_time; }
|
||||
|
||||
void request_locate (samplepos_t sample, bool with_roll = false) {
|
||||
_transport_sample = sample;
|
||||
}
|
||||
|
||||
void request_transport_speed (const double speed) { transport_speed = speed; }
|
||||
};
|
||||
|
||||
class MIDIClock_SlaveTest : public CppUnit::TestFixture, ARDOUR::MIDIClock_Slave
|
||||
{
|
||||
CPPUNIT_TEST_SUITE(MIDIClock_SlaveTest);
|
||||
CPPUNIT_TEST(testStepResponse);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
public:
|
||||
MIDIClock_SlaveTest () : MIDIClock_Slave (new TestSlaveSessionProxy) {}
|
||||
|
||||
void setUp() {
|
||||
}
|
||||
|
||||
void tearDown() {
|
||||
}
|
||||
|
||||
void testStepResponse();
|
||||
};
|
||||
|
||||
} // namespace ARDOUR
|
|
@ -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;
|
||||
}
|
|
@ -0,0 +1,49 @@
|
|||
/*
|
||||
* Copyright (C) 2015-2019 Robin Gareus <robin@gareus.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#include <cassert>
|
||||
#include <stdint.h>
|
||||
#include <cppunit/TestFixture.h>
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
|
||||
#include "ardour/tempo.h"
|
||||
#include "ardour/transport_master.h"
|
||||
|
||||
#include "test_needing_session.h"
|
||||
|
||||
namespace ARDOUR {
|
||||
|
||||
class MclkTestMaster : public ARDOUR::MIDIClock_TransportMaster
|
||||
{
|
||||
|
||||
public:
|
||||
MclkTestMaster () : MIDIClock_TransportMaster ("MClk-test", 24) {}
|
||||
void testStepResponse ();
|
||||
};
|
||||
|
||||
class MIDIClock_Test : public TestNeedingSession
|
||||
{
|
||||
CPPUNIT_TEST_SUITE(MIDIClock_Test);
|
||||
CPPUNIT_TEST(run_test);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
public:
|
||||
void run_test ();
|
||||
};
|
||||
|
||||
} // namespace ARDOUR
|
|
@ -521,7 +521,7 @@ def build(bld):
|
|||
create_ardour_test_program(bld, obj.includes, 'bbt', 'test_bbt', ['test/bbt_test.cc'])
|
||||
create_ardour_test_program(bld, obj.includes, 'tempo', 'test_tempo', ['test/tempo_test.cc'])
|
||||
create_ardour_test_program(bld, obj.includes, 'lua_script', 'test_lua_script', ['test/lua_script_test.cc'])
|
||||
create_ardour_test_program(bld, obj.includes, 'midi_clock_slave', 'test_midi_clock_slave', ['test/midi_clock_slave_test.cc'])
|
||||
create_ardour_test_program(bld, obj.includes, 'midi_clock', 'test_midi_clock', ['test/midi_clock_test.cc'])
|
||||
create_ardour_test_program(bld, obj.includes, 'resampled_source', 'test_resampled_source', ['test/resampled_source_test.cc'])
|
||||
create_ardour_test_program(bld, obj.includes, 'samplewalk_to_beats', 'test_samplewalk_to_beats', ['test/samplewalk_to_beats_test.cc'])
|
||||
create_ardour_test_program(bld, obj.includes, 'samplepos_plus_beats', 'test_samplepos_plus_beats', ['test/samplepos_plus_beats_test.cc'])
|
||||
|
@ -542,7 +542,7 @@ def build(bld):
|
|||
test/dsp_load_calculator_test.cc
|
||||
test/tempo_test.cc
|
||||
test/lua_script_test.cc
|
||||
test/midi_clock_slave_test.cc
|
||||
test/midi_clock_test.cc
|
||||
test/resampled_source_test.cc
|
||||
test/samplewalk_to_beats_test.cc
|
||||
test/samplepos_plus_beats_test.cc
|
||||
|
|
Loading…
Reference in New Issue