zynaddsubfx

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

commit d1078769203594b7f81f99099733321d543568e5
parent dc9f8ac7d86aea99b4599e0863e079270e12eee2
Author: michiboo <chanmickyyun@gmail.com>
Date:   Mon, 17 Jun 2019 01:33:31 +0300

fix accumulate watchpoint value

Diffstat:
Msrc/Synth/WatchPoint.cpp | 16+++++++++++++---
Msrc/Synth/WatchPoint.h | 1+
2 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/src/Synth/WatchPoint.cpp b/src/Synth/WatchPoint.cpp @@ -100,7 +100,7 @@ void WatchManager::tick(void) //Try to send out any vector stuff for(int i=0; i<MAX_WATCH; ++i) { if(sample_list[i]) { - if(data_list[i][MAX_SAMPLE-1] != 0){ + if(accumulate_index[i] >= 109){ char arg_types[MAX_SAMPLE+1] = {0}; rtosc_arg_t arg_val[MAX_SAMPLE]; for(int j=0; j<sample_list[i]; ++j) { @@ -110,6 +110,7 @@ void WatchManager::tick(void) write_back->writeArray(active_list[i], arg_types, arg_val); deactivate[i] = true; + accumulate_index[i] = 0; } } } @@ -166,9 +167,18 @@ void WatchManager::satisfy(const char *id, float *f, int n) if(selected == -1) return; + int space = MAX_SAMPLE - accumulate_index[selected]; + + if(space >= n) + space = n; + //FIXME buffer overflow - for(int i=0; i<n; ++i) - data_list[selected][sample_list[selected]++] = f[i]; + if(space){ + for(int i=0; i<space; ++i) + data_list[selected][sample_list[selected]++] = f[i]; + + accumulate_index[selected] += space; + } } } diff --git a/src/Synth/WatchPoint.h b/src/Synth/WatchPoint.h @@ -42,6 +42,7 @@ struct WatchManager float data_list[MAX_SAMPLE][MAX_WATCH]; int sample_list[MAX_WATCH]; bool deactivate[MAX_WATCH]; + int accumulate_index[MAX_WATCH]; //External API WatchManager(thrlnk *link=0);