summaryrefslogtreecommitdiff
path: root/drumgizmo/input/test/test.cc
diff options
context:
space:
mode:
Diffstat (limited to 'drumgizmo/input/test/test.cc')
-rw-r--r--drumgizmo/input/test/test.cc9
1 files changed, 6 insertions, 3 deletions
diff --git a/drumgizmo/input/test/test.cc b/drumgizmo/input/test/test.cc
index 457733f..3799f07 100644
--- a/drumgizmo/input/test/test.cc
+++ b/drumgizmo/input/test/test.cc
@@ -31,7 +31,7 @@
class Test {
public:
- Test() { p = 0.1; instr = -1; }
+ Test() { p = 0.1; instr = -1; len = -1; }
~Test() {}
bool init(int instruments, char *inames[]);
@@ -48,6 +48,7 @@ public:
private:
float p;
int instr;
+ int len;
};
bool Test::init(int instruments, char *inames[])
@@ -59,6 +60,7 @@ void Test::setParm(std::string parm, std::string value)
{
if(parm == "p") p = atof(value.c_str());
if(parm == "instr") instr = atoi(value.c_str());
+ if(parm == "len") len = atoi(value.c_str());
}
bool Test::start()
@@ -74,7 +76,7 @@ void Test::pre()
{
}
-event_t *Test::run(size_t pos, size_t len, size_t *nevents)
+event_t *Test::run(size_t pos, size_t nsamples, size_t *nevents)
{
if((float)rand() / (float)RAND_MAX > p) {
*nevents = 0;
@@ -84,12 +86,13 @@ event_t *Test::run(size_t pos, size_t len, size_t *nevents)
*nevents = 1;
event_t *evs = (event_t *)malloc(sizeof(event_t));
evs[0].type = TYPE_ONSET;
+ if(len != -1 && pos > len * 44100) evs[0].type = TYPE_STOP;
if(instr != -1) evs[0].instrument = instr;
else evs[0].instrument = rand() % 32;
evs[0].velocity = (float)rand()/(float)RAND_MAX;
- evs[0].offset = len?rand()%len:0;
+ evs[0].offset = nsamples?rand()%nsamples:0;
return evs;
}