summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordeva <deva>2011-07-17 12:26:29 +0000
committerdeva <deva>2011-07-17 12:26:29 +0000
commit7d35e31ea61cb7fa088aa33a90f3207919fcd0b1 (patch)
tree8783116f676a0add64bddb0f7d3f5b3f0772f842
parent75e317627fdc9bcdc2c482038e6af9acb096a766 (diff)
Added 'len' parameter.
-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;
}