0

I am trying to apply some filtering in C/C++ code, I have designed an algorithm using Matlab and it works well, so now I am moving it to native code.

I am interested in the filter function.
In my matlab script it is used as follows.

[y_blk, fir1_state] = filter( h, 1, x.*c, fir1_state ); 

Where the h argument is coefficients generated by firpm function.

I have tried to find any implementation, but unfortunately no results.

I would be very grateful if someone could provide an implementation of this function

Or maybe there is an existing implementation of this function in some library.

Thanks

  • 1
    The `filter` function is implemented in a large number of open-source packages, such as octave and SciPy. – MBaz Nov 19 '17 at 19:33
  • look at https://dsp.stackexchange.com/questions/1571/optimized-ansi-c-libraries-for-dsp and also Google "signal processing c library" –  Nov 19 '17 at 21:28
  • You can find a lot of implementations of a FIR Filter on the INTERNET. I wanted to write the code but I already found it on the below link. https://stackoverflow.com/questions/14997850/fir-filter-implementation-in-c-programming – Alexandru Rusu Feb 22 '18 at 15:23

1 Answers1

1

FIR filtering is an operation whose implementation hugely benefits from utilization of architecture-specific instructions, compiler intrinsics, etc. Hence, if your only goal is to get a performant FIR algorithm, you should try to find a dsp library specifically for your target architecture. Those are most likely written in assembly language with a C interface and you can expect an orders-of-magnitude better performance than you would achieve with a generic C implementation of a transversal FIR.

If the latter is exactly what you're looking for - a generic FIR implementation in C - let me point you towards https://iowegian.com/. They offer a commercial filter design software called ScopeFIR. You can download and install a free trial version of it (no registration). In the program directory, you can find a source file "FirAlgs.c" that offers a variety of well-documented FIR implementations. It's written for MSVC but should be portable to basically anywhere without hassle.