Can't copy buffer in processBlock

Hi all, 


This simple code in processBlock produces silence :

    AudioSampleBuffer in(buffer);

If I remove buffer.clear();, the output is as expected. Any clues ?

From the documentation on the AudioSampleBuffer copy constructor:

Copies another buffer.

This buffer will make its own copy of the other's data, unless the buffer was created using an external data buffer, in which case boths buffers will just point to the same shared block of data.

It is indeed a bit unfortunate (I ran into the same issue once) that when you don't know how the buffer to be copied from was created, you cannot know what the constructor does (own copy of data or refer to the same data). To be safe, always create the new buffer blank, with the same number of channels and samples as the original, and then copy the data.

1 Like

Thanks for your prompt reply

I thought of that but normally when I modify in, buffer should be modified because they're shared ? And anyway the 2 first copyFrom should handle that.

But anyway, I'm gonna try that ! Thanks

...and it works.