In filter design, how should I deal with the starting two delayed samples in the current buffer?

It may involve the last 2 samples from the last buffer. So should I always store the last two samples from a buffer, and then use the stored two samples in the next buffer, or should I just ignore it and set the starting 2 samples to 0.

I think it’s standard practice to start the filter history with zeros.

1 Like

Yes, you should keep the last samples from the previous buffer.
At the very beginning, using zeroes is fine, but while running, you will create artefacts by using zeroes at random points, which is what buffer boundaries are, random positions in the signal.

I would reset those two samples in prepareToPlay, since this is how the host signals a discontinuity, if it wishes to.