From 82aec0140304828d8bd52cbd59635bd55cd985cf Mon Sep 17 00:00:00 2001 From: Sampo Savolainen Date: Thu, 14 Aug 2008 20:20:09 +0000 Subject: [PATCH] Fix glitches in automation events due to the other glitch fix made a few weeks ago. It would be more elegant to fix the other glitch so it aligns the buffers correctly (so they do not add the offset to the buffer pointers), but that might need design changes. git-svn-id: svn://localhost/ardour2/branches/2.0-ongoing@3693 d708f5d6-7413-0410-9779-e7cbd77b26cf --- libs/ardour/insert.cc | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/libs/ardour/insert.cc b/libs/ardour/insert.cc index 9af73e9a7d..35b820dad3 100644 --- a/libs/ardour/insert.cc +++ b/libs/ardour/insert.cc @@ -428,16 +428,25 @@ PluginInsert::automation_run (vector& bufs, uint32_t nbufs, nframes_t connect_and_run (bufs, nbufs, nframes, offset, true, now); return; } + + nframes_t buffer_correct = 0; + int i; + while (nframes) { + nframes_t cnt = min (((nframes_t) ceil (next_event.when) - now), nframes); - nframes_t cnt = min (((nframes_t) ceil (next_event.when) - now), nframes); - + // This is called first, but nframes = 256 connect_and_run (bufs, nbufs, cnt, offset, true, now); nframes -= cnt; offset += cnt; now += cnt; + buffer_correct += cnt; + + for (i = 0; i < nbufs; i++) { + bufs[i] += cnt; + } if (!find_next_event (now, end, next_event)) { break; @@ -449,6 +458,10 @@ PluginInsert::automation_run (vector& bufs, uint32_t nbufs, nframes_t if (nframes) { connect_and_run (bufs, nbufs, nframes, offset, true, now); } + + for (i = 0; i < nbufs; i++) { + bufs[i] -= buffer_correct; + } } float