summaryrefslogtreecommitdiff
path: root/test/lv2.cc
diff options
context:
space:
mode:
Diffstat (limited to 'test/lv2.cc')
-rw-r--r--test/lv2.cc67
1 files changed, 44 insertions, 23 deletions
diff --git a/test/lv2.cc b/test/lv2.cc
index 32d896c..0ecf178 100644
--- a/test/lv2.cc
+++ b/test/lv2.cc
@@ -35,6 +35,12 @@
#define DG_URI "http://drumgizmo.org/lv2"
+enum class Ports {
+ FreeWheel = 0,
+ MidiPort,
+ AudioPortOffset,
+};
+
/**
* Tests that should be performed:
* -------------------------------
@@ -86,7 +92,7 @@ public:
res = h.verify();
CPPUNIT_ASSERT_EQUAL(0, res);
- res = h.createInstance();
+ res = h.createInstance(44100);
CPPUNIT_ASSERT_EQUAL(0, res);
const char config_fmt[] =
@@ -127,7 +133,7 @@ public:
// run for 1 samples to trigger kit loading
res = h.run(1);
CPPUNIT_ASSERT_EQUAL(0, res);
- sleep(1); // wait for kit to get loaded (async),
+ usleep(1000); // wait for kit to get loaded (async),
res = h.run(100);
CPPUNIT_ASSERT_EQUAL(0, res);
@@ -151,7 +157,7 @@ public:
res = h.verify();
CPPUNIT_ASSERT_EQUAL(0, res);
- res = h.createInstance();
+ res = h.createInstance(44100);
CPPUNIT_ASSERT_EQUAL(0, res);
const char config_fmt[] =
@@ -191,15 +197,19 @@ public:
// Port buffers:
char sequence_buffer[4096];
+ bool freeWheel = false;
+
+ // Free wheel port
+ res = h.connectPort((int)Ports::FreeWheel, (void*)&freeWheel);
LV2TestHost::Sequence seq(sequence_buffer, sizeof(sequence_buffer));
- res = h.connectPort(0, seq.data());
+ res = h.connectPort((int)Ports::MidiPort, seq.data());
CPPUNIT_ASSERT_EQUAL(0, res);
// run for 1 samples to trigger kit loading
res = h.run(1);
CPPUNIT_ASSERT_EQUAL(0, res);
- sleep(1); // wait for kit to get loaded (async),
+ usleep(1000); // wait for kit to get loaded (async),
seq.addMidiNote(5, 1, 127);
res = h.run(100);
@@ -224,7 +234,7 @@ public:
res = h.verify();
CPPUNIT_ASSERT_EQUAL(0, res);
- res = h.createInstance();
+ res = h.createInstance(44100);
CPPUNIT_ASSERT_EQUAL(0, res);
const char config_fmt[] =
@@ -265,14 +275,22 @@ public:
// Port buffers:
char sequence_buffer[4096];
float pcm_buffer[16][10];
+ bool freeWheel = true;
+
+ // Free wheel port
+ res = h.connectPort((int)Ports::FreeWheel, (void*)&freeWheel);
LV2TestHost::Sequence seq(sequence_buffer, sizeof(sequence_buffer));
- res = h.connectPort(0, seq.data());
+ res = h.connectPort((int)Ports::MidiPort, seq.data());
CPPUNIT_ASSERT_EQUAL(0, res);
- for(int i = 1; i <= 16; i++) {
- memset(pcm_buffer, 1, sizeof(pcm_buffer));
- res += h.connectPort(i, pcm_buffer[i-1]);
+ for(int i = 0; i < 16; ++i)
+ {
+ for(int j = 0; j < 10; ++j)
+ {
+ pcm_buffer[i][j] = 0.42;
+ }
+ res += h.connectPort((int)Ports::AudioPortOffset + i, pcm_buffer[i]);
}
CPPUNIT_ASSERT_EQUAL(0, res);
@@ -282,19 +300,19 @@ public:
sleep(1); // wait for kit to get loaded (async),
seq.addMidiNote(5, 1, 127);
- for(int i = 0; i < 10; i++) {
+ for(int i = 0; i < 10; i++)
+ {
res = h.run(10);
+ usleep(1000);
CPPUNIT_ASSERT_EQUAL(0, res);
- /*
- printf("Iteration:\n");
- for(int k = 0; k < 4; k++) {
- printf("#%d ", k);
- for(int j = 0; j < 10; j++) printf("[%f]", pcm_buffer[k][j]);
- printf("\n");
- }
- printf("\n");
- */
+ //printf("Iteration:\n");
+ //for(int k = 0; k < 16; k++) {
+ // printf("#%d ", k);
+ // for(int j = 0; j < 10; j++) printf("[%f]", pcm_buffer[k][j]);
+ // printf("\n");
+ //}
+ //printf("\n");
seq.clear();
}
@@ -302,6 +320,7 @@ public:
seq.addMidiNote(5, 1, 127);
res = h.run(10);
+ usleep(1000);
CPPUNIT_ASSERT_EQUAL(0, res);
/*
@@ -321,9 +340,11 @@ public:
comp_val.u = 1040744448; // floating point value 0.133301....
- for(int k = 0; k < 4; k++) {
- for(int j = 0; j < 10; j++) {
- CPPUNIT_ASSERT_EQUAL(((j==0)?comp_val.f:0), pcm_buffer[k][j]);
+ for(int k = 0; k < 4; k++)
+ {
+ for(int j = 0; j < 10; j++)
+ {
+ CPPUNIT_ASSERT_EQUAL(((j==5)?comp_val.f:0), pcm_buffer[k][j]);
}
}
seq.clear();