diff options
author | Bent Bisballe Nyeng <deva@aasimon.org> | 2015-07-19 14:03:09 +0200 |
---|---|---|
committer | Bent Bisballe Nyeng <deva@aasimon.org> | 2015-07-19 14:03:09 +0200 |
commit | b06eaaff85cb086829a58d152e1ba7d3206fc368 (patch) | |
tree | 9a6439e86ecb6800a81ea14d1666cf550138abe7 | |
parent | c7005700ef35d91176c4f347bfd876104ced6a33 (diff) |
Added new nth argument to test input module which plays a note each nth sample. Overrides/disables p argument.
-rw-r--r-- | drumgizmo/input/test/test.cc | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/drumgizmo/input/test/test.cc b/drumgizmo/input/test/test.cc index 225a7a2..6032f02 100644 --- a/drumgizmo/input/test/test.cc +++ b/drumgizmo/input/test/test.cc @@ -34,6 +34,8 @@ public: Test() : p(0.1) , instr(-1) + , nth(-1) + , nth_counter(0) {} ~Test() {} @@ -52,6 +54,8 @@ public: private: float p; int instr; + int nth; + int nth_counter; int num_instruments; }; @@ -65,6 +69,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 == "nth") nth = atoi(value.c_str()); } bool Test::start() @@ -87,8 +92,17 @@ event_t *Test::run(size_t pos, size_t nsamples, size_t *nevents) event_t *evs = (event_t *)malloc(sizeof(event_t) * BUFFER_MAX); for(size_t i = 0; i < nsamples; ++i) { - if((float)rand() / (float)RAND_MAX > p) { - continue; + + if(nth != -1) { + if(nth_counter < nth) { + ++nth_counter; + continue; + } + nth_counter = 0; + } else { + if((float)rand() / (float)RAND_MAX > p) { + continue; + } } evs[*nevents].type = TYPE_ONSET; |