berndporr / iir1

DSP IIR realtime filter library written in C++

Home Page:http://berndporr.github.io/iir1/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Butterworth highpass filter like python scipy.signal

hawl666 opened this issue · comments

dear @berndporr :
how can i process data like scipy.signal,here is my python code:
def butter_highpass_filter(data, Fstop1, fs, order=3):
b, a = signal.butter(order, 2.0*Fstop1/fs, 'highpass')
filtedData = signal.filtfilt(b, a, data)
return filtedData

You create an instance of the iir filter and then filter your C array sample by sample.
Note that "filtfilt" is a-causal (!) so you actually need to first filter it from the first to the last sample and then again from the last sample to the first one in two passes. filtfilt emulates an a-causal linear phase filter. Not sure if you really want to do that. Up to you. The standard filter command under python is "lfilter" which emulates the sample by sample realtime IIR filtering as an analogue filter would do it. Also note that Python processes arrays and is for post processing while this library is for realtime processing (i.e. sample by sample) but of course you can filter an array by feeding the samples one by one into the filter.

Check out the demo programs here to see how it's done in C++. A lot of examples are available.