13
0
livetrax/libs/evoral/test/SMFTest.cpp
Hans Baier dcc25d795b * Evoral: Added Unit test for SMF
git-svn-id: svn://localhost/ardour2/branches/3.0@4523 d708f5d6-7413-0410-9779-e7cbd77b26cf
2009-02-10 23:58:02 +00:00

42 lines
915 B
C++

#include "SMFTest.hpp"
using namespace std;
CPPUNIT_TEST_SUITE_REGISTRATION( SMFTest );
void
SMFTest::takeFiveTest ()
{
TestSMF<Time> smf;
smf.open("./test/testdata/TakeFive.mid");
CPPUNIT_ASSERT(!smf.is_empty());
seq->start_write();
smf.seek_to_start();
uint64_t time = 0; /* in SMF ticks */
Evoral::Event<double> ev;
const double frames_per_beat = 100.0;
uint32_t delta_t = 0;
uint32_t size = 0;
uint8_t* buf = NULL;
int ret;
while ((ret = smf.read_event(&delta_t, &size, &buf)) >= 0) {
cerr << "read smf event type " << int(buf[0]) << endl;
ev.set(buf, size, 0.0);
time += delta_t;
if (ret > 0) { // didn't skip (meta) event
// make ev.time absolute time in frames
ev.time() = time * frames_per_beat / (double)smf.ppqn();
ev.set_event_type(type_map->midi_event_type(buf[0]));
seq->append(ev);
}
}
seq->end_write(false);
CPPUNIT_ASSERT(!seq->empty());
}