Question

I'm using socket.io to stream data from a node.js server. The data is coming in at one packet every 33ms. I'm putting the data into a chart in real-time and I'd like to apply a digital high-pass filter on it.

I'm trying to figure out how to use DSP.js to apply an infinite impulse response algorithm on the data - high pass at 1hz - but I'm not really sure how to go about this.

I understand that I would create the filter object using this library (var filter = IIRFilter(HIGHPASS, 1, 30)), but as for the applying the filter (filter.process(signal)), I'm not sure what the signal would be. When each packet comes in, I add it to an array called data. Would it be on this array? Or would I have to do this for each packet as it comes in?

Was it helpful?

Solution

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.

  1. Wait, gather all the samples, finally do the processing before displaying the array data

  2. 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 in data array, then copy data array in filtered_data and call filter.process(filtered_data). Finally display filtered_data.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top