In an IIR filter, all past samples count in computation of the result for current sample. That's why it is called infinite impulse response.
I can see 2 options for your processing.
Wait, gather all the samples, finally do the processing before displaying the array
data
Do it real-time! Keep in mind that the filtered data must not be mixed with raw data. Otherwise the filtering will be distorted. Create a new array
filtered_data
. Each time a packet comes in, copy it indata
array, then copydata
array infiltered_data
and callfilter.process(filtered_data)
. Finally displayfiltered_data
.