change reasonable-synth to be sample accurate (note on/off)
authorRobin Gareus <robin@gareus.org>
Sun, 6 Jul 2014 11:13:34 +0000 (13:13 +0200)
committerRobin Gareus <robin@gareus.org>
Sun, 6 Jul 2014 11:24:53 +0000 (13:24 +0200)
at expense of slightly increased CPU load.

libs/plugins/reasonablesynth.lv2/rsynth.c

index eff01d8d69270f40b9b32a104fefbe7425acf62a..68bd81714db997ad7d1007aa08a8e479a47f7f79 100644 (file)
@@ -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));