I am doing some overlap and save functions to make my filter give realtime playback of windowed buffers. To do this I have to construct a new buffer that is twice as long as the one sent in by the Host. I construct the "processBuffer" copying from the last buffer received by the processBlock(), then appending the current buffer given to the processBlock(). like this:
processBuffer = new AudioSampleBuffer (2, blockSize*2);
processBuffer->copyFrom(channelIndex, 0, *lastInputBuffer, channelIndex, 0, blockSize);
processBuffer->copyFrom(channelIndex, blockSize, buffer, channelIndex, 0, blockSize);
After building successfully I get this assertion on the first of the above lines:
jassert (sourceStartSample >= 0 && sourceStartSample + numSamples <= source.size);
...which is totally correct. But I only want to copy into the first half of processBuffer, not fill it to the end. In the next line, the "destStartSample" is at the index half way through the processBuffer.
In Matlab I would just do this with:
processBuffer = [lastInputBuffer; buffer;]; %for a column vector
Is there a better way to join two sample buffers end to end into another AudioSampleBuffer?