zynaddsubfx

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

commit 7f2a23ae3bf358ff2229f935aa3acb6013a3ca76
parent c07e1ce0c07e02c9d832c5564ad072804986faf0
Author: michiboo <chanmickyyun@gmail.com>
Date:   Wed, 10 Jul 2019 18:07:11 +0300

add prebuffer for active watchpoint

Diffstat:
Msrc/Synth/WatchPoint.cpp | 36++++++++++++++++++++++++++----------
Msrc/Synth/WatchPoint.h | 1+
2 files changed, 27 insertions(+), 10 deletions(-)

diff --git a/src/Synth/WatchPoint.cpp b/src/Synth/WatchPoint.cpp @@ -124,6 +124,7 @@ void WatchManager::tick(void) 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; } @@ -171,6 +172,11 @@ void WatchManager::satisfy(const char *id, float *f, int n) int space = MAX_SAMPLE - sample_list[selected]; + + for(int i = 0; i < n; ++i){ + prebuffer[selected][i] = f[i]; + } + if(space >= n) space = n; @@ -187,16 +193,26 @@ void WatchManager::satisfy(const char *id, float *f, int n) trigger[selected] = true; for(int k=0; k<MAX_WATCH; ++k) { if(selected != 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)){ - trigger[k] = true; + 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)){ + trigger[k] = true; + int space_k = MAX_SAMPLE - sample_list[k]; + if(space_k >= n) + space_k = n; + + for(int j = i; j < space_k ; ++j){ + data_list[k][sample_list[k]] = prebuffer[k][j]; + sample_list[k]++; + } + + } } } diff --git a/src/Synth/WatchPoint.h b/src/Synth/WatchPoint.h @@ -40,6 +40,7 @@ struct WatchManager bool new_active; char active_list[MAX_WATCH][MAX_WATCH_PATH]; float data_list[MAX_WATCH][MAX_SAMPLE]; + float prebuffer[MAX_WATCH][MAX_SAMPLE]; int sample_list[MAX_WATCH]; bool deactivate[MAX_WATCH]; bool trigger[MAX_WATCH];