From 36135baaacb8249f5a812aab6b547557c6c37f73 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Sun, 6 Jul 2014 13:13:34 +0200 Subject: [PATCH] change reasonable-synth to be sample accurate (note on/off) at expense of slightly increased CPU load. --- libs/plugins/reasonablesynth.lv2/rsynth.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libs/plugins/reasonablesynth.lv2/rsynth.c b/libs/plugins/reasonablesynth.lv2/rsynth.c index eff01d8d69..68bd81714d 100644 --- a/libs/plugins/reasonablesynth.lv2/rsynth.c +++ b/libs/plugins/reasonablesynth.lv2/rsynth.c @@ -402,8 +402,9 @@ static uint32_t synth_sound (void *synth, uint32_t written, const uint32_t nfram uint32_t nremain = nframes - written; if (rs->boffset >= BUFFER_SIZE_SAMPLES) { - rs->boffset = 0; - synth_fragment(rs, BUFFER_SIZE_SAMPLES, rs->buf[0], rs->buf[1]); + const uint32_t tosynth = MIN(BUFFER_SIZE_SAMPLES, nremain); + rs->boffset = BUFFER_SIZE_SAMPLES - tosynth; + synth_fragment(rs, tosynth, &(rs->buf[0][rs->boffset]), &(rs->buf[1][rs->boffset])); } uint32_t nread = MIN(nremain, (BUFFER_SIZE_SAMPLES - rs->boffset));