zynaddsubfx

ZynAddSubFX open source synthesizer
Log | Files | Refs | Submodules | LICENSE

commit ed0a081315fd43ff0425496681b0a3991d6a68b1
parent e4a02e4bb94e2c19e9e495fe0be9c639bfa93a8d
Author: michiboo <[email protected]>
Date:   Sat, 20 Jul 2019 17:54:33 +0300

fix trigger test

Diffstat:
Msrc/Synth/WatchPoint.cpp | 22++++++++++++++++++----
Msrc/Tests/TriggerTest.h | 27++++++++-------------------
2 files changed, 26 insertions(+), 23 deletions(-)

diff --git a/src/Synth/WatchPoint.cpp b/src/Synth/WatchPoint.cpp @@ -82,13 +82,14 @@ void WatchManager::add_watch(const char *id) fast_strcpy(active_list[i], id, MAX_WATCH_PATH); new_active = true; sample_list[i] = 0; + //printf("\n added watchpoint ID %s\n",id); break; } } } void WatchManager::del_watch(const char *id) -{ +{ //Queue up the delete for(int i=0; i<MAX_WATCH; ++i) if(!strcmp(active_list[i], id)) @@ -121,12 +122,14 @@ void WatchManager::tick(void) //Clear deleted slots for(int i=0; i<MAX_WATCH; ++i) { if(deactivate[i]) { + //printf("\ndelete id : %s\n",active_list[i]); memset(active_list[i], 0, MAX_SAMPLE); sample_list[i] = 0; memset(data_list[i], 0, sizeof(float)*MAX_SAMPLE); memset(prebuffer[i], 0, sizeof(float)*MAX_SAMPLE); deactivate[i] = false; trigger[i] = false; + } } @@ -146,10 +149,14 @@ bool WatchManager::active(const char *id) const bool WatchManager::trigger_active(const char *id) const { - for(int i=0; i<MAX_WATCH; ++i) - if(!strcmp(active_list[i], id)) + for(int i=0; i<MAX_WATCH; ++i){ + //printf("\n current watch id :%s and id : %s\n",active_list[i], id); + if(!strcmp(active_list[i], id)){ + //printf("\n testing trigger %s\n",active_list[i]); if(trigger[i]) return true; + } + } return false; } @@ -179,6 +186,11 @@ void WatchManager::satisfy(const char *id, float *f, int n) if(selected == -1) return; + // printf("\npath : %s \n", id); + + // if (!strcmp(id,"/part0/kit0/subpars/noteout")) + // printf("\n matched: %s\n", id); + int space = MAX_SAMPLE - sample_list[selected]; @@ -201,16 +213,18 @@ void WatchManager::satisfy(const char *id, float *f, int n) if (f[i-1] <= 0 && f[i] > 0) trigger[selected] = true; for(int k=0; k<MAX_WATCH; ++k) { - if(selected != k){ + if(selected != k && !trigger[k]){ char tmp[128]; char tmp1[128]; strcpy(tmp, active_list[selected]); strcpy(tmp1, active_list[k]); + if(strlen(active_list[k]) < strlen(active_list[selected])) tmp[strlen(tmp)-1] =0; else if (strlen(active_list[k]) > strlen(active_list[selected])) tmp1[strlen(tmp1)-1] =0; if(!strcmp(tmp1,tmp)){ + //printf("\n path compare %s vs %s id: %s\n",tmp,tmp1, active_list[k]); trigger[k] = true; int space_k = MAX_SAMPLE - sample_list[k]; if(space_k >= n) diff --git a/src/Tests/TriggerTest.h b/src/Tests/TriggerTest.h @@ -52,7 +52,8 @@ class TriggerTest:public CxxTest::TestSuite void setUp() { synth = new SYNTH_T; // //First the sensible settings and variables that have to be set: - synth->buffersize = 256; + synth->buffersize = 32; + synth->alias(false); outL = new float[synth->buffersize]; for(int i = 0; i < synth->buffersize; ++i) *(outL + i) = 0; @@ -60,7 +61,7 @@ class TriggerTest:public CxxTest::TestSuite for(int i = 0; i < synth->buffersize; ++i) *(outR + i) = 0; - synth->buffersize = 64; + time = new AbsTime(*synth); tr = new rtosc::ThreadLink(1024,3); @@ -79,17 +80,12 @@ class TriggerTest:public CxxTest::TestSuite TS_ASSERT(wrap.enterbranch("SUB_SYNTH_PARAMETERS")); defaultPreset->getfromXML(wrap); - synth = new SYNTH_T; - synth->buffersize = 64; controller = new Controller(*synth, time); //lets go with.... 50! as a nice note testnote = 50; float freq = 440.0f * powf(2.0f, (testnote - 69.0f) / 12.0f); - - synth = new SYNTH_T; - synth->buffersize = 64; SynthParams pars{memory, *controller, *synth, *time, freq, 120, 0, testnote / 12.0f, false, prng()}; note = new SUBnote(defaultPreset, pars, w); this->pars = defaultPreset; @@ -127,32 +123,25 @@ class TriggerTest:public CxxTest::TestSuite TS_ASSERT(!tr->hasNext()); w->add_watch("noteout"); - + w->add_watch("noteout1"); note->noteout(outL, outR); sampleCount += synth->buffersize; w->tick(); + TS_ASSERT(w->trigger_active("noteout1")); + TS_ASSERT(w->trigger_active("noteout")); note->noteout(outL, outR); sampleCount += synth->buffersize; w->tick(); - // TS_ASSERT(!tr->hasNext()); - // w->add_watch("noteout1"); note->noteout(outL, outR); sampleCount += synth->buffersize; - // w->tick(); + w->tick(); + TS_ASSERT_EQUALS(string("noteout1"), tr->read()); note->noteout(outL, outR); sampleCount += synth->buffersize; w->tick(); - TS_ASSERT(tr->hasNext()); - TS_ASSERT(w->trigger_active("/part0/kit0/subpars/noteout")); - - TS_ASSERT_EQUALS(string("noteout"), tr->read()); - // TS_ASSERT(tr->hasNext()); - // TS_ASSERT_EQUALS(string("noteout1"), tr->read()); - // TS_ASSERT(!tr->hasNext()); - while(!note->finished()) { note->noteout(outL, outR); #ifdef WRITE_OUTPUT