diff options
author | Bent Bisballe Nyeng <deva@aasimon.org> | 2015-07-19 14:03:09 +0200 |
---|---|---|
committer | Bent Bisballe Nyeng <deva@aasimon.org> | 2016-01-20 13:31:09 +0100 |
commit | f7c57640ecaf20148361db0bad321b60009061f7 (patch) | |
tree | 83d0c8234ff24cddddac4e60e248e0366c076e44 /drumgizmo | |
parent | 9131cc64375b5b9bd022ef323621e67907e60f37 (diff) |
Added new nth argument to test input module which plays a note each nth sample. Overrides/disables p argument.
Diffstat (limited to 'drumgizmo')
-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; |